示例#1
0
文件: yokadid.py 项目: bport/yokadi
    def run(self):
        filename = self.options.filename
        if not filename:
            filename = os.path.join(os.path.expandvars("$HOME"), ".yokadi.db")
            print "Using default database (%s)" % filename

        connectDatabase(filename, createIfNeeded=False)

        # Basic tests :
        if not (Task.tableExists() and Config.tableExists()):
            print "Your database seems broken or not initialised properly. Start yokadi command line tool to do it"
            sys.exit(1)

        # Start ical http handler
        if self.options.icalserver:
            yokadiIcalServer = YokadiIcalServer(self.options.tcpPort,
                                                self.options.tcpListen)
            yokadiIcalServer.start()

        # Start the main event Loop
        try:
            while event[1] != "SIGTERM":
                eventLoop()
                event[0] = True
        except KeyboardInterrupt:
            print "\nExiting..."
示例#2
0
文件: yokadid.py 项目: bport/yokadi
    def run(self):
        filename = self.options.filename
        if not filename:
            filename = os.path.join(os.path.expandvars("$HOME"), ".yokadi.db")
            print "Using default database (%s)" % filename

        connectDatabase(filename, createIfNeeded=False)

        # Basic tests :
        if not (Task.tableExists() and Config.tableExists()):
            print "Your database seems broken or not initialised properly. Start yokadi command line tool to do it"
            sys.exit(1)

        # Start ical http handler
        if self.options.icalserver:
            yokadiIcalServer = YokadiIcalServer(self.options.tcpPort, self.options.tcpListen)
            yokadiIcalServer.start()

        # Start the main event Loop
        try:
            while event[1] != "SIGTERM":
                eventLoop()
                event[0] = True
        except KeyboardInterrupt:
            print "\nExiting..."
示例#3
0
文件: aliascmd.py 项目: bport/yokadi
 def __init__(self):
     try:
         self.aliases = eval(Config.byName("ALIASES").value)
     except SQLObjectNotFound:
         self.aliases = {}
     except Exception:
         tui.error("Aliases syntax error. Ignored")
         self.aliases = {}
示例#4
0
文件: aliascmd.py 项目: bport/yokadi
 def do_a_remove(self, line):
     """Remove an alias"""
     if line in self.aliases:
         del self.aliases[line]
         aliases = Config.selectBy(name="ALIASES")[0]
         aliases.value = repr(self.aliases)
     else:
         tui.error(
             "No alias with that name. Use a_list to display all aliases")
示例#5
0
文件: taskcmd.py 项目: bport/yokadi
 def parser_t_purge(self):
     parser = YokadiOptionParser()
     parser.usage = "t_purge [options]"
     parser.description = "Remove old done tasks from all projects."
     parser.add_argument("-f", "--force", dest="force", default=False, action="store_true",
                       help="Skip confirmation prompt")
     delay = int(Config.byName("PURGE_DELAY").value)
     parser.add_argument("-d", "--delay", dest="delay", default=delay,
                       type=int, help="Delay (in days) after which done tasks are destroyed. Default is %d." % delay)
     return parser
示例#6
0
文件: aliascmd.py 项目: bport/yokadi
    def do_a_add(self, line):
        """Add an alias on a command
        Ex. create an alias 'la' for 't_list -a':
        a_add la t_list -a"""
        tokens = line.split()
        if len(tokens) < 2:
            raise BadUsageException(
                "You should provide an alias name and a command")
        name = tokens[0]
        command = " ".join(tokens[1:])
        self.aliases.update({name: command})
        try:
            aliases = Config.selectBy(name="ALIASES")[0]
        except IndexError:
            # Config entry does not exist. Create it.
            aliases = Config(name="ALIASES",
                             value="{}",
                             system=True,
                             desc="User command aliases")

        aliases.value = repr(self.aliases)
示例#7
0
文件: confcmd.py 项目: bport/yokadi
 def do_c_get(self, line):
     parser = self.parser_c_get()
     args = parser.parse_args(line)
     key = args.key
     if not key:
         key = "%"
     k = Config.select(AND(LIKE(Config.q.name, key), Config.q.system == args.system))
     fields = [(x.name, "%s (%s)" % (x.value, x.desc)) for x in k]
     if fields:
         tui.renderFields(fields)
     else:
         raise YokadiException("Configuration key %s does not exist" % line)
示例#8
0
文件: confcmd.py 项目: bport/yokadi
 def do_c_get(self, line):
     parser = self.parser_c_get()
     args = parser.parse_args(line)
     key = args.key
     if not key:
         key = "%"
     k = Config.select(
         AND(LIKE(Config.q.name, key), Config.q.system == args.system))
     fields = [(x.name, "%s (%s)" % (x.value, x.desc)) for x in k]
     if fields:
         tui.renderFields(fields)
     else:
         raise YokadiException("Configuration key %s does not exist" % line)
示例#9
0
文件: confcmd.py 项目: bport/yokadi
 def do_c_set(self, line):
     """Set a configuration key to value : c_set <key> <value>"""
     line = line.split()
     if len(line) < 2:
         raise BadUsageException("You should provide two arguments : the parameter key and the value")
     name = line[0]
     value = " ".join(line[1:])
     p = Config.select(AND(Config.q.name == name, Config.q.system == False))
     if p.count() == 0:
         tui.error("Sorry, no parameter match")
     else:
         if self.checkParameterValue(name, value):
             p[0].value = value
             tui.info("Parameter updated")
         else:
             tui.error("Parameter value is incorrect")
示例#10
0
文件: confcmd.py 项目: bport/yokadi
 def do_c_set(self, line):
     """Set a configuration key to value : c_set <key> <value>"""
     line = line.split()
     if len(line) < 2:
         raise BadUsageException(
             "You should provide two arguments : the parameter key and the value"
         )
     name = line[0]
     value = " ".join(line[1:])
     p = Config.select(AND(Config.q.name == name, Config.q.system == False))
     if p.count() == 0:
         tui.error("Sorry, no parameter match")
     else:
         if self.checkParameterValue(name, value):
             p[0].value = value
             tui.info("Parameter updated")
         else:
             tui.error("Parameter value is incorrect")
示例#11
0
文件: taskcmd.py 项目: bport/yokadi
 def parser_t_purge(self):
     parser = YokadiOptionParser()
     parser.usage = "t_purge [options]"
     parser.description = "Remove old done tasks from all projects."
     parser.add_argument("-f",
                         "--force",
                         dest="force",
                         default=False,
                         action="store_true",
                         help="Skip confirmation prompt")
     delay = int(Config.byName("PURGE_DELAY").value)
     parser.add_argument(
         "-d",
         "--delay",
         dest="delay",
         default=delay,
         type=int,
         help=
         "Delay (in days) after which done tasks are destroyed. Default is %d."
         % delay)
     return parser
示例#12
0
 def testAdd(self):
     self.cmd.do_a_add("l t_list")
     alias = Config.selectBy(name="ALIASES")[0]
     self.assertEqual(eval(alias.value)["l"], "t_list")