Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions nipype/pipeline/plugins/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
from time import sleep
import subprocess

from .base import (SGELikeBatchManagerBase, logger, iflogger, logging)

Expand Down Expand Up @@ -35,16 +36,12 @@ def __init__(self, **kwargs):
super(PBSPlugin, self).__init__(template, **kwargs)

def _is_pending(self, taskid):
cmd = CommandLine('qstat')
cmd.inputs.args = '%s' % taskid
# check pbs task
oldlevel = iflogger.level
iflogger.setLevel(logging.getLevelName('CRITICAL'))
result = cmd.run(ignore_exception=True)
iflogger.setLevel(oldlevel)
if 'Unknown Job Id' in result.runtime.stderr:
return False
return True
proc = subprocess.Popen(["qstat", taskid],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
_, e = proc.communicate()
errmsg = 'Unknown Job Id' # %s' % taskid
return errmsg not in e

def _submit_batchtask(self, scriptfile, node):
cmd = CommandLine('qsub', environ=os.environ.data)
Expand Down
18 changes: 7 additions & 11 deletions nipype/pipeline/plugins/sge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"""

import os
import subprocess
from time import sleep

from .base import (SGELikeBatchManagerBase, logger, iflogger, logging)

from nipype.interfaces.base import CommandLine

from time import sleep

class SGEPlugin(SGELikeBatchManagerBase):
"""Execute using SGE (OGE not tested)
Expand Down Expand Up @@ -36,16 +37,11 @@ def __init__(self, **kwargs):
super(SGEPlugin, self).__init__(template, **kwargs)

def _is_pending(self, taskid):
cmd = CommandLine('qstat')
cmd.inputs.args = '-j %d' % taskid
# check sge task
oldlevel = iflogger.level
iflogger.setLevel(logging.getLevelName('CRITICAL'))
result = cmd.run(ignore_exception=True)
iflogger.setLevel(oldlevel)
if result.runtime.stdout.startswith('='):
return True
return False
proc = subprocess.Popen(["qstat", '-j', taskid],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
o, _ = proc.communicate()
return o.startswith('=')

def _submit_batchtask(self, scriptfile, node):
cmd = CommandLine('qsub', environ=os.environ.data)
Expand Down