How to use the proxmoxer.backends.base_ssh.Response function in proxmoxer

To help you get started, we’ve selected a few proxmoxer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swayf / proxmoxer / proxmoxer / backends / base_ssh.py View on Github external
"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)
github swayf / proxmoxer / proxmoxer / backends / base_ssh.py View on Github external
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)