Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb6efd7

Browse files
committed
fix removing threading
1 parent 65bddb3 commit cb6efd7

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

bin/python.py

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,35 @@
33
44
Used for running standard library python modules such as:
55
SimpleHTTPServer, unittest and .py files.
6-
-b will run the module/file in the background
76
7+
Can also be used to run a script in the background, such as a server, with the bash character & at the end.
88
usage:
9-
python -m [-b] module_name [args]
10-
python [-b] python_file.py [args]
9+
python -m module_name [args]
10+
python python_file.py [args]
1111
'''
1212

1313
import runpy
1414
import sys
15-
import threading
1615
import ui
17-
import argparse
18-
19-
20-
class ModuleThread(threading.Thread):
21-
22-
def __init__(self,module,name):
23-
self.is_module = module
24-
self.module_name = name
25-
threading.Thread.__init__(self)
26-
@ui.in_background
27-
def run(self):
28-
try:
29-
if self.is_module:
30-
31-
runpy.run_module(self.module_name, run_name='__main__')
32-
else:
33-
runpy.run_path(self.module_name, run_name='__main__')
34-
except Exception, e:
35-
print e
36-
16+
import argparse
3717

3818
ap = argparse.ArgumentParser()
3919
ap.add_argument('-m', '--module', action='store_true', default=False, help='run module')
40-
ap.add_argument('-b', '--background', action='store_true', default=False, help='run as background thread')
4120
ap.add_argument('name', help='file or module name')
4221
ap.add_argument('args_to_pass', nargs=argparse.REMAINDER, help='args to pass')
4322
args = ap.parse_args()
4423

45-
run_as_thread = args.background
46-
run_as_module = args.module
4724
module_name = str(args.name)
4825

4926
sys.argv = [sys.argv[0]] + args.args_to_pass
5027

51-
if run_as_module:
28+
if args.module:
5229
try:
53-
#os.chdir('../..')
54-
if run_as_thread:
55-
ModuleThread(True,module_name).start()
56-
else:
57-
runpy.run_module(module_name, run_name='__main__')
30+
runpy.run_module(module_name, run_name='__main__')
5831
except ImportError, e:
5932
print 'ImportError: '+str(e)
6033
else:
6134
try:
62-
if run_as_thread:
63-
ModuleThread(False,module_name).start()
64-
else:
65-
runpy.run_path(module_name, run_name='__main__')
35+
runpy.run_path(module_name, run_name='__main__')
6636
except Exception, e:
6737
print 'Error: '+ str(e)

0 commit comments

Comments
 (0)