1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- """RIDE -- Robot Framework test data editor
17-
18- Usage: ride.py [--noupdatecheck] [--debugconsole] [--settingspath <full path|settings filename>] [--version] [inpath]
19-
20- RIDE can be started either without any arguments or by giving a path to a test
21- data file or directory to be opened.
22-
23- To disable update checker use --noupdatecheck.
24-
25- To start debug console for RIDE problem debugging use --debugconsole option.
26-
27- To use different settings use the option --settingspath followed by the path to the settings file or file name.
28-
29- To see RIDE's version use --version.
30-
31- RIDE's API is still evolving while the project is moving towards the 1.0
32- release. The most stable, and best documented, module is `robotide.pluginapi`.
33- """
34-
16+ import argparse
3517import os
3618import sys
37- import wx
38- import wx .lib .inspection
39- from wx import Size
19+
20+ try :
21+ from robotide import version
22+ except ImportError :
23+ print ("Error getting RIDE version!" )
24+ sys .exit (1 )
25+
26+ errorMessage = """wxPython not found.\n
27+ RIDE depends on wx (wxPython). Known versions for Python3 are: 4.0.7.post2, 4.1.1 and 4.2.3.\
28+ At the time of this release the current wxPython version is 4.2.3.\
29+ You can install with 'pip install wxPython' on most operating systems, or find the \
30+ the download link from https://wxPython.org/"""
31+
32+ if __name__ == '__main__' and 'robotide' not in sys .modules :
33+ from pathlib import Path
34+ robotide_dir = Path (__file__ ).absolute ().parent # zipsafe
35+ sys .path = [str (robotide_dir .parent )] + [p for p in sys .path if Path (p ) != robotide_dir ]
36+
37+ parser = argparse .ArgumentParser (prog = 'ride' , description = 'RIDE is an IDE for Robot Framework test cases and tasks.' ,
38+ epilog = 'See information about Robot Framework ecosystem at https://robotframewok.org/' ,
39+ add_help = False )
40+ parser .add_argument ('inpath' , nargs = '?' , help = 'Path to a test data file or'
41+ ' directory to be opened.' )
42+ parser .add_argument ('-n' , '--noupdatecheck' , action = 'store_true' , help = 'To disable update check.' )
43+ parser .add_argument ('-d' , '--debugconsole' , action = 'store_true' ,
44+ help = 'To start debug console for RIDE problem debugging, and wxPython inspection tool.' )
45+ parser .add_argument ('-s' , '--settingspath' , default = None , help = '<full path|settings filename>\n '
46+ 'To use different settings use the option --settingspath followed by'
47+ ' the path to the settings file or file name.' )
48+ parser .add_argument ('-v' , '--version' , action = 'version' , version = f'{ version .VERSION } ' ,
49+ help = 'To see RIDE\' s version.' )
50+ parser .add_argument ('-h' , '--help' , action = 'help' , help = 'RIDE can be started either without any '
51+ 'arguments or by giving a path to a test data file or'
52+ ' directory to be opened.' )
53+ # arguments = parser.parse_args()
54+
55+ try :
56+ import wx
57+ import wx .lib .inspection
58+ from wx import Colour , Size
59+ except ModuleNotFoundError :
60+ print (errorMessage )
61+ sys .exit (1 )
4062
4163# Insert bundled robot to path before anything else
4264sys .path .append (os .path .join (os .path .dirname (__file__ ), 'spec' ))
4365sys .path .append (os .path .join (os .path .dirname (__file__ ), 'lib' ))
4466
45- def main ():
46- arguments = tuple (_parse_args (tuple (sys .argv [1 :])))
47- mainrun (arguments )
4867
49- def mainrun ( args ):
68+ def main ( * args ):
5069 _replace_std_for_win ()
51- noupdatecheck = args [0 ]
52- debugconsole = args [1 ]
53- settingspath = args [2 ]
54- inpath = args [3 ]
55- print (f"DEBUG: main.py { noupdatecheck = } { debugconsole = } { settingspath = } { inpath = } " )
70+ arguments = parser .parse_args ()
71+ noupdatecheck = arguments .noupdatecheck
72+ debugconsole = arguments .debugconsole
73+ settingspath = arguments .settingspath
74+ inpath = arguments .inpath # _parse_args(*args)
75+ # print(f"DEBUG: main.py {noupdatecheck=} {debugconsole=} {settingspath=} {inpath=}")
5676 try :
5777 _run (inpath , not noupdatecheck , debugconsole , settingspath = settingspath )
5878 except Exception : # DEBUG
@@ -61,29 +81,6 @@ def mainrun(args):
6181 sys .stderr .write ('\n \n Use --help to get usage information.\n ' )
6282
6383
64- def _parse_args (args ):
65- if not args :
66- return False , False , None , None
67- arguments = list (args )
68- if '-a' in arguments :
69- arguments .remove ('-a' )
70- noupdatecheck = '--noupdatecheck' in arguments
71- if noupdatecheck :
72- arguments .remove ('--noupdatecheck' )
73- debug_console = '--debugconsole' in arguments
74- if debug_console :
75- arguments .remove ('--debugconsole' )
76- settings_path = None
77- if '--settingspath' in arguments :
78- arguments .remove ('--settingspath' )
79- if len (arguments ) > 0 :
80- settings_path = arguments .pop (0 )
81- else :
82- settings_path = None
83- inpath = arguments [0 ] if arguments else None
84- return noupdatecheck , debug_console , settings_path , inpath
85-
86-
8784def _run (inpath = None , updatecheck = True , debug_console = False , settingspath = None ):
8885 # print(f"DEBUG: ENTER _run {inpath=}, {updatecheck=}, {debug_console=}")
8986 try :
@@ -151,5 +148,4 @@ def _show_old_wxpython_warning_if_needed(parent=None):
151148
152149
153150if __name__ == '__main__' :
154- args = tuple (_parse_args (tuple (sys .argv [1 :])))
155- mainrun (args )
151+ main (* sys .argv [1 :])
0 commit comments