コード例 #1
0
    def run(self, args):
        """Run 'create' subcommand."""
        optparser = CreateOptions(go_args=args,
                                  envvar_prefix=self.envvar_prefix,
                                  usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
        except StandardError as err:
            self._log_and_raise(err)

        return 0
コード例 #2
0
ファイル: create.py プロジェクト: boegel/hanythingondemand
    def run(self, args):
        """Run 'create' subcommand."""
        optparser = CreateOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
        except StandardError as err:
            self._log_and_raise(err)

        return 0
コード例 #3
0
ファイル: create.py プロジェクト: ehiggs/hanythingondemand
    def run(self, args):
        """Run 'create' subcommand."""
        optparser = CreateOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
            return 0
        except StandardError as e:
            fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
            fancylogger.logToScreen(enable=True)
            _log.raiseException(e.message)
コード例 #4
0
 def test_validate_label(self):
     self.assertTrue(hc.validate_label('my-batch-job', ['your-batch-job']))
     self.assertFalse(hc.validate_label('my-batch-job', ['my-batch-job']))
     self.assertTrue(hc.validate_label('my-batch-job', []))
     self.assertFalse(hc.validate_label('my/batch-job', ['my-batch-job']))
     self.assertFalse(hc.validate_label('my/batch-job', ['your-batch-job', 'my-batch-job']))
     self.assertFalse(hc.validate_label('/mybatch-job', ['mybatch-job']))
     self.assertFalse(hc.validate_label('/mybatch-job', ['/mybatch-job']))
コード例 #5
0
 def test_validate_label(self):
     self.assertTrue(hc.validate_label('my-batch-job', ['your-batch-job']))
     self.assertFalse(hc.validate_label('my-batch-job', ['my-batch-job']))
     self.assertTrue(hc.validate_label('my-batch-job', []))
     self.assertFalse(hc.validate_label('my/batch-job', ['my-batch-job']))
     self.assertFalse(hc.validate_label('my/batch-job', ['your-batch-job', 'my-batch-job']))
     self.assertFalse(hc.validate_label('/mybatch-job', ['mybatch-job']))
     self.assertFalse(hc.validate_label('/mybatch-job', ['/mybatch-job']))
コード例 #6
0
    def run(self, args):
        """Run 'batch' subcommand."""
        optparser = BatchOptions(go_args=args,
                                 envvar_prefix=self.envvar_prefix,
                                 usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        if optparser.options.script is None:
            sys.stderr.write('Missing script. Exiting.\n')
            return 1

        # resolve script path to absolute path
        optparser.options.script = os.path.abspath(optparser.options.script)

        if not os.path.exists(optparser.options.script):
            sys.stderr.write(
                "Specified script does not exist: %s. Exiting.\n" %
                optparser.options.script)
            return 1

        # make sure script is executable
        cur_perms = os.stat(optparser.options.script)[stat.ST_MODE]
        if not (cur_perms & stat.S_IXUSR):
            print "Specified script %s is not executable yet, fixing that..." % optparser.options.script
            os.chmod(optparser.options.script, cur_perms | stat.S_IXUSR)

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
        except StandardError as err:
            self._log_and_raise(err)

        return 0
コード例 #7
0
ファイル: batch.py プロジェクト: ehiggs/hanythingondemand
    def run(self, args):
        """Run 'batch' subcommand."""
        optparser = BatchOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        if optparser.options.script is None:
            sys.stderr.write('Missing script. Exiting.\n')
            return 1

        # resolve script path to absolute path
        optparser.options.script = os.path.abspath(optparser.options.script)

        if not os.path.exists(optparser.options.script):
            sys.stderr.write("Specified script does not exist: %s. Exiting.\n" % optparser.options.script)
            return 1

        # make sure script is executable
        cur_perms = os.stat(optparser.options.script)[stat.ST_MODE]
        if not (cur_perms & stat.S_IXUSR):
            print "Specified script %s is not executable yet, fixing that..." % optparser.options.script
            os.chmod(optparser.options.script, cur_perms|stat.S_IXUSR)

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
            return 0
        except StandardError as e:
            fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
            fancylogger.logToScreen(enable=True)
            _log.raiseException(e.message)