X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=dbuscron%2Fshell%2Fedit.py;h=607619f5df2d5f9ef47c98c51c08a7d426443d9e;hb=6b8747d2314f8654c5729509ecab9285cb530ec4;hp=810b7dc693d70f5c58aba8afa026574131c1105a;hpb=007864ea0f8962407c77e087238634391cd5749b;p=dbuscron diff --git a/dbuscron/shell/edit.py b/dbuscron/shell/edit.py index 810b7dc..607619f 100644 --- 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.') +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: - 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: - 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)