def run(command, options, args): """Run the requested command. args is either a list of descriptions or a list of strings to filter by""" if command == "backend": subprocess.call(("sqlite3", db_path)) if command == "add": dp = pdt.Calendar() due = mktime(dp.parse(options.due)[0]) if options.due else None print "added tasks..." [Task(desc, due).add() for desc in args] return filters = args if len(args) else None rows = Query(filters, options).find() tasks = [Task(r["desc"], r["due"]) for r in rows] if command == "list": for t in tasks: print "\t *", t if command == "done": print "done with..." finished_tasks = [] for t in tasks: finished = t.done() if finished: finished_tasks.append(t) if not finished_tasks: return print "" print "finished tasks:" for t in finished_tasks: print "\t X", t if command == "remove": print "remove..." removed_tasks = [] for t in tasks: removed = t.remove() if removed: removed_tasks.append(t) if not removed_tasks: return print "" print "removed tasks:" for t in removed_tasks: print "\t RM", t
def printSchedule(printerArgs): taskifyTuple = lambda x: Task(*x) taskifyList = lambda x: list(map(taskifyTuple, x)) argAmount = len(printerArgs) if argAmount >= 1 and printerArgs[0] == 'help': OutputWriter.printerHelp() return 0 if argAmount >= 1: if printerArgs[0] not in ['week', 'weekly']: request = InputReader.checkAndPrepDateString(printerArgs[0]) if request is None: OutputWriter.wrongInputMessage(printerArgs[0], '-s') return 1 else: request = printerArgs[0] else: OutputWriter.printerOptions() request = InputReader.getPrinterRequest() if request == 'week': tasks = list( map(taskifyList, FileReader.fetchUpComingWeekTaskDictsAndTypes())) OutputWriter.printUpcomingWeek(tasks) elif request == 'weekly': tasks = list( map(taskifyList, FileReader.fetchWeeklyTaskDictsAndTypes())) OutputWriter.printWeeklyTasks(tasks) else: tasks = taskifyList(FileReader.fetchDateTaskDictsAndTypes(request)) OutputWriter.printRequestedDate(tasks) return 0
def add_task(self, id, command): print("[+] Task has been added") self.logger.info("[+] Task has been added") self.queue.put(Task(id, command)) ## ignore this '''
def createTask(creatorArgs): recurrProperArgs = ['recur', 'r', 'recurring'] oneOffProperArgs = ['once', 'o', 'oneoff'] argAmount = len(creatorArgs) silentMode = False if argAmount >= 1 and creatorArgs[0] == 'help': OutputWriter.creatorHelp() return 0 if argAmount >= 1 and creatorArgs[0] == 's': silentMode = True creatorArgs = creatorArgs[1:] argAmount = argAmount - 1 if argAmount == 0: isRecurring = InputReader.promptForIsRecurring() else: isRecurringCandidate = creatorArgs[0] if isRecurringCandidate in recurrProperArgs: isRecurring = True elif isRecurringCandidate in oneOffProperArgs: isRecurring = False else: OutputWriter.wrongInputMessage(creatorArgs[0], '-c') return 1 taskDets = creatorArgs[1:] argsOk, wrongArg = InputReader.verifyAndPrepRecurrArgs( taskDets) if isRecurring else InputReader.verifyAndPrepOneOffArgs( taskDets) if not argsOk: OutputWriter.wrongInputMessage(wrongArg, '-c') return 1 else: taskToAdd = Task( True, InputReader.createRecurring(taskDets)) if isRecurring else Task( False, InputReader.createOneOff(taskDets)) if isRecurring: if argAmount <= 1 or (silentMode or InputReader.askToAddRecurr(taskToAdd)): FileWriter.addRecurring(taskToAdd) else: if argAmount <= 1 or (silentMode or InputReader.askToAddOneOff(taskToAdd)): FileWriter.addOneOff(taskToAdd) return 0
def readStorageFile(path): taskList = [] errors = [] with open(argv[1], 'r') as storage: reader = csv.DictReader(storage) if (reader.fieldnames == csvHeader): for row in reader: newTask = Task(row["taskDesc"], row["timeList"], row["comments"]) taskList.append(newTask) else: errors.append("Incorrect header format in {}".format(path)) return taskList, errors
def processTaskSpec( self, task_spec ): task = Task.getTaskFromSpec( task_spec ) if task: return task.map( self.global_comm, self.task_comm ) return -1
def deleteOneOffWithName(taskName): task = Task(False,fetchOneOffTaskWithName(taskName)) deleteNameFromFile(taskName,oneOffTasksFile) deleteOneOffCron(task) deleteOneOffDeleter(task)
def deleteRecurrWithName(taskName): task = Task(True,fetchRecurrTaskWithName(taskName)) deleteNameFromFile(taskName,recurringTasksFile) deleteRecurrCrons(task)
def __init__(self, name): Task.__init__(self, name)
def newTask(args, state): state["tasks"].append(Task(args)) startTask(-1, state) return False