コード例 #1
0
    def write_script(self, fname=''):
        """write processing script to a file (in the proc_dir)
         - if fname is set, use it, else generate
         - set rvars.file_proc and output_proc
      """

        if not self.script:
            print('** no script to write out')
            return 1
        if fname: name = fname
        else: name = 'script.ttest'

        # store (intended) names for calling tool to execute with
        self.rvars.file_proc = name  # store which file we have written to
        self.rvars.output_proc = 'output.%s' % name  # file for command output

        if self.cvars.verb > 0: print('++ writing script to %s' % name)

        # if requested, make an original copy
        self.LV.retdir = SUBJ.goto_proc_dir(self.cvars.proc_dir)

        if self.cvars.copy_scripts == 'yes':  # make an orig copy
            UTIL.write_text_to_file('.orig.%s' % name, self.script, exe=1)
        rv = UTIL.write_text_to_file(name, self.script, exe=1)

        self.LV.retdir = SUBJ.ret_from_proc_dir(self.LV.retdir)

        return rv
コード例 #2
0
    def nuke_old_results(self):
        """if the results directory exists, remove it"""

        if self.cvars.results_dir == '': return

        # ------------------------- do the work -------------------------
        self.LV.retdir = SUBJ.goto_proc_dir(self.cvars.proc_dir)

        if os.path.isdir(self.cvars.results_dir):
            print('-- nuking old results: %s' % self.cvars.results_dir)
            os.system('rm -fr %s' % self.cvars.results_dir)

        self.LV.retdir = SUBJ.ret_from_proc_dir(self.LV.retdir)
コード例 #3
0
    def copy_orig_proc(self):
        """if the proc script exists, copy to .orig.SCRIPTNAME"""
        if self.rvars.file_proc == '': return
        pfile = self.rvars.file_proc

        # ------------------------- do the work -------------------------
        self.LV.retdir = SUBJ.goto_proc_dir(self.cvars.proc_dir)
        if os.path.isfile(pfile):
            cmd = 'cp -f %s .orig.%s' % (pfile, pfile)
            if self.cvars.verb > 1: print('++ exec: %s' % cmd)
            os.system(cmd)
        elif self.cvars.verb > 1:
            print("** no proc '%s' to copy" % pfile)
        self.LV.retdir = SUBJ.ret_from_proc_dir(self.LV.retdir)