Update python example: Use sys.exit for quitting

automatically sends the message to `stderr` and sets the exit-code to 1
`quit` is only for exiting the interpreter, use the recommended `sys.exit`
This commit is contained in:
Sebastian 2021-11-18 12:39:02 +01:00 committed by Aliaksei Levin
parent bd733c1c6e
commit 505fed00bd
1 changed files with 2 additions and 4 deletions

View File

@ -13,8 +13,7 @@ import sys
# load shared library
tdjson_path = find_library('tdjson') or 'tdjson.dll'
if tdjson_path is None:
print('can\'t find tdjson library')
quit()
sys.exit("Can't find 'tdjson' library")
tdjson = CDLL(tdjson_path)
# load TDLib functions from shared library
@ -43,8 +42,7 @@ _td_set_log_message_callback.argtypes = [c_int, log_message_callback_type]
# initialize TDLib log with desired parameters
def on_log_message_callback(verbosity_level, message):
if verbosity_level == 0:
print('TDLib fatal error: ', message)
sys.stdout.flush()
sys.exit('TDLib fatal error: %r' % message)
def td_execute(query):
query = json.dumps(query).encode('utf-8')