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 @@ @@ -3,12 +3,14 @@
import os
import sys
import pwd
import errno
import argparse
import datetime
import time
import hashlib
import base64
import configobj
import subprocess
import daemon
import daemon.pidlockfile
@ -48,6 +50,20 @@ def check(): @@ -48,6 +50,20 @@ def check():
S.close()
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():
while True:
check()

Loading…
Cancel
Save