diff --git a/configtool.py b/configtool.py index 6f2d8bd..800537a 100755 --- a/configtool.py +++ b/configtool.py @@ -78,6 +78,14 @@ def cmdLoad(arg): print("Expected one of *.ini, board.*.h or printer.*.h.") sys.exit(2) +def cmdShowAll(): + names = {"configtool": getSettings(), "board": board, "printer": printer} + for namespace in names: + if names[namespace]: + values = names[namespace].getValues() + for k in sorted(values): + print("%s.%s: %s" % (namespace, k, str(values[k]))) + def cmdHelp(): print("""Usage: %s [options] @@ -96,6 +104,8 @@ Following options are available for command line automation: Content of this file is valid before the GUI loads, only. GUI will overwrite them with the files found in config.h. + + -a, --show-all Show all loaded variables and values. """ % sys.argv[0]) def CommandLine(argv): @@ -106,7 +116,8 @@ def CommandLine(argv): global settings, verbose try: - opts, args = getopt.getopt(argv, "hvl:", ["help", "verbose", "load="]) + opts, args = getopt.getopt(argv, "hvl:a", ["help", "verbose", "load=", + "show-all"]) except getopt.GetoptError as err: print(err) print("Use '%s --help' to get help with command line options." % @@ -128,6 +139,9 @@ def CommandLine(argv): elif opt in ("-l", "--load"): cmdLoad(arg) + elif opt in ("-a", "--show-all"): + cmdShowAll() + if __name__ == '__main__': CommandLine(sys.argv[1:]) StartGui(getSettings()) diff --git a/configtool/board.py b/configtool/board.py index a71fd15..fab8b6f 100644 --- a/configtool/board.py +++ b/configtool/board.py @@ -26,6 +26,12 @@ class Board: self.candHeatPins = [] self.candThermPins = [] + def getValues(self): + vars = [("sensor." + x[0], x[1:]) for x in self.sensors] + vars += [("heater." + x[0], x[1:]) for x in self.heaters] + vars += [(x, self.cfgValues[x]) for x in self.cfgValues] + return dict(vars) + def getCPUInfo(self): vF_CPU = None if 'F_CPU' in self.cfgValues.keys(): diff --git a/configtool/printer.py b/configtool/printer.py index 0af792a..3b289e2 100644 --- a/configtool/printer.py +++ b/configtool/printer.py @@ -16,6 +16,10 @@ class Printer: self.settings = settings self.cfgDir = os.path.join(self.settings.folder, "configtool") + def getValues(self): + vars = [(x, self.cfgValues[x]) for x in self.cfgValues] + return dict(vars) + def hasData(self): return (self.configFile != None) diff --git a/configtool/settings.py b/configtool/settings.py index 1ce39a7..645770e 100644 --- a/configtool/settings.py +++ b/configtool/settings.py @@ -100,6 +100,22 @@ class Settings: return True + def getValues(self): + return { + "arduinodir": str(self.arduinodir), + "cflags": str(self.cflags), + "ldflags": str(self.ldflags), + "objcopyflags": str(self.objcopyflags), + "programmer": str(self.programmer), + "port": str(self.port), + "t0": str(self.t0), + "r1": str(self.r1), + "numtemps": str(self.numTemps), + "maxadc": str(self.maxAdc), + "minadc": str(self.minAdc), + "uploadspeed": str(self.uploadspeed) + } + def saveSettings(self): self.section = "configtool" try: