-
Notifications
You must be signed in to change notification settings - Fork 10
/
gsat-console.py
executable file
·142 lines (107 loc) · 3.93 KB
/
gsat-console.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python
"""----------------------------------------------------------------------------
gsat-console.py:
Copyright (C) 2018 Wilhelm Duembeg
This file is part of gsat. gsat is a cross-platform GCODE debug/step for
Grbl like GCODE interpreters. With features similar to software debuggers.
Features such as breakpoint, change current program counter, inspection
and modification of variables.
gsat is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
gsat is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gsat. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------"""
import sys
import argparse
import curses
import modules.config as gc
import modules.con_main as cm
import modules.version_info as vinfo
def get_cli_params():
"""
define, retrieve and error check command line interface (cli) params
"""
# parser = argparse.ArgumentParser(description=__description__)
parser = argparse.ArgumentParser()
parser.add_argument(
'-V', '--version',
action='version',
version=f"{sys.argv[0]} {vinfo.__revision__} ({vinfo.__appname__})")
parser.add_argument(
"-c", "--config",
dest="config",
default=None,
help="Use alternate configuration file name",
metavar="FILE")
parser.add_argument(
"-g", "--gcode",
dest="gcode",
default="None",
help="gcode file.",
metavar="FILE")
parser.add_argument(
"-r", "--run",
dest="run",
action="store_true",
default=False,
help="run gcode immediately, must have --gcode")
parser.add_argument(
"-s", "--server",
dest="server",
action="store_true",
default=False,
help="run gsat server on local host, and automatically connect")
parser.add_argument(
"--nc", "--ncurses", "--no-curses",
dest="no_curses",
action="store_true",
default=False,
help="Don't use curses user interface")
mask_str = str(sorted(gc.VERBOSE_MASK_DICT.keys()))
parser.add_argument(
"--vm", "--verbose_mask",
dest="verbose_mask",
default=None,
help="select verbose mask(s) separated by ',' options are {}".format(mask_str),
metavar="MASK")
options = parser.parse_args()
if options.verbose_mask is not None:
options.verbose_mask = gc.decode_verbose_mask_string(options.verbose_mask)
if len(options.gcode):
options.gcode = str(options.gcode).strip()
if options.run and options.gcode == "None":
print("Error: --gcode option must be included when using --run option\n")
parser.print_usage()
exit(1)
if sys.version_info < (3, 8, 0):
parser.error("** Required Python 3.8.2 or grater.")
sys.exit(1)
return options
"""----------------------------------------------------------------------------
main
----------------------------------------------------------------------------"""
cli_options = None
def main(screen=None):
global cli_options
app = cm.ConsoleApp(cli_options)
app.run()
if __name__ == '__main__':
cli_options = get_cli_params()
try:
if cli_options.no_curses:
main()
else:
curses.wrapper(main)
finally:
if cli_options is False:
pass
# curses.nocbreak()
# curses.echo()
# curses.curs_set(1)
# curses.endwin()