Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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'))
Esempio n. 5
0
 def test_list_scp_wrong_key(self):
     with self.assertRaises(AuthenticationException):
         list_remote('scp://runner@localhost:'+self.remote_dir_path,
                     self.test_wrong_key)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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'))
Esempio n. 9
0
 def test_list_scp_wrong_key(self):
     with self.assertRaises(AuthenticationException):
         list_remote('scp://localhost:'+self.remote_dir_path,
                     self.test_wrong_key)