From 77490bd881ca17c60d3eff545c9add1acdeb3002 Mon Sep 17 00:00:00 2001 From: Patrick Ulbrich Date: Sat, 27 Jul 2013 14:39:01 +0200 Subject: [PATCH] added start_subprocess() function --- Mailnag/common/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Mailnag/common/utils.py b/Mailnag/common/utils.py index ad6ffa2..fa7fb0e 100644 --- a/Mailnag/common/utils.py +++ b/Mailnag/common/utils.py @@ -28,6 +28,8 @@ import sys import time import dbus import urllib2 +import subprocess +import threading from common.dist_cfg import PACKAGE_NAME, DBUS_BUS_NAME, DBUS_OBJ_PATH @@ -84,3 +86,14 @@ def shutdown_existing_instance(): sys.stdout.write('OK\n') except: sys.stdout.write('FAILED\n') + + +def start_subprocess(args, callback = None): + def thread(): + p = subprocess.Popen(args) + retcode = p.wait() + if callback != None: + callback(retcode) + + t = threading.Thread(target = thread) + t.start()