|
2 | 2 | """
|
3 | 3 |
|
4 | 4 | import os
|
| 5 | +import subprocess |
| 6 | +from time import sleep |
5 | 7 |
|
6 | 8 | from .base import (SGELikeBatchManagerBase, logger, iflogger, logging)
|
7 | 9 |
|
8 | 10 | from nipype.interfaces.base import CommandLine
|
9 | 11 |
|
10 |
| -from time import sleep |
11 | 12 |
|
12 | 13 | class SGEPlugin(SGELikeBatchManagerBase):
|
13 | 14 | """Execute using SGE (OGE not tested)
|
@@ -36,16 +37,11 @@ def __init__(self, **kwargs):
|
36 | 37 | super(SGEPlugin, self).__init__(template, **kwargs)
|
37 | 38 |
|
38 | 39 | def _is_pending(self, taskid):
|
39 |
| - cmd = CommandLine('qstat') |
40 |
| - cmd.inputs.args = '-j %d' % taskid |
41 |
| - # check sge task |
42 |
| - oldlevel = iflogger.level |
43 |
| - iflogger.setLevel(logging.getLevelName('CRITICAL')) |
44 |
| - result = cmd.run(ignore_exception=True) |
45 |
| - iflogger.setLevel(oldlevel) |
46 |
| - if result.runtime.stdout.startswith('='): |
47 |
| - return True |
48 |
| - return False |
| 40 | + proc = subprocess.Popen(["qstat", '-j', taskid], |
| 41 | + stdout=subprocess.PIPE, |
| 42 | + stderr=subprocess.PIPE) |
| 43 | + o, _ = proc.communicate() |
| 44 | + return o.startswith('=') |
49 | 45 |
|
50 | 46 | def _submit_batchtask(self, scriptfile, node):
|
51 | 47 | cmd = CommandLine('qsub', environ=os.environ.data)
|
|
0 commit comments