2012-06-22 02:00:04 +00:00
|
|
|
"""For starting up remote processes"""
|
2012-08-17 20:15:13 +00:00
|
|
|
import sys, pickle, os
|
2012-06-22 02:00:04 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-01-12 19:31:49 +00:00
|
|
|
if hasattr(os, 'setpgrp'):
|
|
|
|
os.setpgrp() ## prevents signals (notably keyboard interrupt) being forwarded from parent to this process
|
2013-01-12 23:07:35 +00:00
|
|
|
if sys.version[0] == '3':
|
2013-02-13 16:43:22 +00:00
|
|
|
#name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin.buffer)
|
|
|
|
opts = pickle.load(sys.stdin.buffer)
|
2013-01-12 23:07:35 +00:00
|
|
|
else:
|
2013-02-13 16:43:22 +00:00
|
|
|
#name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin)
|
|
|
|
opts = pickle.load(sys.stdin)
|
2013-01-12 19:31:49 +00:00
|
|
|
#print "key:", ' '.join([str(ord(x)) for x in authkey])
|
2013-02-13 16:43:22 +00:00
|
|
|
path = opts.pop('path', None)
|
2012-06-22 02:00:04 +00:00
|
|
|
if path is not None:
|
|
|
|
## rewrite sys.path without assigning a new object--no idea who already has a reference to the existing list.
|
|
|
|
while len(sys.path) > 0:
|
|
|
|
sys.path.pop()
|
|
|
|
sys.path.extend(path)
|
2013-01-12 23:07:35 +00:00
|
|
|
|
2013-02-13 16:43:22 +00:00
|
|
|
if opts.pop('pyside', False):
|
2013-01-12 23:07:35 +00:00
|
|
|
import PySide
|
2013-11-18 03:32:15 +00:00
|
|
|
|
2013-11-07 04:14:27 +00:00
|
|
|
|
2013-02-13 16:43:22 +00:00
|
|
|
targetStr = opts.pop('targetStr')
|
2012-06-22 02:00:04 +00:00
|
|
|
target = pickle.loads(targetStr) ## unpickling the target should import everything we need
|
2013-02-13 16:43:22 +00:00
|
|
|
target(**opts) ## Send all other options to the target function
|
2012-06-22 02:00:04 +00:00
|
|
|
sys.exit(0)
|