Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"python -c 'import tempfile; import sys; tf = tempfile.NamedTemporaryFile(); sys.stdout.write(tf.name)'")
self.upload_file_obj(data['filename'], tmp_filename)
data['filename'] = data['filename'].name
data['tmpfilename'] = tmp_filename
translated_data = ' '.join(["-{0} {1}".format(k, v) for k, v in chain(data.items(), params.items())])
full_cmd = 'pvesh {0}'.format(' '.join(filter(None, (cmd, url, translated_data))))
stdout, stderr = self._exec(full_cmd)
match = lambda s: re.match('\d\d\d [a-zA-Z]', s)
# sometimes contains extra text like 'trying to acquire lock...OK'
status_code = next(
(int(s.split()[0]) for s in stderr.splitlines() if match(s)),
500)
if stdout:
return Response(stdout, status_code)
else:
return Response(stderr, status_code)
data['filename'] = data['filename'].name
data['tmpfilename'] = tmp_filename
translated_data = ' '.join(["-{0} {1}".format(k, v) for k, v in chain(data.items(), params.items())])
full_cmd = 'pvesh {0}'.format(' '.join(filter(None, (cmd, url, translated_data))))
stdout, stderr = self._exec(full_cmd)
match = lambda s: re.match('\d\d\d [a-zA-Z]', s)
# sometimes contains extra text like 'trying to acquire lock...OK'
status_code = next(
(int(s.split()[0]) for s in stderr.splitlines() if match(s)),
500)
if stdout:
return Response(stdout, status_code)
else:
return Response(stderr, status_code)