deal with empty config values

workspace
Brendan Howell 4 years ago
parent 0dd6bc979b
commit f9a24c458b

@ -184,14 +184,17 @@ class Bureau(object):
printcfg = configparser.ConfigParser()
try:
printcfg.read("printers.cfg")
self.smprint = object()
self.smprint["vendorid"] = int(printcfg["smallprinter"]["vendorid"], 16)
self.smprint["prodid"] = int(printcfg["smallprinter"]["productid"], 16)
self.smprint["in_ep"] = int(printcfg["smallprinter"]["inep"], 16)
self.smprint["out_ep"] = int(printcfg["smallprinter"]["outep"], 16)
self.smprint = {}
for hexkey in ["vendorid", "productid", "inep", "outep"]:
val = printcfg["smallprinter"][hexkey]
if val == "":
self.smprint[hexkey] = None
else:
self.smprint[hexkey] = int(val, 16)
self.smprint["width"] = int(printcfg["smallprinter"]["width"])
self.smprint["textwidth"] = int(printcfg["smallprinter"]["textwidth"])
self.lp = {}
self.lp["name"] = printcfg["largeprinter"]["name"]
self.lp["papersize"] = printcfg["largeprinter"]["papersize"]
self.lp["duplex"] = printcfg["largeprinter"].getboolean("duplex")

Loading…
Cancel
Save