Answer the question
In order to leave comments, you need to log in
How to run python scripts on OpenShift?
I recently wrote a python bot ( pyTelegramBotAPI ) and decided to put it on OpenShift hosting
. Bot messages are received using the polling method. The script works fine on the computer, and after sending it to OpenShift, the bot received one message and was cut down.
Perhaps I should not have sent the main program code to the setup.py file, which is loaded immediately, but I did not find another way to run the script.
Actually throws an error per linebot.polling(none_stop=True, interval=0)
Traceback (most recent call last):
File "/var/lib/openshift/57517dca0c1e660af1000092/app-root/runtime/rep o//setup.py", line 166, in module
bot.polling(none_stop=True, interval=0 )
File "/var/lib/openshift/57517dca0c1e660af1000092/python/virtenv/venv/lib/python3.3/site-packages/telebot/init.py", line 192, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "/var/lib/openshift/57517dca0c1e660af1000092/python/virtenv/venv/ lib/python3.3/site-packages/telebot/init.py", line 216, in __threaded_pollin g
self.worker_pool.raise_exceptions()
File "/ var/lib/openshift/57517dca0c1e660af1000092/python/virtenv/venv/ lib/python3.3/site-packages/telebot/util.py", line 103, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info1, self.exc_info[2])
File "/opt/rh/python33/root/usr/lib/python3.3/site-packages/six.py", line 329, in reraise
raise value
File "/var/lib/openshift/57517dca0c1e660af1000092/python/virtenv/venv/ lib/python3.3/site-packages/telebot/util.py", line 54, in run remote: task (*args, **kwargs)
def log(message):
print("\n~~~~~~")
print(str(datetime.datetime.now()))
print("Message from {0} {1}. (id = {2}, chat = {3}) \n Text - {4}".format(message.from_user.first_name,
message.from_user.last_name,
str(message.from_user.id),
str(message.chat.id),
message.text))
functions.log(message) File "/var/lib/openshift/57517dca0c1e660af1000092/app-root/runtime/repo/functions.py", line 16, in log
message.text))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 77-82: ordinal not in range(128)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question