Hi Tibor,
I've updated my portable patch implementation I posted some months ago
to the users list.
Ferran
A more portable implementation that should work on Linux, Solaris and
Digital Unix. Not tested on FreeBSD.
It should also be faster than CDS Invenio 0.92.0, implementation, because
it calls only one external command (ps), and not 3 (ps, grep --twice-- and
sed).
---
modules/bibsched/lib/bibsched.py | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
Index: cds-invenio/modules/bibsched/lib/bibsched.py
===================================================================
--- cds-invenio.orig/modules/bibsched/lib/bibsched.py 2007-03-01 15:41:38.000000000 +0100
+++ cds-invenio/modules/bibsched/lib/bibsched.py 2007-04-11 14:26:46.301060324 +0200
@@ -44,6 +44,7 @@
import curses.panel
from curses.wrapper import wrapper
import signal
+import pwd
from invenio.config import \
CFG_PREFIX, \
@@ -75,16 +76,14 @@
return None
def get_my_pid(process, args=''):
- if sys.platform.startswith('freebsd'):
- COMMAND = "ps -o pid,args | grep '%s %s' | grep -v 'grep' | sed -n 1p" % (process, args)
- else:
- COMMAND = "ps -C %s o '%%p%%a' | grep '%s %s' | grep -v 'grep' | sed -n 1p" % (process, process, args)
- answer = string.strip(os.popen(COMMAND).read())
- if answer == '':
- answer = 0
- else:
- answer = answer[:string.find(answer,' ')]
- return int(answer)
+ COMMAND = "ps -fu %s" % (pwd.getpwuid(os.getuid())[0])
+ pslist = os.popen(COMMAND).readlines()
+ str = string.join([process,args])
+ answer = 0
+ for ps in pslist:
+ if ps.find(str) > 0:
+ answer = int(ps.split()[1])
+ return answer
def get_output_channelnames(task_id):
"Construct and return filename for stdout and stderr for the task 'task_id'."