33 @author xingyujie https://github.com/xingyujie
44 @abstract BINPython main file
55"""
6+
67#BINPython By:XINGYUJIE AGPL-V3.0 LICENSE Release
78#Please follow the LICENSE AGPL-V3
89#full version
910####################################
1011#build configure
1112
12- ver = "0.29 -dev-full"
13+ ver = "0.30 -dev-full"
1314
1415libs_warning = "1"
1516#1 is ture 0 is false.
@@ -62,13 +63,21 @@ def self_import(name):
6263 if libs_warning == "1" :
6364 print ("Warning: Custom import library %s does not exist, please check the source code library configuration and rebuild" % importlibs )
6465 print ("" )
66+ def optreadfile ():
67+ import sys
68+ getfile = sys .argv [1 ]
69+ getfilecode = open (getfile ,encoding = "utf-8" )
70+ exec (getfilecode .read ())
71+ input ("Run finished. Enter to Shell." )
72+ sys .exit (0 )
6573try :
6674#base import
6775 import getopt
6876 import sys
6977 import platform
7078 import os
7179 import timeit
80+ import pdb
7281#fix for exit()
7382 from sys import exit
7483#import for http_server
@@ -158,20 +167,27 @@ def binpython_shell():
158167 else :
159168 exec (pycmd )
160169 except KeyboardInterrupt :
161- print ("EXIT! " )
170+ print ("KeyboardInterrupt " )
162171 sys .exit ()
163172 except Exception as err :
164173 print (err )
174+ try :
175+ optreadfile ()
176+ except :
177+ pass
178+
179+
180+
165181
166182
167183#def
168184helpinfobase = """
169185Usage: binpython [OPTIONS]
170186
171187Options:
172-
188+ <filename> Enter Python Filename and run (*.py)
189+ -f --file Enter Python Filename and run (*.py), But this options is no Run finished prompt
173190-h --help View this help
174- -f <filename> --file=<filename> Enter Python Filename and run (*.py)
175191-s <port> --server=<port> Start a simple web server that supports html and file transfer (http.server)
176192-v --version View BINPython Version
177193-g --gui View GUI About and build info
@@ -181,24 +197,27 @@ def binpython_shell():
181197-p --plus Open BINPython IDE Plus Code Editor(beta) with http web server
182198-e --example Run various code examples through BINPython
183199"""
200+ def outputfullhelp ():
201+ try :
202+ f = open ("binpython_config/help.txt" ,encoding = "utf-8" )
203+ print (f .read ())
204+ except :
205+ print (helpinfobase )
206+ if buildversion == "plus" :
207+ print ("Additional options for the plus version" )
208+ print (helpinfoplus )
184209about = "BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release"
185210#getopt
186211try :
187212 opts ,args = getopt .getopt (sys .argv [1 :],'-h-f:-s:-g-i-p-e-v' ,['help' ,'file=' ,'server=' ,'gui' ,'idle' ,'plus' ,'example' ,'version' ])
188- except :
213+ except getopt . GetoptError as err :
189214 print ("Please check help:" )
190- help ()
191- print ("The parameters you use do not exist or are not entered completely, please check help! ! ! ! !" )
215+ print ("The parameters you use do not exist or are not entered completely, please check help!!!!" )
216+ outputfullhelp ()
217+ sys .exit ()
192218for opt_name ,opt_value in opts :
193219 if opt_name in ('-h' ,'--help' ):
194- try :
195- f = open ("binpython_config/help.txt" ,encoding = "utf-8" )
196- print (f .read ())
197- except :
198- print (helpinfobase )
199- if buildversion == "plus" :
200- print ("Additional options for the plus version" )
201- print (helpinfoplus )
220+ outputfullhelp ()
202221 sys .exit ()
203222 if opt_name in ('-v' ,'--version' ):
204223 try :
@@ -213,7 +232,6 @@ def binpython_shell():
213232 file = opt_value
214233 f = open (file ,encoding = "utf-8" )
215234 exec (f .read ())
216- input ("Please enter to continue" )
217235 sys .exit ()
218236 if opt_name in ('-s' ,'--server' ):
219237 server_port = opt_value
0 commit comments