-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-display.py
executable file
·40 lines (35 loc) · 1.17 KB
/
export-display.py
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
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
'''
usage :
'''
import optparse
import subprocess
import re
import os
import sys
from optparse import OptionParser
from execBash import execBash
#----------------- global variable ----------------#
#----------------- parseCmd() ----------------#
## parse the command line arguments
def parseCmd():
usage = "usage: %prog [options] <startBranch>..<endBranch> <branch1> <branch2> [<branch3>]"
parser = OptionParser(usage) #when --help is used or when wrong opt
parser.add_option("-l", "--list-file",
action="store_true", dest="list_file",
help="list all changed files") # set options.verbose=True
#parse_args(arg) arg (default) = sys.argv[1:]
return parser.parse_args() #options.filename, options.verbose..
#----------------- main() ----------------#
def main():
(options, args) = parseCmd()
for i in range(50):
if execBash('export DISPLAY=localhost:%d && xclock'% (i,))[1] ==0:
#if execBash('xclock')[1]==0:
print("export DISPLAY=localhost:%d" % i)
execBash ('export DISPLAY=localhost:%d' % i)
sys.exit(0)
#----------------- standalone() ----------------#
## if standalone, i.e. called directly from shell
if __name__ == '__main__':
main()