From f9a24c458b1369a85756487948e4de8b5599d472 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Fri, 20 Mar 2020 16:55:56 +0100 Subject: [PATCH] deal with empty config values --- screenless/bureau/bureau.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/screenless/bureau/bureau.py b/screenless/bureau/bureau.py index e193a1f..41f4b47 100644 --- a/screenless/bureau/bureau.py +++ b/screenless/bureau/bureau.py @@ -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")