diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-11 14:51:07 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-11 14:51:07 -0400 |
commit | 58e8e944052b67c6b5dd2a4ff51c82fb157cf4a6 (patch) | |
tree | 9a55518104edb3cafd012d184b7a6f98ebe1b2de | |
parent | f0aab2aea0e8006cb9693f370e7ee0a63a78b787 (diff) | |
download | htc_utils-58e8e944052b67c6b5dd2a4ff51c82fb157cf4a6.tar.gz |
Fix self.environ calls. Account for CONDOR_CONFIG if undefined.
-rw-r--r-- | htc_utils/bindings/submit.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/htc_utils/bindings/submit.py b/htc_utils/bindings/submit.py index fba59a5..7c82678 100644 --- a/htc_utils/bindings/submit.py +++ b/htc_utils/bindings/submit.py @@ -21,11 +21,21 @@ from . import htcondor_path class Submit(object): def __init__(self, job, **kwargs): + self._htcondor_path = None + if 'install_prefix' in kwargs: + self._htcondor_path = htcondor_path(kwargs['install_prefix']) + else: + self._htcondor_path = htcondor_path() + self.job = job - self.cluster = None + self.cluster = [] self.environ = os.environ - self._prefix = ':'.join([os.environ['PATH'], htcondor_path()]) + self._prefix = ':'.join([self.environ['PATH'], self._htcondor_path]) self.environ['PATH'] = self._prefix + + if 'CONDOR_CONFIG' not in self.environ: + self.environ['CONDOR_CONFIG'] = os.path.abspath(self._htcondor_path.split(':')[0] + '/../etc/condor_config') + self.cli_args = [] print("Received job: {}".format(self.job.filename)) @@ -63,14 +73,14 @@ class Submit(object): if 'cluster' in stdout: for line in stdout.split(os.linesep): if 'cluster' in line: - self.cluster = line.split()[-1].strip('.') + self.cluster.append(line.split()[-1].strip('.')) def monitor(self): - if self.cluster is None: + if not self.cluster: print('No cluster data for job.') return False print('Monitoring cluster {}'.format(self.cluster)) - os.environ['PATH'] = self._prefix + self.environ['PATH'] = self._prefix ''' proc = subprocess.Popen('condor_q -analyze:summary'.split(), env=self.environ) proc.communicate() |