Wed, 20 Jan 2021 11:37:03 +0100
reimplemented lasercutter 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 | ||
18 | import sys | |
19 | import traceback | |
20 | import logging | |
21 | from printrun.pronsole import pronsole | |
22 | import getopt | |
23 | ||
24 | if __name__ == "__main__": | |
25 | ||
26 | from printrun.printcore import __version__ as printcore_version | |
27 | ||
28 | usage = "Usage:\n"+\ | |
45 | 29 | " pronsole [OPTIONS] [FILE]\n\n"+\ |
15 | 30 | "Options:\n"+\ |
45 | 31 | " -h, --help\t\t\tPrint this help message and exit\n"+\ |
15 | 32 | " -V, --version\t\t\tPrint program's version number and exit\n"+\ |
45 | 33 | " -v, --verbose\t\t\tIncrease verbosity\n"+\ |
34 | " -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"+\ | |
35 | " -e, --execute=COMMAND\t\tExecutes command after configuration/.pronsolerc is loaded; macros/settings from these commands are not autosaved" | |
15 | 36 | |
37 | try: | |
45 | 38 | opts, args = getopt.getopt(sys.argv[1:], "hVvc:e:", ["help", "version", "verbose", "conf=", "config=", "execute="]) |
39 | except getopt.GetoptError as err: | |
40 | print(str(err)) | |
41 | print(usage) | |
15 | 42 | sys.exit(2) |
43 | for o, a in opts: | |
44 | if o in ('-V','--version'): | |
45 | 45 | print("printrun "+printcore_version) |
15 | 46 | sys.exit(0) |
47 | elif o in ('-h', '--help'): | |
45 | 48 | print(usage) |
15 | 49 | sys.exit(0) |
50 | ||
51 | interp = pronsole() | |
52 | interp.parse_cmdline(sys.argv[1:]) | |
53 | try: | |
54 | interp.cmdloop() | |
55 | except SystemExit: | |
56 | interp.p.disconnect() | |
57 | except: | |
58 | logging.error(_("Caught an exception, exiting:") | |
59 | + "\n" + traceback.format_exc()) | |
60 | interp.p.disconnect() |