def run_job()

in cstar/remote_paramiko.py [0:0]


    def run_job(self, file, jobid, timeout=None, env={}):
        try:
            self._connect()

            transport = self.client.get_transport()
            session = transport.open_session()
            paramiko.agent.AgentRequestHandler(session)

            dir = ".cstar/remote-jobs/" + jobid

            self.run(("mkdir", "-p", dir))

            self.put_command(file, "%s/job" % (dir,))

            # Manually insert environment into script, since passing env into exec_command leads to it being
            # ignored on most ssh servers. :-(

            for key in env:
                if _alnum_re.search(key):
                    raise BadEnvironmentVariable(key)
            
            # substitute host variables in the command
            env_str = self._substitute_host_variables(" ".join(key + "=" + self.escape(value) for key, value in env.items()))

            remote_script = resource_string('cstar.resources', 'scripts/remote_job.sh')
            wrapper = remote_script.decode("utf-8") % (env_str,)
            self.write_command(wrapper, "%s/wrapper" % (dir,))

            cmd = """