Print Protovac messages
This commit is contained in:
parent
db24789f5c
commit
4d231bece7
12
main.py
12
main.py
|
@ -151,7 +151,7 @@ def message_protovac(message):
|
||||||
cookies=cookies,
|
cookies=cookies,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
json=json_data,
|
json=json_data,
|
||||||
timeout=20,
|
timeout=30,
|
||||||
)
|
)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return json.loads(r.text.split('\n')[-2])['replies'][0]['text']
|
return json.loads(r.text.split('\n')[-2])['replies'][0]['text']
|
||||||
|
@ -159,6 +159,14 @@ def message_protovac(message):
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
return 'Error'
|
return 'Error'
|
||||||
|
|
||||||
|
def print_messages(messages):
|
||||||
|
try:
|
||||||
|
with open('/dev/usb/lp0', 'w') as f:
|
||||||
|
for m in messages:
|
||||||
|
f.write(' ' + m + '\n')
|
||||||
|
f.write('\n')
|
||||||
|
except BaseException as e:
|
||||||
|
logging.exception(e)
|
||||||
|
|
||||||
if wa_api_key:
|
if wa_api_key:
|
||||||
import wolframalpha
|
import wolframalpha
|
||||||
|
@ -738,6 +746,7 @@ while True:
|
||||||
initial_indent=' '*20,
|
initial_indent=' '*20,
|
||||||
subsequent_indent=' '*20,
|
subsequent_indent=' '*20,
|
||||||
)
|
)
|
||||||
|
print_messages(lines)
|
||||||
messages.append('')
|
messages.append('')
|
||||||
messages.extend(lines)
|
messages.extend(lines)
|
||||||
|
|
||||||
|
@ -747,6 +756,7 @@ while True:
|
||||||
reply,
|
reply,
|
||||||
width=60,
|
width=60,
|
||||||
)
|
)
|
||||||
|
print_messages(lines)
|
||||||
messages.append('')
|
messages.append('')
|
||||||
messages.extend(lines)
|
messages.extend(lines)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user