def run(config=None): if config: config = b3.getAbsolutePath(config) else: # search for the config file config = None for p in ( "b3.xml", "conf/b3.xml", "b3/conf/b3.xml", "~/b3.xml", "~/conf/b3.xml", "~/b3/conf/b3.xml", "@b3/conf/b3.xml", ): path = b3.getAbsolutePath(p) print "Searching for config file: %s" % path if os.path.isfile(path): config = path break if not config: Setup(config) # raise SystemExit('Could not find config file.') b3.start(config)
def run_console(options): """ Run B3 in console mode. :param options: command line options """ analysis = None # main config analysis result printexit = False # whether the exit message has been printed alreadty or not try: if options.config: config = b3.getAbsolutePath(options.config, True) if not os.path.isfile(config): printexit = True console_exit('ERROR: configuration file not found (%s).\n' 'Please visit %s to create one.' % (config, B3_CONFIG_GENERATOR)) else: config = None for p in ('b3.%s', 'conf/b3.%s', 'b3/conf/b3.%s', os.path.join(HOMEDIR, 'b3.%s'), os.path.join(HOMEDIR, 'conf', 'b3.%s'), os.path.join(HOMEDIR, 'b3', 'conf', 'b3.%s'), '@b3/conf/b3.%s'): for e in ('ini', 'cfg', 'xml'): path = b3.getAbsolutePath(p % e, True) if os.path.isfile(path): print "Using configuration file: %s" % path config = path sleep(3) break if not config: printexit = True console_exit('ERROR: could not find any valid configuration file.\n' 'Please visit %s to create one.' % B3_CONFIG_GENERATOR) # LOADING MAIN CONFIGURATION main_config = b3.config.MainConfig(b3.config.load(config)) analysis = main_config.analyze() if analysis: raise b3.config.ConfigFileNotValid('invalid configuration file specified') # START B3 b3.start(main_config, options) except b3.config.ConfigFileNotValid: if analysis: print 'CRITICAL: invalid configuration file specified:\n' for problem in analysis: print" >>> %s\n" % problem else: print 'CRITICAL: invalid configuration file specified!' raise SystemExit(1) except SystemExit, msg: if not printexit and main_is_frozen(): if sys.stdout != sys.__stdout__: sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ print msg raw_input("press any key to continue...") raise
def run(options): """ Run B3 in console. :param options: command line options """ analysis = None # main config analysis result printexit = False # whether the exit message has been printed alreadty or not try: if options.config: config = b3.getAbsolutePath(options.config, True) if not os.path.isfile(config): printexit = True console_exit('ERROR: configuration file not found (%s).\n' 'Please visit %s to create one.' % (config, B3_CONFIG_GENERATOR)) else: config = None for p in ('b3.%s', 'conf/b3.%s', 'b3/conf/b3.%s', os.path.join(HOMEDIR, 'b3.%s'), os.path.join(HOMEDIR, 'conf', 'b3.%s'), os.path.join(HOMEDIR, 'b3', 'conf', 'b3.%s'), '@b3/conf/b3.%s'): for e in ('ini', 'cfg', 'xml'): path = b3.getAbsolutePath(p % e, True) if os.path.isfile(path): print "Using configuration file: %s" % path config = path sleep(3) break if not config: printexit = True console_exit('ERROR: could not find any valid configuration file.\n' 'Please visit %s to create one.' % B3_CONFIG_GENERATOR) # LOADING MAIN CONFIGURATION main_config = b3.config.MainConfig(b3.config.load(config)) analysis = main_config.analyze() if analysis: raise b3.config.ConfigFileNotValid('invalid configuration file specified') # START B3 b3.start(main_config, options) except b3.config.ConfigFileNotValid: if analysis: print 'CRITICAL: invalid configuration file specified:\n' for problem in analysis: print" >>> %s\n" % problem else: print 'CRITICAL: invalid configuration file specified!' raise SystemExit(1) except SystemExit, msg: if not printexit and main_is_frozen(): if sys.stdout != sys.__stdout__: sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ print msg raw_input("press any key to continue...") raise
def run(config=None): if config: config = b3.getAbsolutePath(config) else: # search for the config file config = None for p in ('b3.xml', 'conf/b3.xml', 'b3/conf/b3.xml', '~/b3.xml', '~/conf/b3.xml', '~/b3/conf/b3.xml', '@b3/conf/b3.xml'): path = b3.getAbsolutePath(p) print 'Searching for config file: %s' % path if os.path.isfile(path): config = path break if not config: raise SystemExit('Could not find config file.') b3.start(config)
def run(config=None): if config: config = b3.getAbsolutePath(config) else: # search for the config file config = None for p in ('b3.xml', 'conf/b3.xml', 'b3/conf/b3.xml', '~/b3.xml', '~/conf/b3.xml', '~/b3/conf/b3.xml', '@b3/conf/b3.xml'): path = b3.getAbsolutePath(p) print 'Searching for config file: %s' % path if os.path.isfile(path): config = path break if not config: #Setup(config) raise SystemExit('ERROR: Could not find config file, Please run B3 with option: --setup or -s') b3.start(config)
def run(config=None, nosetup=False): if config: config = b3.getAbsolutePath(config) else: # search for the config file config = None for p in ('b3.xml', 'conf/b3.xml', 'b3/conf/b3.xml', '~/b3.xml', '~/conf/b3.xml', '~/b3/conf/b3.xml', '@b3/conf/b3.xml'): path = b3.getAbsolutePath(p) print 'Searching for config file: %s' % path if os.path.isfile(path): config = path break if not config: # This happens when no config was specified on the commandline and the default configs are missing! if nosetup: raise SystemExit('ERROR: Could not find config file, Please run B3 with option: --setup or -s') else: Setup(config) b3.start(config, nosetup)
def run(config=None, nosetup=False): if config: config = b3.getAbsolutePath(config) else: # search for the config file config = None for p in ('b3.xml', 'conf/b3.xml', 'b3/conf/b3.xml', '~/b3.xml', '~/conf/b3.xml', '~/b3/conf/b3.xml', '@b3/conf/b3.xml'): path = b3.getAbsolutePath(p) print 'Searching for config file: %s' % path if os.path.isfile(path): config = path break if not config: # This happens when no config was specified on the commandline and the default configs are missing! if nosetup: raise SystemExit( 'ERROR: Could not find config file, Please run B3 with option: --setup or -s' ) else: Setup(config) b3.start(config, nosetup)