def setUp(self): super(CleanTest, self).setUp() ## Setup pre-casava results for k in self.RESULT_FILES.keys(): for f in self.RESULT_FILES[k]: outfile = os.path.join(intermediate, flowcell, f) if not os.path.exists(os.path.dirname(outfile)): safe_makedir(os.path.dirname(outfile)) exit_code = shell.exec_cmd2(['touch', outfile]) for k in self.INPUT_FILES.keys(): for f in self.INPUT_FILES[k]: outfile = os.path.join(data, flowcell, '1_120829_AA001AAAXX_barcode', f) if not os.path.exists(os.path.dirname(outfile)): safe_makedir(os.path.dirname(outfile)) exit_code = shell.exec_cmd2(['touch', outfile]) ## Setup casava results for k in self.RESULT_FILES.keys(): for f in self.RESULT_FILES[k]: outfile = os.path.join(data, k, flowcell, f) if not os.path.exists(os.path.dirname(outfile)): safe_makedir(os.path.dirname(outfile)) exit_code = shell.exec_cmd2(['touch', outfile]) for k in self.INPUT_FILES.keys(): for f in self.INPUT_FILES[k]: outfile = os.path.join(data, k, flowcell, '1_120829_AA001AAAXX_barcode', f) if not os.path.exists(os.path.dirname(outfile)): safe_makedir(os.path.dirname(outfile)) exit_code = shell.exec_cmd2(['touch', outfile])
def sync(self, source): sources = self.app.db['sources'] src = self.app.db['sources'][source] if not src['is_local']: if not os.path.exists(os.path.join(src['cache'], '.git')): shell.exec_cmd2([ 'git', 'clone', src['path'], src['cache'] ]) else: os.chdir(src['cache']) shell.exec_cmd2(['git', 'pull']) src['last_sync_time'] = datetime.now() sources[source] = src self.app.db['sources'] = sources
def unpack(self): cmd = ['java', '-jar', 'lib/abe.jar', 'unpack', self.options.in_backup[0], self.options.out_archive[0]] exitcode = shell.exec_cmd2(cmd) self.log.debug('abe exit: %d.' % exitcode, __name__) if exitcode == 0: # self.log.info('Done.') # self.log.info('tar archive is saved as: %s' % self.options.out_archive[0]) CoreUtil.hash(self.options.out_archive[0]) else: self.log.warning('Backup Unpack module exit unexpectedly: %d.' % exitcode)
def sync(self, source): sources = self.app.db['sources'] src = self.app.db['sources'][source] if not src['is_local']: if not os.path.exists(os.path.join(src['cache'], '.git')): shell.exec_cmd2(['git', 'clone', src['path'], src['cache']]) else: orig_dir = fs.abspath(os.curdir) try: os.chdir(src['cache']) shell.exec_cmd2(['git', 'pull']) os.chdir(orig_dir) finally: os.chdir(orig_dir) src['last_sync_time'] = datetime.now() sources[source] = src self.app.db['sources'] = sources
def sync(self, source): sources = self.app.db["sources"] src = self.app.db["sources"][source] if not src["is_local"]: if not os.path.exists(os.path.join(src["cache"], ".git")): shell.exec_cmd2(["git", "clone", src["path"], src["cache"]]) else: orig_dir = fs.abspath(os.curdir) try: os.chdir(src["cache"]) shell.exec_cmd2(["git", "pull"]) os.chdir(orig_dir) finally: os.chdir(orig_dir) src["last_sync_time"] = datetime.now() sources[source] = src self.app.db["sources"] = sources
def _do_tests(self): print('Running Nose Tests') out, err, res = shell.exec_cmd(['which', 'nosetests']) nose = out.decode('utf-8').strip() if self.app.pargs.loud: cmd_args = ['coverage', 'run', nose, '--verbosity=3'] res = shell.exec_cmd2(cmd_args) else: cmd_args = ['coverage', 'run', nose, '--verbosity=0'] out, err, res = shell.exec_cmd(cmd_args) if res > 0: self._do_error("\n\nNose tests did not pass.\n\n" + "$ %s\n%s" % (' '.join(cmd_args), err))
def _do_tests(self): print('Running Nose Tests') out, err, res = shell.exec_cmd(['which', 'nosetests']) if self.app.pargs.loud: cmd_args = ['coverage', 'run', out.strip(), '--verbosity=3'] res = shell.exec_cmd2(cmd_args) else: cmd_args = ['coverage', 'run', out.strip(), '--verbosity=0'] out, err, res = shell.exec_cmd(cmd_args) if res > 0: self._do_error("\n\nNose tests did not pass.\n\n" + "$ %s\n%s" % (' '.join(cmd_args), err))
def setUp(self): super(ProjectTest, self).setUp() ## FIX ME: deliver data first - serves as test data self.app = self.make_app(argv = []) self.app.setup() self.fastq_dir = os.path.join(self.app.config.get("project", "root"), "j_doe_00_01", "data", flowcell) safe_makedir(self.fastq_dir) for f in self.COMPRESS_FILES: m = glob.glob("{}*".format(os.path.join(self.fastq_dir, f))) if not m: exit_code = shell.exec_cmd2(['touch', os.path.join(self.fastq_dir, f)]) flist = walk(j_doe_00_04['data']) for f in flist: os.unlink(f)
def setUp(self): super(ProjectTest, self).setUp() ## FIX ME: deliver data first - serves as test data self.app = self.make_app(argv=[]) self.app.setup() self.fastq_dir = os.path.join(self.app.config.get("project", "root"), "j_doe_00_01", "data", flowcell) safe_makedir(self.fastq_dir) for f in self.COMPRESS_FILES: m = glob.glob("{}*".format(os.path.join(self.fastq_dir, f))) if not m: exit_code = shell.exec_cmd2( ['touch', os.path.join(self.fastq_dir, f)]) flist = walk(j_doe_00_04['data']) for f in flist: os.unlink(f)
def execute(self): cmd = ['adb', 'backup'] if self.options.apk: cmd.append('-apk') if self.options.all: cmd.append('-all') if self.options.system: cmd.append('-system') if self.options.obb: cmd.append('-obb') if self.options.shared: cmd.append('-shared') if self.options.filename: cmd.append('-f %s' % self.options.filename) exitcode = shell.exec_cmd2(cmd) self.log.debug('adb backup exit: %d.' % exitcode, __name__) if exitcode == 0: # self.log.info('Done.') # self.log.info('Backup is saved as: %s' % self.options.filename) CoreUtil.hash(self.options.filename) else: self.log.warning('Logical Acquisition module exit unexpectedly: %d.' % exitcode)
def list(self): cmd = ['adb', 'shell', 'pm', 'list', 'packages', '-u', '-f'] shell.exec_cmd2(cmd)
def test_exec_cmd2_bad_command(self): ret = shell.exec_cmd2(['false']) self.eq(ret, 1)
def test_exec_cmd2_shell_true(self): ret = shell.exec_cmd2(['echo johnny'], shell=True) self.eq(ret, 0)
def test_exec_cmd2(self): ret = shell.exec_cmd2(['echo']) self.eq(ret, 0)
def test_exec_cmd2_bad_command(): ret = shell.exec_cmd2(['false']) assert ret == 1
def test_exec_cmd2_shell_true(): ret = shell.exec_cmd2(['echo johnny'], shell=True) assert ret == 0
def test_exec_cmd2(): ret = shell.exec_cmd2(['echo']) assert ret == 0