-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaliburn.py
51 lines (42 loc) · 1.88 KB
/
caliburn.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
#
#
#
import argparse
import ConfigParser
import msvcrt
import sys
import logger
def print_banner(logger):
pass
def main():
###########################
## Add argument parser ##
###########################
parser = argparse.ArgumentParser(description="Caliburn is an application for performing interaction between PC and a remote embedded system via the RS232 protocol.",
epilog="Please raise any bugs when you encounter and give any suggestion when you need a new feature.")
parser.add_argument("-p", "--port", dest="port", action="store", description="Specify the name of the serial port to use.")
parser.add_argument("-b", "--baud", dest="baudrate", action="store", type=int, description="Specify the value of the baudrate for the serial port used.")
parser.add_argument("-f", "--file", dest="config", required=True, action="store", description="Specify the name of the configuration file.")
parser.add_argument("-o", "--outfile", dest="outfile", action="store")
parser.add_argument("-v", "--verbose", dest="verbose", action="count")
parser.add_argument("--echo", dest="echo", action="store_true")
args = parser.parse_args()
logger =
print_banner(logger)
####################################
## Parse the configuration file ##
####################################
config = ConfigParser.RawConfigParser()
try:
if (not config.read([args.config])):
print("=== The configuration file is invalid.")
print("... ... Press any key to exit ... ...")
msvcrt.getch()
sys.exit(1)
except ConfigParser.MissingSectionHeaderError:
print("=== The contents in the configuration file is invalid.")
print("--- Press any key to exit ---")
msvcrt.getch()
sys.exit(1)
if __name__ == "__main__":
main()