File: bootstrap.py

package info (click to toggle)
python-pyqtgraph 0.9.8-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,552 kB
  • ctags: 4,262
  • sloc: python: 30,181; makefile: 116; sh: 1
file content (28 lines) | stat: -rw-r--r-- 1,162 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""For starting up remote processes"""
import sys, pickle, os

if __name__ == '__main__':
    if hasattr(os, 'setpgrp'):
        os.setpgrp()  ## prevents signals (notably keyboard interrupt) being forwarded from parent to this process
    if sys.version[0] == '3':
        #name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin.buffer)
        opts = pickle.load(sys.stdin.buffer)
    else:
        #name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin)
        opts = pickle.load(sys.stdin)
    #print "key:",  ' '.join([str(ord(x)) for x in authkey])
    path = opts.pop('path', None)
    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)
        
    if opts.pop('pyside', False):
        import PySide
        
    
    targetStr = opts.pop('targetStr')
    target = pickle.loads(targetStr)  ## unpickling the target should import everything we need
    target(**opts)  ## Send all other options to the target function
    sys.exit(0)