Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def start(self):
args = [sys.executable,
'-m', 'pyexasol', 'script_output',
'--output-dir', str(self.output_dir),
'--ppid', str(utils.get_pid())
]
if self.host:
args.append('--host')
args.append(self.host)
if self.port:
args.append('--port')
args.append(str(self.port))
self.proc = subprocess.Popen(args, stdout=subprocess.PIPE)
self.output_address = self.proc.stdout.readline().decode().rstrip('\n')
self.proc.stdout.close()
def service_actions(self):
utils.check_orphaned(self.initial_ppid)
def execute_udf_output(self, query, query_params=None):
"""
Execute SQL query with UDF script, capture output
Return ExaStatement object and list of Path-objects for script output log files
Exasol should be able to open connection to the host where current script is running
"""
self._udf_output_count += 1
output_dir = utils.get_output_dir_for_statement(self.options['udf_output_dir'],
self.session_id(),
self._udf_output_count)
script_output = ExaScriptOutputProcess(self.options['udf_output_bind_address'][0],
self.options['udf_output_bind_address'][1],
output_dir)
script_output.start()
# This option is useful to get around complex network setups, like Exasol running in Docker containers
if self.options['udf_output_connect_address']:
address = f"{self.options['udf_output_connect_address'][0]}:{self.options['udf_output_connect_address'][1]}"
else:
address = script_output.get_output_address()
self.execute("ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS = {address}", {'address': address})