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

View File

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