Robot Framework Integrated Development Environment (RIDE)
__init__.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 
32 
33 import os
34 import sys
35 from string import Template
36 
37 errorMessageTemplate = Template("""$reason
38 RIDE depends on wx (wxPython). Historically, the last supported version was 2.8.12.1 with unicode support.\
39 At the time of this release the current wxPython version is 4.0.7.post2.\
40 You can install with 'pip install wxPython' on most operating systems, or find the \
41 the download link from https://wxPython.org/""")
42 
43 try:
44  import wx
45  import wx.lib.inspection
46  from wx import Colour
47 except ImportError:
48  print(errorMessageTemplate.substitute(reason="wxPython not found."))
49  sys.exit(1)
50 
51 # Insert bundled robot to path before anything else
52 sys.path.append(os.path.join(os.path.dirname(__file__), 'spec'))
53 sys.path.append(os.path.join(os.path.dirname(__file__), 'lib'))
54 
55 
56 def main(*args):
58  noupdatecheck, debug_console, inpath = _parse_args(args)
59  if len(args) > 3 or '--help' in args:
60  print(__doc__)
61  sys.exit()
62  if '--version' in args:
63  try:
64  from . import version
65  except ImportError:
66  print("Error getting RIDE version!")
67  sys.exit(1)
68  print(version.VERSION)
69  sys.exit(0)
70  try:
71  _run(inpath, not noupdatecheck, debug_console)
72  except Exception: # DEBUG
73  import traceback
74  traceback.print_exception(*sys.exc_info())
75  sys.stderr.write('\n\nUse --help to get usage information.\n')
76 
77 
78 def _parse_args(args):
79  if not args:
80  return False, False, None
81  noupdatecheck = '--noupdatecheck' in args
82  debug_console = '--debugconsole' in args
83  inpath = args[-1] if args[-1] not in ['--noupdatecheck',
84  '--debugconsole'] else None
85  return noupdatecheck, debug_console, inpath
86 
87 
88 def _run(inpath=None, updatecheck=True, debug_console=False):
89  try:
90  from robotide.application import RIDE
91  from robotide.application import debugconsole
92  except ImportError:
94  raise
95  ride = RIDE(inpath, updatecheck)
96  if wx.VERSION <= (4, 0, 4, '', ''):
98  else:
99  wx.CallAfter(_show_old_wxpython_warning_if_needed, ride.frame)
100  if debug_console:
101  wx.lib.inspection.InspectionTool().Show()
102  debugconsole.start(ride)
103  ride.MainLoop()
104 
105 
107 
108  class NullStream:
109  def close(self): pass
110 
111  def flush(self): pass
112 
113  def write(self, line): pass
114 
115  def writelines(self, sequence): pass
116 
117  if sys.executable.endswith('pythonw.exe'):
118  # In windows, when launching RIDE with pythonw.exe
119  # sys.stderr and sys.stdout will be None
120  if sys.stderr is None:
121  sys.stderr = NullStream()
122  if sys.stdout is None:
123  sys.stdout = NullStream()
124 
125 
127  if wx.VERSION <=(4, 0, 4, '', ''):
128  title = "Please upgrade your wxPython installation"
129  message = ("RIDE needs a newer wxPython version. Your current "
130  "version is %s."
131  "\n"
132  "At the time of this release the current wxPython version is 4.0.7.post2. See "
133  "https://wxPython.org/ for downloads and instructions."
134  % wx.VERSION_STRING)
135  style = wx.ICON_EXCLAMATION
136  if not parent:
137 
140  _ = wx.App()
141  parent = wx.Frame(None, size=(0, 0))
142  sys.stderr.write("{0}\n{1}\n".format(title, message))
143  dlg = wx.MessageDialog(parent, message=message, caption=title, style=style)
144  """
145  dlg.SetBackgroundColour(Colour(200, 222, 40))
146  dlg.SetForegroundColour(Colour(7, 0, 70))
147  """
148  dlg.ShowModal()
149 
150 
151 if __name__ == '__main__':
152  main(*sys.argv[1:])
def write(msg, level='INFO', html=False)
Writes the message to the log file using the given level.
Definition: logger.py:86
def _run(inpath=None, updatecheck=True, debug_console=False)
Definition: __init__.py:88
def _show_old_wxpython_warning_if_needed(parent=None)
Definition: __init__.py:126
def _replace_std_for_win()
Definition: __init__.py:106
def main(*args)
Definition: __init__.py:56
def _parse_args(args)
Definition: __init__.py:78