Wed, 20 Jan 2021 10:17:01 +0100
updated pronterface.py losing my own changes
45 | 1 | #!/usr/bin/env python3 |
15 | 2 | |
3 | # This file is part of the Printrun suite. | |
4 | # | |
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 | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # Printrun is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
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/>. | |
17 | ||
45 | 18 | import os |
15 | 19 | import sys |
20 | import getopt | |
21 | ||
22 | try: | |
23 | import wx # NOQA | |
45 | 24 | if wx.VERSION < (4,): |
25 | raise ImportError() | |
15 | 26 | except: |
45 | 27 | print("wxPython >= 4 is not installed. This program requires wxPython >=4 to run.") |
28 | raise | |
15 | 29 | |
30 | from printrun.pronterface import PronterApp | |
31 | ||
32 | if __name__ == '__main__': | |
33 | ||
34 | from printrun.printcore import __version__ as printcore_version | |
35 | ||
45 | 36 | os.environ['GDK_BACKEND'] = 'x11' |
37 | ||
15 | 38 | usage = "Usage:\n"+\ |
45 | 39 | " pronterface [OPTIONS] [FILE]\n\n"+\ |
15 | 40 | "Options:\n"+\ |
45 | 41 | " -h, --help\t\t\tPrint this help message and exit\n"+\ |
15 | 42 | " -V, --version\t\t\tPrint program's version number and exit\n"+\ |
45 | 43 | " -v, --verbose\t\t\tIncrease verbosity\n"+\ |
15 | 44 | " -a, --autoconnect\t\tAutomatically try to connect to printer on startup\n"+\ |
45 | 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=COMMAND\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved" | |
15 | 47 | |
48 | try: | |
45 | 49 | opts, args = getopt.getopt(sys.argv[1:], "hVvac:e:", ["help", "version", "verbose", "autoconnect", "conf=", "config=", "execute="]) |
50 | except getopt.GetoptError as err: | |
51 | print(str(err)) | |
52 | print(usage) | |
15 | 53 | sys.exit(2) |
54 | for o, a in opts: | |
55 | if o in ('-V','--version'): | |
45 | 56 | print("printrun "+printcore_version) |
15 | 57 | sys.exit(0) |
58 | elif o in ('-h', '--help'): | |
45 | 59 | print(usage) |
15 | 60 | sys.exit(0) |
61 | ||
62 | app = PronterApp(False) | |
63 | try: | |
64 | app.MainLoop() | |
65 | except KeyboardInterrupt: | |
66 | pass | |
67 | del app |