printrun-src/pronterface.py

Tue, 19 Jan 2021 20:45:09 +0100

author
mdd
date
Tue, 19 Jan 2021 20:45:09 +0100
changeset 45
c82943fb205f
parent 15
0bbb006204fc
permissions
-rwxr-xr-x

updated main files to new github master version

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

mercurial