printrun-src/pronterface.py

changeset 45
c82943fb205f
parent 15
0bbb006204fc
equal deleted inserted replaced
44:310be640a303 45:c82943fb205f
1 #!/usr/bin/env python 1 #!/usr/bin/env python3
2 2
3 # This file is part of the Printrun suite. 3 # This file is part of the Printrun suite.
4 # 4 #
5 # Printrun is free software: you can redistribute it and/or modify 5 # Printrun is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Printrun. If not, see <http://www.gnu.org/licenses/>. 16 # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import os
18 import sys 19 import sys
19 import getopt 20 import getopt
20 21
21 try: 22 try:
22 import wx # NOQA 23 import wx # NOQA
24 if wx.VERSION < (4,):
25 raise ImportError()
23 except: 26 except:
24 print("wxPython is not installed. This program requires wxPython to run.") 27 print("wxPython >= 4 is not installed. This program requires wxPython >=4 to run.")
25 if sys.version_info.major >= 3: 28 raise
26 print("""\
27 As you are currently running python3, this is most likely because wxPython is
28 not yet available for python3. You should try running with python2 instead.""")
29 sys.exit(-1)
30 else:
31 raise
32 29
33 from printrun.pronterface import PronterApp 30 from printrun.pronterface import PronterApp
34 31
35 if __name__ == '__main__': 32 if __name__ == '__main__':
36 33
37 from printrun.printcore import __version__ as printcore_version 34 from printrun.printcore import __version__ as printcore_version
38 35
36 os.environ['GDK_BACKEND'] = 'x11'
37
39 usage = "Usage:\n"+\ 38 usage = "Usage:\n"+\
40 " pronterface [OPTION]\n\n"+\ 39 " pronterface [OPTIONS] [FILE]\n\n"+\
41 "Options:\n"+\ 40 "Options:\n"+\
41 " -h, --help\t\t\tPrint this help message and exit\n"+\
42 " -V, --version\t\t\tPrint program's version number and exit\n"+\ 42 " -V, --version\t\t\tPrint program's version number and exit\n"+\
43 " -h, --help\t\t\tPrint this help message and exit\n"+\ 43 " -v, --verbose\t\t\tIncrease verbosity\n"+\
44 " -a, --autoconnect\t\tAutomatically try to connect to printer on startup\n"+\ 44 " -a, --autoconnect\t\tAutomatically try to connect to printer on startup\n"+\
45 " -c, --conf\t\t\tLoad this file on startup instead of .pronsolerc; you may chain config files, if so settings auto-save will use the last specified file\n"+\ 45 " -c, --conf, --config=CONFIG_FILE\tLoad this file on startup instead of .pronsolerc; you may chain config files, if so settings auto-save will use the last specified file\n"+\
46 " -e, --execute\t\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved" 46 " -e, --execute=COMMAND\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved"
47 47
48 try: 48 try:
49 opts, args = getopt.getopt(sys.argv[1:], "hVcea", ["help", "version", "conf", "execute", "autoconnect"]) 49 opts, args = getopt.getopt(sys.argv[1:], "hVvac:e:", ["help", "version", "verbose", "autoconnect", "conf=", "config=", "execute="])
50 except getopt.GetoptError, err: 50 except getopt.GetoptError as err:
51 print str(err) 51 print(str(err))
52 print usage 52 print(usage)
53 sys.exit(2) 53 sys.exit(2)
54 for o, a in opts: 54 for o, a in opts:
55 if o in ('-V','--version'): 55 if o in ('-V','--version'):
56 print "printrun "+printcore_version 56 print("printrun "+printcore_version)
57 sys.exit(0) 57 sys.exit(0)
58 elif o in ('-h', '--help'): 58 elif o in ('-h', '--help'):
59 print usage 59 print(usage)
60 sys.exit(0) 60 sys.exit(0)
61 61
62 app = PronterApp(False) 62 app = PronterApp(False)
63 try: 63 try:
64 app.MainLoop() 64 app.MainLoop()

mercurial