Fix use of daemon library in Version >= 1.6

For some reason they decided to rename the pidlockfile
file to pidfile.

Fixes: #6
This commit is contained in:
Stefan Hacker
2016-05-02 21:35:14 +02:00
parent 557a4951b1
commit dd19472b8c

View File

@ -533,7 +533,10 @@ if __name__ == '__main__':
if option.force_app:
raise ImportError # Pretend that we couldn't import the daemon lib
import daemon
import daemon.pidlockfile
try:
from daemon.pidfile import TimeoutPIDLockFile
except ImportError: # Version < 1.6
from daemon.pidlockfile import TimeoutPIDLockFile
except ImportError:
if option.force_daemon:
print >> sys.stderr, 'Fatal error, could not daemonize process due to missing "daemon" library, ' \
@ -541,7 +544,7 @@ if __name__ == '__main__':
sys.exit(1)
ret = do_main_program()
else:
pidfile = daemon.pidlockfile.TimeoutPIDLockFile(cfg.system.pidfile, 5)
pidfile = TimeoutPIDLockFile(cfg.system.pidfile, 5)
if pidfile.is_locked():
try:
os.kill(pidfile.read_pid(), 0)