Remove deprecated functions for log managing from Python example.

GitOrigin-RevId: 76ce3b9dbd5b8d9d4d8f92fd3ee158cc8c8d6d12
This commit is contained in:
levlam 2019-04-30 22:51:17 +03:00
parent 37c83bd39e
commit fca3eacf4b

View File

@ -38,18 +38,6 @@ td_json_client_destroy = tdjson.td_json_client_destroy
td_json_client_destroy.restype = None
td_json_client_destroy.argtypes = [c_void_p]
td_set_log_file_path = tdjson.td_set_log_file_path
td_set_log_file_path.restype = c_int
td_set_log_file_path.argtypes = [c_char_p]
td_set_log_max_file_size = tdjson.td_set_log_max_file_size
td_set_log_max_file_size.restype = None
td_set_log_max_file_size.argtypes = [c_longlong]
td_set_log_verbosity_level = tdjson.td_set_log_verbosity_level
td_set_log_verbosity_level.restype = None
td_set_log_verbosity_level.argtypes = [c_int]
fatal_error_callback_type = CFUNCTYPE(None, c_char_p)
td_set_log_fatal_error_callback = tdjson.td_set_log_fatal_error_callback
@ -60,10 +48,20 @@ td_set_log_fatal_error_callback.argtypes = [fatal_error_callback_type]
def on_fatal_error_callback(error_message):
print('TDLib fatal error: ', error_message)
td_set_log_verbosity_level(1)
def td_execute(query):
query = json.dumps(query).encode('utf-8')
result = td_json_client_execute(None, query)
if result:
result = json.loads(result.decode('utf-8'))
return result
c_on_fatal_error_callback = fatal_error_callback_type(on_fatal_error_callback)
td_set_log_fatal_error_callback(c_on_fatal_error_callback)
# setting TDLib log verbosity level to 1 (errors)
print(td_execute({'@type': 'setLogVerbosityLevel', 'new_verbosity_level': 1, '@extra': 1.01234}))
# create client
client = td_json_client_create()
@ -78,14 +76,7 @@ def td_receive():
result = json.loads(result.decode('utf-8'))
return result
def td_execute(query):
query = json.dumps(query).encode('utf-8')
result = td_json_client_execute(None, query)
if result:
result = json.loads(result.decode('utf-8'))
return result
# testing TDLib execute method
# another test for TDLib execute method
print(td_execute({'@type': 'getTextEntities', 'text': '@telegram /test_command https://telegram.org telegram.me', '@extra': ['5', 7.0]}))
# testing TDLib send method