mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-22 20:44:55 +00:00
py-i2phosts-checker: add run_prog()
Needed for run other tools in common way.
This commit is contained in:
parent
94f885a7b8
commit
be103aeb7a
@ -3,12 +3,14 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pwd
|
import pwd
|
||||||
|
import errno
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
import base64
|
import base64
|
||||||
import configobj
|
import configobj
|
||||||
|
import subprocess
|
||||||
import daemon
|
import daemon
|
||||||
import daemon.pidlockfile
|
import daemon.pidlockfile
|
||||||
|
|
||||||
@ -48,6 +50,20 @@ def check():
|
|||||||
S.close()
|
S.close()
|
||||||
log.info('check finished')
|
log.info('check finished')
|
||||||
|
|
||||||
|
def run_prog(prog):
|
||||||
|
try:
|
||||||
|
log.info('launching %s (see his log for details)', prog)
|
||||||
|
p = subprocess.Popen([prog], shell=False, stdin=None,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
except OSError, e:
|
||||||
|
log.error('failed to exec %s: %s', prog, e)
|
||||||
|
if e.errno == errno.ENOENT:
|
||||||
|
log.error('maybe it isn\'t in PATH')
|
||||||
|
else:
|
||||||
|
out = p.communicate()[0]
|
||||||
|
if out:
|
||||||
|
log.info('got output from %s: %s', prog, out)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
while True:
|
while True:
|
||||||
check()
|
check()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user