def main(): parser = OptionParser( usage='usage: %prog [options] [folder containing dxr.config | config ' 'file]', description='If no args are given, defaults to looking for a config ' 'file called dxr.config in the current working directory.') parser.add_option('-f', '--file', dest='config_file', help='A DXR config file. [Deprecated. Use the first ' 'positional arg instead.]') parser.add_option('-t', '--tree', dest='tree', help='An INI section title in the config file, ' 'specifying a source tree to build. (Default: all ' 'trees.)') parser.add_option('-j', '--jobs', dest='jobs', type='int', default=1, help='Number of parallel processes to use, (Default: 1)') options, args = parser.parse_args() if len(args) > 1: parser.print_usage() if args: # Handle deprecated --file arg: if options.config_file: print >> stderr, ('Warning: overriding the --file or -f flag with ' 'the first positional argument.') options.config_file = (os.path.join(args[0], 'dxr.config') if isdir(args[0]) else args[0]) elif not options.config_file: # Assume dxr.config in the cwd: options.config_file = 'dxr.config' build_instance( options.config_file, # TODO: Remove this brain-dead cast when we get the types # right in the Config object: nb_jobs=str(options.jobs), tree=options.tree)
def main(): parser = OptionParser( usage='usage: %prog [options] [folder containing dxr.config | config ' 'file]', description='If no args are given, defaults to looking for a config ' 'file called dxr.config in the current working directory.') parser.add_option('-f', '--file', dest='config_file', help='A DXR config file. [Deprecated. Use the first ' 'positional arg instead.]') parser.add_option('-t', '--tree', dest='tree', help='An INI section title in the config file, ' 'specifying a source tree to build. (Default: all ' 'trees.)') parser.add_option('-j', '--jobs', dest='jobs', type='int', default=None, help='Number of parallel processes to use, (Default: the' ' value of nb_jobs in the config file)') parser.add_option('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Display the build logs during the build instead of' ' only on error.') options, args = parser.parse_args() if len(args) > 1: parser.print_usage() if args: # Handle deprecated --file arg: if options.config_file: print >> stderr, ('Warning: overriding the --file or -f flag with ' 'the first positional argument.') options.config_file = (os.path.join(args[0], 'dxr.config') if isdir(args[0]) else args[0]) elif not options.config_file: # Assume dxr.config in the cwd: options.config_file = 'dxr.config' build_instance(options.config_file, nb_jobs=options.jobs, tree=options.tree, verbose=options.verbose)
def main(): parser = OptionParser( usage='usage: %prog [options] [folder containing dxr.config | config ' 'file]', description='If no args are given, defaults to looking for a config ' 'file called dxr.config in the current working directory.') parser.add_option('-f', '--file', dest='config_file', help='A DXR config file. [Deprecated. Use the first ' 'positional arg instead.]') parser.add_option('-t', '--tree', dest='tree', help='An INI section title in the config file, ' 'specifying a source tree to build. (Default: all ' 'trees.)') parser.add_option('-j', '--jobs', dest='jobs', type='int', default=1, help='Number of parallel processes to use, (Default: 1)') options, args = parser.parse_args() if len(args) > 1: parser.print_usage() if args: # Handle deprecated --file arg: if options.config_file: print >> stderr, ('Warning: overriding the --file or -f flag with ' 'the first positional argument.') options.config_file = (os.path.join(args[0], 'dxr.config') if isdir(args[0]) else args[0]) elif not options.config_file: # Assume dxr.config in the cwd: options.config_file = 'dxr.config' build_instance(options.config_file, # TODO: Remove this brain-dead cast when we get the types # right in the Config object: nb_jobs=str(options.jobs), tree=options.tree)
# write configurate to disk with open(join(build_root, "dxr.config"), "w") as config_file: config.write(config_file) import pysqlite2.dbapi2 sys.modules['sqlite3'] = pysqlite2.dbapi2 try: from dxr.build import build_instance except ImportError: log.exception("Failed to import") else: try: build_instance(join(build_root, "dxr.config"), nb_jobs=None, tree=None, verbose=False) except: log.exception("Failed to build") else: dist_path = environ["STACKATO_FILESYSTEM_DXR_WWW"] trees_path = join(dist_path, "trees") if not exists(trees_path): os.makedirs(trees_path, 0775) # Move the whole tree over first so it's on the same FS stage_path = join(trees_path, dxr_tree + ".stage") if exists(stage_path): shutil.rmtree(stage_path) shutil.move(join(build_root, "www", "trees", dxr_tree), stage_path) try: os.rename(join(trees_path, dxr_tree), join(trees_path, dxr_tree + ".old"))