def main(): p = ConfigMaster() p.setDefaultParams(defaultParams) p.init(__doc__) print "Using these parameters" p.printParams() if p.opt["debug"]: print "\nDEBUG: Using forecast hour: {}".format(p.opt["forecastHour"])
def main(): p = ConfigMaster() p.setDefaultParams(defaultParams) p.init(__doc__, add_default_logging=False) print("Using these parameters") p.printParams() if p["debug"]: print(f"\nDEBUG: Using forecast hour: {p['forecastHour']}")
#possible values: GFS3, GFS4 or GFS5 model = "GFS3" expected_file_size = 10e+7 forecast_hours = 24 _config_override["model"]["GFS4"]["expected_file_size"] = 15e+7 _config_override["model"]["GFS4"]["forecast_hours"] = 36 _config_override["model"]["GFS5"]["expected_file_size"] = 20e+7 _config_override["model"]["GFS5"]["forecast_hours"] = 48 """ # It can be convenient to give your ConfigMaster instance global scope p = ConfigMaster(defaultParams, __doc__, add_default_logging=True, allow_extra_parameters=True, doDebug=True) print(f"Using ConfigMaster version {p.version}") def main(): logging.info(f"Using these parameters:") for key in p.opt: if not key == "_config_override": logging.info(f"\t{key} : {p[key]}") if __name__ == "__main__": main()
return self._auth_code_queue.get(block=True) def start_local_server(listen=('', 4443)): server = RedirectHTTPServer(listen, RedirectHandler) thread = threading.Thread(target=server.serve_forever) thread.daemon = True thread.start() return server ##################################### # ConfigMaster ##################################### p = ConfigMaster() p.setDefaultParams(defaultParams) p.init(__doc__) ######################################################## # global constants ######################################################## CLIENT_ID = "f70debeb-31cc-40c0-8d65-d747641428b4" REDIRECT_URI = 'https://auth.globus.org/v2/web/auth-code' SCOPES = ('openid email profile ' 'urn:globus:auth:scope:transfer.api.globus.org:all') ########################### # Global for the email ########################### email_msg = email.message.EmailMessage()
forecastHour = 3 # Email Address emailAddress = "*****@*****.**" dataDir = os.path.join(os.environ["HOME"],"data") outFile = os.path.join(dataDir,"output",datetime.datetime.now().strftime("%Y%m%d") + ".out") test = True """ # It can be useful to give your ConfigMaster instance global scope p = ConfigMaster() p.setDefaultParams(defaultParams) p.init(__doc__, add_default_logging=True, allow_extra_parameters=True) def main(): logging.info(f"Using these parameters:") for line in p.getParamsString().splitlines(): logging.info(f"\t{line}") logging.info("info test") logging.debug("debug test") # using deprecated .warn instead of .warning # to illustrate utility of logging.captureWarnings() logging.warn("warn test")
#!/usr/bin/env python3 ''' Super simple example of ConfigMaster ''' from ConfigMaster import ConfigMaster import logging defaultParams = """ import os, datetime forecastHour = 4 dataDir = "/dir" outFile = os.path.join(dataDir,"output",datetime.datetime.now().strftime("%Y%m%d") + ".out") """ p = ConfigMaster(defaultParams, __doc__, add_default_logging=True) logging.info(f"forecastHour = {p['forecastHour']}")