Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, host, port, mode, compression=False, encryption=False):
self.http_proc = ExaHTTPProcess(host, port, compression, encryption, mode)
self.http_proc.start()
self.proxy = self.http_proc.get_proxy()
if callback_params is None:
callback_params = {}
if import_params is None:
import_params = {}
if 'format' in import_params:
compression = False
else:
compression = self.options['compression']
if not callable(callback):
raise ValueError('Callback argument is not callable')
try:
http_proc = ExaHTTPProcess(self.ws_host, self.ws_port, compression, self.options['encryption'], HTTP_IMPORT)
http_proc.start()
sql_thread = ExaSQLImportThread(self, http_proc.get_proxy(), compression, table, import_params)
sql_thread.set_http_proc(http_proc)
sql_thread.start()
result = callback(http_proc.write_pipe, src, **callback_params)
http_proc.write_pipe.close()
http_proc.join()
sql_thread.join()
return result
except Exception as e:
# Close HTTP Server if it is still running
if 'http_proc' in locals():
if callback_params is None:
callback_params = {}
if export_params is None:
export_params = {}
if 'format' in export_params:
compression = False
else:
compression = self.options['compression']
if query_params is not None:
query_or_table = self.format.format(query_or_table, **query_params)
try:
http_proc = ExaHTTPProcess(self.ws_host, self.ws_port, compression, self.options['encryption'], HTTP_EXPORT)
http_proc.start()
sql_thread = ExaSQLExportThread(self, http_proc.get_proxy(), compression, query_or_table, export_params)
sql_thread.set_http_proc(http_proc)
sql_thread.start()
result = callback(http_proc.read_pipe, dst, **callback_params)
http_proc.read_pipe.close()
http_proc.join()
sql_thread.join()
return result
except Exception as e:
# Close HTTP Server if it is still running
if 'http_proc' in locals():