def list_remote_files(job): """Lists valid study files on a remote server Parameters ---------- job : qiita_db.processing_job.ProcessingJob The processing job performing the task """ with qdb.sql_connection.TRN: url = job.parameters.values['url'] private_key = job.parameters.values['private_key'] study_id = job.parameters.values['study_id'] try: files = list_remote(url, private_key) r_client.set("upload_study_%s" % study_id, dumps({ 'job_id': job.id, 'url': url, 'files': files })) except Exception: job._set_error(traceback.format_exception(*exc_info())) else: job._set_status('success') finally: # making sure to always delete the key so Qiita never keeps it remove(private_key)
def list_remote_files(job): """Lists valid study files on a remote server Parameters ---------- job : qiita_db.processing_job.ProcessingJob The processing job performing the task """ with qdb.sql_connection.TRN: url = job.parameters.values['url'] private_key = job.parameters.values['private_key'] study_id = job.parameters.values['study_id'] try: files = list_remote(url, private_key) r_client.set("upload_study_%s" % study_id, dumps({'job_id': job.id, 'url': url, 'files': files})) except Exception: job._set_error(traceback.format_exception(*exc_info())) else: job._set_status('success') finally: # making sure to always delete the key so Qiita never keeps it remove(private_key)
def test_list_scp(self): kpath = join(self.temp_local_dir, 'tmp-key') copyfile(self.test_ssh_key, kpath) read_file_list = list_remote( 'scp://runner@localhost:'+self.remote_dir_path, kpath) self.assertCountEqual(read_file_list, self.exp_files)
def test_list_scp_nonexist_key(self): with self.assertRaises(IOError): list_remote('scp://runner@localhost:'+self.remote_dir_path, join(self.self_dir_path, 'nokey'))
def test_list_scp_wrong_key(self): with self.assertRaises(AuthenticationException): list_remote('scp://runner@localhost:'+self.remote_dir_path, self.test_wrong_key)
def test_list_sftp(self): read_file_list = list_remote( 'sftp://localhost:' + self.remote_dir_path, self.test_ssh_key) self.assertCountEqual(read_file_list, self.exp_files)
def test_list_sftp(self): read_file_list = list_remote('sftp://localhost:'+self.remote_dir_path, self.test_ssh_key) self.assertCountEqual(read_file_list, self.exp_files)
def test_list_scp_nonexist_key(self): with self.assertRaises(IOError): list_remote('scp://localhost:'+self.remote_dir_path, join(self.self_dir_path, 'nokey'))
def test_list_scp_wrong_key(self): with self.assertRaises(AuthenticationException): list_remote('scp://localhost:'+self.remote_dir_path, self.test_wrong_key)