Esempio n. 1
0
 def load(self, *ignore):
     """Load the configuration file and activate the commands."""
     if (not self.conf_exists()):
         return
     # Purge any existing sites
     purged = []
     for kw, func in engine.commands().iteritems():
         if func.__name__ == self.name + "_task":
             purged.append(kw)
             engine.remove(kw)
     logger.debug("purged ConfHandler commands: %s" % purged)
     logger.debug("ConfHandler loading %s" % self.conf_path)
     with open(self.conf_path) as in_file:
         for line in in_file:
             if not line.strip():
                 continue
             if COMMENT_RE.match(line):
                 continue
             tokens = line.split()
             if len(tokens) < 2:
                 continue
             keyword = tokens[0]
             args = tokens[1:]
             for alias in keyword.split(","):
                 message = "Adding conf_handler function with alias '%s'" + \
                     " for args '%s'"
                 logger.debug(message % (alias, args))
                 engine.add(self.make_task(args), alias)
Esempio n. 2
0
def load(open_path, task_name=None, pre_hook=None):
    if not os.path.exists(open_path):
        return

    with open(open_path) as conf:
        try:
            commands = json.load(conf)
        except ValueError:
            sys.stderr.write("Warning: invalid JSON at {}".format(open_path))
            return
    engine.add_reloader(open_path, full_reload)
    [add_command(command, pre_hook) for command in commands]
    if task_name:
        engine.add(prompt_and_save(open_path), task_name)
Esempio n. 3
0
def workflower(alias, node_id):
    def workflowy():
        commander.mac.pbcopy("https://workflowy.com/#/" + node_id)
        commander.mac.maestro("Workflowy URL")
    engine.add(workflowy, alias)
    return workflowy
Esempio n. 4
0
def add_command(command, pre_hook):
    task = opener(command, pre_hook)
    names = command["name"]
    if type(names) in types.StringTypes:
        names = [names]
    [engine.add(task, name) for name in names]