From 8ca085a72837d936568eb66af390d79ce9593aff Mon Sep 17 00:00:00 2001 From: Keegi Date: Mon, 4 Jul 2011 13:06:42 +0300 Subject: [PATCH] changed order of parsing startup config files and -e commands --- pronsole.py | 16 ++++++++++++---- pronterface.py | 2 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pronsole.py b/pronsole.py index f2ef176..0b0a00b 100644 --- a/pronsole.py +++ b/pronsole.py @@ -359,8 +359,6 @@ class pronsole(cmd.Cmd): del rci,rco def preloop(self): - if not self.rc_loaded: - self.load_default_rc() print "Welcome to the printer console! Type \"help\" for a list of available commands." cmd.Cmd.preloop(self) @@ -1028,12 +1026,22 @@ class pronsole(cmd.Cmd): def parse_cmdline(self,args): import getopt - opts,args = getopt.getopt(args, "c:e:", ["conf=","config="]) + opts,args = getopt.getopt(args, "c:e:h", ["conf=","config=","help"]) for o,a in opts: #print repr((o,a)) if o in ("-c","--conf","--config"): self.load_rc(a) - elif o == "-e": + elif o in ("-h","--help"): + print "Usage: "+sys.argv[0]+' [-c filename [-c filename2 ... ] ] [-e "command" ...]' + print " -c | --conf | --config - override startup .pronsolerc file" + print " may chain config files, settings auto-save will go into last file in the chain" + print ' -e - executes command after configuration/.pronsolerc is loaded' + print " macros/settings from these commands are not autosaved" + sys.exit() + if not self.rc_loaded: + self.load_default_rc() + for o,a in opts: + if o == "-e": self.processing_args = True self.onecmd(a) self.processing_args = False diff --git a/pronterface.py b/pronterface.py index c74f5f1..8421a8d 100644 --- a/pronterface.py +++ b/pronterface.py @@ -84,8 +84,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.custombuttons=[] self.btndict={} self.parse_cmdline(sys.argv[1:]) - if not self.rc_loaded: - self.load_default_rc(".pronsolerc") customdict={} try: execfile("custombtn.txt",customdict)