def init(): args = sys.argv.copy() options = [] while len(args) > 1: # args[0] = script name arg = args.pop() if (arg == "--debug") or (arg == "-d"): options.append("debug") print( "[LPHK] Debugging mode active! Will not shut down on window close." ) print( "[LPHK] Run shutdown() to manually close the program correctly." ) elif arg == "--autoconnect": options.append("autoconnect") elif arg.startswith("--layout="): options.append("loadlayout") options.insert(0, arg[9:]) else: print("[LPHK] Invalid argument: " + arg + ". Ignoring...") files.init(PATH) sound.init(PATH) return options
def init(): global EXIT_ON_WINDOW_CLOSE if len(sys.argv) > 1: if ("--debug" in sys.argv) or ("-d" in sys.argv): EXIT_ON_WINDOW_CLOSE = False print("[LPHK] Debugging mode active! Will not shut down on window close.") print("[LPHK] Run shutdown() to manually close the program correctly.") else: print("[LPHK] Invalid argument: " + sys.argv[1] + ". Ignoring...") files.init(PATH) sound.init(PATH)
def init(schema, coll, pgConn, host, resourceUtil, workspacePath): global collections collections = coll; ensureIndexes(collections) files.init(collections, workspacePath) ckan.init(pgConn, schema) query.init(collections, host) vocab.init(schema, collections) delete.init(collections, workspacePath) workspace.init(collections, resourceUtil, workspacePath) mapreduce.init(collections, schema) push.init(collections)
def __init__(self, network=None, link=False): import files import links files.init() links.init() if network: print("Creating network ...") self.network = self.createReseau(network) print("Creating links ...") self.links = self.createLiens() else: print("Loading network ...") self.network, self.links = files.load() """
def init(): global EXIT_ON_WINDOW_CLOSE global DEFAULT_LOAD_FILE if args["debug"] is True: EXIT_ON_WINDOW_CLOSE = False print( "[LPHK] Debugging mode active! Will not shut down on window close." ) print("[LPHK] Run shutdown() to manually close the program correctly.") if args["load"] is not None: DEFAULT_LOAD_FILE = args["load"] files.init(USER_PATH) sound.init(USER_PATH)
def init(): global EXIT_ON_WINDOW_CLOSE ap = argparse.ArgumentParser() # argparse makes argument processing easy ap.add_argument( # reimnplementation of debug (-d or --debug) "-d", "--debug", help = "Turn on debugging mode", action="store_true") ap.add_argument( # option to automatically load a layout "-l", "--layout", help = "Load an initial layout", type=argparse.FileType('r')) ap.add_argument( # option to start minimised "-m", "--minimised", help = "Start the application minimised", action="store_true") ap.add_argument( # option to start without connecting to a Launchpad "-s", "--standalone", help = "Operate without connection to Launchpad", type=str, choices=[LP_MK1, LP_MK2, LP_MINI, LP_PRO]) ap.add_argument( # option to start with launchpad window in a particular mode "-M", "--mode", help = "Launchpad mode", type=str, choices=[LM_EDIT, LM_MOVE, LM_SWAP, LM_COPY, LM_RUN], default=LM_EDIT) ap.add_argument( # turn of unnecessary verbosity "-q", "--quiet", help = "Disable information popups", action="store_true") ap.add_argument( # make button text variable in size (default is small) "-f", "--fit", help = "Make short button text fit the button", action="store_true") global_vars.ARGS = vars(ap.parse_args()) # store the arguments in a place anything can get to if global_vars.ARGS['debug']: EXIT_ON_WINDOW_CLOSE = False print("[LPHK] Debugging mode active! Will not shut down on window close.") print("[LPHK] Run shutdown() to manually close the program correctly.") files.init(USER_PATH) sound.init(USER_PATH) global LP LP = Launchpad()
cmd = self.commands[data[0]] return cmd.run(data[1:]) cp = CommandProcessor() import processes processes.init(cp) import console console.init(cp) import mailbox mailbox.init(cp) import files files.init(cp) import sockets sockets.init(cp) pr = packet.PacketReader(cp) start_time = time.time() with cbreak(): #while time.time() - start_time < 100: while True: res = pr.process() if res == False: break
#!/usr/bin/env python3 import argparse from tasks import * import files if __name__ == '__main__': files.init() parse = argparse.ArgumentParser() parse.add_argument("-s", type=str, help="search task with key", required=False) parse.add_argument("-a", type=str, help="add a new task", required=False) parse.add_argument("-d", type=int, help="delete a task", required=False) parse.add_argument("-c", type=int, help="copy a task to clipboard", required=False) args = parse.parse_args() if args.s is not None: show_task(key=args.s) elif args.a is not None: add_task(args.a) elif args.d is not None: delete_task(args.d) elif args.c is not None: copy_task(args.c) else: show_task(key=None)
cmd = self.commands[data[0]] return cmd.run(data[1:]) cp = CommandProcessor() import processes processes.init(cp) import console console.init(cp) import mailbox mailbox.init(cp) import files files.init(cp) import sockets sockets.init(cp) import sockets_udp sockets_udp.init(cp) pr = packet.PacketReader(cp) start_time = time.time() with cbreak(): #while time.time() - start_time < 100: while True: res = pr.process() if res == False: break
import files files.init() print(files.options["player name"]) from pprint import pprint as prettyprint prettyprint(files.options)