File: python_execfile.py

package info (click to toggle)
xpra 3.1.5%2Bdfsg1-0.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,692 kB
  • sloc: python: 117,045; javascript: 94,780; ansic: 2,843; sh: 939; cpp: 268; makefile: 212; xml: 89
file content (27 lines) | stat: -rwxr-xr-x 627 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/env python

# simple wrapper script so we can launch a script file with the same python interpreter
# and environment which is used by the xpra.exe / xpra_cmd.exe process.
#
import os.path
import sys
from xpra.platform import init, clean
init("Xpra-Python-Exec")

def ret(v):
    clean()
    sys.exit(v)

if len(sys.argv)<2:
    print("you must specify a python script file to run!")
    ret(1)
filename = sys.argv[1]
if not os.path.exists(filename):
    print("script file '%s' not found" % filename)
    ret(1)

cwd = os.getcwd()
if cwd not in sys.path:
    sys.path.append(cwd)
exec(open(filename).read())
ret(0)