Browse Source

py-i2phosts-checker: add run_prog()

Needed for run other tools in common way.
pull/1/head
Hidden Z 14 years ago
parent
commit
be103aeb7a
  1. 16
      py-i2phosts-checker

16
py-i2phosts-checker

@ -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…
Cancel
Save