Exemplo n.º 1
0
def tricks_from(args):
    """
    Subcommand to execute tricks from a tricks configuration file.

    :param args:
        Command line argument options.
    """
    from mitmflib.watchdog.observers import Observer

    add_to_sys_path(path_split(args.python_path))
    observers = []
    for tricks_file in args.files:
        observer = Observer(timeout=args.timeout)

        if not os.path.exists(tricks_file):
            raise IOError("cannot find tricks file: %s" % tricks_file)

        config = load_config(tricks_file)

        try:
            tricks = config[CONFIG_KEY_TRICKS]
        except KeyError:
            raise KeyError("No `%s' key specified in %s." % (
                           CONFIG_KEY_TRICKS, tricks_file))

        if CONFIG_KEY_PYTHON_PATH in config:
            add_to_sys_path(config[CONFIG_KEY_PYTHON_PATH])

        dir_path = os.path.dirname(tricks_file)
        if not dir_path:
            dir_path = os.path.relpath(os.getcwd())
        schedule_tricks(observer, tricks, dir_path, args.recursive)
        observer.start()
        observers.append(observer)

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        for o in observers:
            o.unschedule_all()
            o.stop()
    for o in observers:
        o.join()
Exemplo n.º 2
0
 def start_config_watch(self):
     observer = Observer()
     observer.schedule(self, path='./config', recursive=False)
     observer.start()
Exemplo n.º 3
0
 def start_config_watch(self):
     observer = Observer()
     observer.schedule(self, path='./config', recursive=False)
     observer.start()
Exemplo n.º 4
0
 def start(self):
     observer = Observer()
     observer.schedule(self, path='./config/beef_arerules/enabled', recursive=False)
     observer.start()
Exemplo n.º 5
0
 def startConfigWatch(self):
     observer = Observer()
     observer.schedule(self, path="./config", recursive=False)
     observer.start()