projects
/
dbuscron
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
007864e
)
dbuscrontab: get daemon's pid from pidfile if upstart failed
author
Konstantin Stepanov
<kstep@p-nut.info>
Wed, 22 Dec 2010 12:28:51 +0000
(14:28 +0200)
committer
Konstantin Stepanov
<kstep@p-nut.info>
Wed, 22 Dec 2010 12:28:51 +0000
(14:28 +0200)
dbuscron/shell/edit.py
patch
|
blob
|
history
diff --git
a/dbuscron/shell/edit.py
b/dbuscron/shell/edit.py
index
810b7dc
..
607619f
100644
(file)
--- a/
dbuscron/shell/edit.py
+++ b/
dbuscron/shell/edit.py
@@
-18,14
+18,26
@@
def run_system_editor(filename):
if os.system(editor + ' ' + pipes.quote(filename)) != 0:
raise SystemError('Editor returned non-zero status value.')
if os.system(editor + ' ' + pipes.quote(filename)) != 0:
raise SystemError('Editor returned non-zero status value.')
+def get_dbuscron_pid_from_upstart():
+ f = os.popen('initctl status dbuscron', 'r')
+ status = f.readline()
+ f.close()
+ return int(status.strip().split(' ').pop())
+
+def get_dbuscron_pid_from_pidfile():
+ f = open(pidfile, 'r')
+ pid = f.readline()
+ f.close()
+ return int(pid)
+
def get_dbuscron_pid():
try:
def get_dbuscron_pid():
try:
- f = os.popen('initctl status dbuscron', 'r')
- status = f.readline()
- f.close()
- return int(status.strip().split(' ').pop())
+ return get_dbuscron_pid_from_upstart()
except:
except:
- raise SystemError('Unable to get PID of dbuscron job.')
+ try:
+ return get_dbuscron_pid_from_pidfile()
+ except:
+ raise SystemError('Unable to get PID of dbuscron job.')
def check_syntax(filename):
parser = CrontabParser(filename)
def check_syntax(filename):
parser = CrontabParser(filename)