Beispiel #1
0
 def write_batch_script(self, n):
     """Instantiate and write the batch script to the work_dir."""
     self.context['n'] = n
     self.context['queue'] = self.queue
     print self.context
     # first priority is batch_template if set
     if self.batch_template_file and not self.batch_template:
         # second priority is batch_template_file
         with open(self.batch_template_file) as f:
             self.batch_template = f.read()
     if not self.batch_template:
         # third (last) priority is default_template
         self.batch_template = self.default_template
     
     regex = re.compile(self.job_array_regexp)
     # print regex.search(self.batch_template)
     if not regex.search(self.batch_template):
         self.log.info("adding job array settings to batch script")
         firstline, rest = self.batch_template.split('\n',1)
         self.batch_template = u'\n'.join([firstline, self.job_array_template, rest])
     
     regex = re.compile(self.queue_regexp)
     # print regex.search(self.batch_template)
     if self.queue and not regex.search(self.batch_template):
         self.log.info("adding PBS queue settings to batch script")
         firstline, rest = self.batch_template.split('\n',1)
         self.batch_template = u'\n'.join([firstline, self.queue_template, rest])
         
     script_as_string = Itpl.itplns(self.batch_template, self.context)
     self.log.info('Writing instantiated batch script: %s' % self.batch_file)
 
     with open(self.batch_file, 'w') as f:
         f.write(script_as_string)
     os.chmod(self.batch_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
Beispiel #2
0
 def write_batch_script(self, n):
     """Instantiate and write the batch script to the work_dir."""
     self.context['n'] = n
     script_as_string = Itpl.itplns(self.batch_template, self.context)
     log.msg('Writing instantiated batch script: %s' % self.batch_file)
     f = open(self.batch_file, 'w')
     f.write(script_as_string)
     f.close()
Beispiel #3
0
 def write_batch_script(self, n):
     """Instantiate and write the batch script to the work_dir."""
     self.context['n'] = n
     script_as_string = Itpl.itplns(self.batch_template, self.context)
     log.msg('Writing instantiated batch script: %s' % self.batch_file)
     f = open(self.batch_file, 'w')
     f.write(script_as_string)
     f.close()
Beispiel #4
0
 def write_batch_script(self, n):
     self.context['n'] = n
     template = open(self.template_file, 'r').read()
     log.msg('Using template for batch script: %s' % self.template_file)
     script_as_string = Itpl.itplns(template, self.context)
     log.msg('Writing instantiated batch script: %s' % self.batch_file)
     f = open(self.batch_file,'w')
     f.write(script_as_string)
     f.close()
Beispiel #5
0
 def write_batch_script(self, n):
     self.context['n'] = n
     template = open(self.template_file, 'r').read()
     log.msg('Using template for batch script: %s' % self.template_file)
     script_as_string = Itpl.itplns(template, self.context)
     log.msg('Writing instantiated batch script: %s' % self.batch_file)
     f = open(self.batch_file, 'w')
     f.write(script_as_string)
     f.close()
Beispiel #6
0
    def write_batch_script(self, n):
        """Instantiate and write the batch script to the work_dir."""
        self.context['n'] = n
        self.context['queue'] = self.queue
        print self.context
        # first priority is batch_template if set
        if self.batch_template_file and not self.batch_template:
            # second priority is batch_template_file
            with open(self.batch_template_file) as f:
                self.batch_template = f.read()
        if not self.batch_template:
            # third (last) priority is default_template
            self.batch_template = self.default_template

        regex = re.compile(self.job_array_regexp)
        # print regex.search(self.batch_template)
        if not regex.search(self.batch_template):
            self.log.info("adding job array settings to batch script")
            firstline, rest = self.batch_template.split('\n', 1)
            self.batch_template = u'\n'.join(
                [firstline, self.job_array_template, rest])

        regex = re.compile(self.queue_regexp)
        # print regex.search(self.batch_template)
        if self.queue and not regex.search(self.batch_template):
            self.log.info("adding PBS queue settings to batch script")
            firstline, rest = self.batch_template.split('\n', 1)
            self.batch_template = u'\n'.join(
                [firstline, self.queue_template, rest])

        script_as_string = Itpl.itplns(self.batch_template, self.context)
        self.log.info('Writing instantiated batch script: %s' %
                      self.batch_file)

        with open(self.batch_file, 'w') as f:
            f.write(script_as_string)
        os.chmod(self.batch_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)