-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigReader.py
88 lines (72 loc) · 2.16 KB
/
configReader.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
from xml.etree import ElementTree
import logging, codecs, sys
class ConfigReader():
configXML = None
def __init__(self, fileName="config.xml"):
self.configXML = ElementTree.parse(fileName)
def getTextByXPath(self, xpath):
returnValue = None
try:
returnValue = self.configXML.find(xpath).text
except:
pass
return returnValue
def getScannerID(self):
scannerID = self.getTextByXPath(".//ScannerIDNumber")
try:
bytes.fromhex(scannerID)
except ValueError:
logging.exception("ScannerID is expected to be HEX value")
sys.exit(255)
return scannerID
def getGT06ServerHostname(self):
return self.getTextByXPath(".//GT06ClientSettings/Hostname")
def getGT06ServerPort(self):
returnValue = None
try:
returnValue = int(
self.getTextByXPath(".//GT06ClientSettings/Port")
)
except:
pass
return returnValue
def getGT06ServerUpdateDelay(self):
returnValue = None
try:
returnValue = int(
self.getTextByXPath(".//GT06ClientSettings/UpdateDelay")
)
except:
pass
return returnValue
def getGPSDevicePort(self):
return self.getTextByXPath(".//GPSSettings/Port")
def getGPSDeviceBaud(self):
returnValue = None
try:
returnValue = int(
self.getTextByXPath(".//GPSSettings/Baud")
)
except:
pass
return returnValue
def getMapsURL(self):
return self.getTextByXPath(".//DisplaySettings/MapsURL")
def getMapsZoom(self):
returnValue = None
try:
returnValue = int(
self.getTextByXPath(".//DisplaySettings/Zoom")
)
except:
pass
return returnValue
def getMapsMagnification(self):
returnValue = 1
try:
returnValue = int(
self.getTextByXPath(".//DisplaySettings/Magnification")
)
except:
pass
return returnValue