コード例 #1
0
def text_to_cron_object(text):

    if text.startswith('@yearly') or text.startswith('@annually'):
        text = text.replace('@yearly', '0 0 1 1 *', 1)
        text = text.replace('@annually', '0 0 1 1 *', 1)

    elif text.startswith('@monthly'):
        text = text.replace('@monthly', '0 0 1 * *', 1)

    elif text.startswith('@weekly'):
        text = text.replace('@weekly', '0 0 * * 0', 1)

    elif text.startswith('@daily') or text.startswith('@midnight'):
        text = text.replace('@daily', '0 0 * * *', 1)
        text = text.replace('@midnight', '0 0 * * *', 1)

    elif text.startswith('@hourly'):
        text = text.replace('@hourly', '0 * * * *', 1)

    cron = text.split()
    if cron[0] == '@reboot':
        t = Task(action=' '.join(cron[1:]), reboot=True)
    else:
        try:
            t = Task(minute=cron[0],
                     hour=cron[1],
                     day_of_month=cron[2],
                     month=cron[3],
                     day_of_week=cron[4],
                     action=' '.join(cron[5:]))
        except Exception as e:
            print "{} is not a valid cron entry.\nDetails: {}".format(text, e)
            return e

    return t
コード例 #2
0
ファイル: controller.py プロジェクト: kbhagi/TodoApp
    def start_program(self, **kwargs):
        choice = kwargs.get("choice")
        print("choice ")
        print(choice)
        while choice.lower() != "q":
            print("Adding a Task")
            # choice = input(">")
            if choice == "1":
                task_name = self.view.get_input(input_name="task name: ")
                task_description = self.view.get_input(
                    input_name="task description: ")
                task_date = datetime.date.today().__str__()
                task_status = self.view.get_input(input_name="task status: ")
                task = Task(task_name, task_description, task_date,
                            task_status)
                tasks_list = [task]
                self.add_tasks(tasks_list=tasks_list)
                break

            elif choice == "2":
                print("Updating a Task")
                task_name = self.view.get_input(input_name="task name: ")
                task_description = self.view.get_input(
                    input_name="task description: ") or "default"
                print("task description")
                print(task_description)
                task_date = "default"  #datetime.date.today().__str__()
                task_status = self.view.get_input(
                    input_name="task status: ") or "default"
                print(task_status)
                task = Task(task_name, task_description, task_date,
                            task_status)
                print("task log_date")
                print(task.log_date)
                result = self.db.update_task(task)
                print("result of updating at ask")
                print(result)
                break

            elif choice == "3":
                print("Searching a task")

                break

            elif choice == "4":
                print("Deleting a Task")
                break

            else:
                print("Sorry, I didnt recognize that option")
                print("none of option matched")
                self.view.display_menu()
                choice = self.view.get_input(input_name="choice")
        print("Thank you! Shutting down.")
        sys.exit
        print("exiting start_program")
コード例 #3
0
ファイル: db_connect.py プロジェクト: yonjuuni/cron-manager
def get_cron_list():
    cursor = collection.find()
    if cursor:
        res = []
        for cron in list(cursor):
            if cron.get('action'):
                if cron.get('reboot'):
                    res.append(
                        Task(action=cron['action'],
                             reboot=True,
                             _id=cron['_id']))
                else:
                    res.append(
                        Task(cron['minute'], cron['hour'],
                             cron['day_of_month'], cron['month'],
                             cron['day_of_week'], cron['action'], cron['_id']))
        return res
コード例 #4
0
ファイル: DB.py プロジェクト: kbhagi/TodoApp
 def search_task(self, task):
     existing_tasks = self.read_file()
     print("tasks read")
     print(existing_tasks)
     for index, task_data in enumerate(existing_tasks):
         if task_data:
             items = task_data.split(",")
             if items:
                 print("items")
                 print(items)
                 taskobject = Task(items[0], items[1], items[2], items[3])
             if taskobject.name == task.name:
                 print("Task found at :", index)
                 return existing_tasks, index, taskobject
     print("Task not found ")
コード例 #5
0
ファイル: dao.py プロジェクト: xpao24/crawler
def select(state):
    db = connection()
    cursor = db.cursor()
    sql = "select * from task where state = '%d'" % (state)
    try:
        cursor.execute(sql)
        row = cursor.fetchone()
        if row == None:
            task = None
        else:
            task = Task(id=row[0],
                        priority=row[1],
                        type=row[2],
                        state=row[3],
                        link=row[4],
                        avaliable_time=row[5],
                        start_time=row[6],
                        end_time=row[7])
    except:
        print "Error : unable to fetch daba"
    db.close()
    return task
コード例 #6
0
ファイル: user_model.py プロジェクト: tes1oner/pyutils
 def tasks(self):
     myTasks = Task.where(['id_user = '+str(self._id)])
     return myTasks
コード例 #7
0
ファイル: service.py プロジェクト: Ekula/uSquam_backend
    def findWhere(self, **kwargs):

        return Task.objects(**kwargs)
コード例 #8
0
ファイル: service.py プロジェクト: Ekula/uSquam_backend
    def insert(self, in_task):
        task = Task()

        task.name = in_task['name']
        task.requester_id = in_task['requester_id']
        task.time_indication = in_task['time_indication']
        task.reward = in_task['reward']
        task.data_collection_id = in_task['data_collection_id']

        if 'coordinates' in in_task:
            task.coordinates = in_task['coordinates']

        if 'active' in in_task:
            task.active = in_task['active']

        for item in in_task['questions']:
            question = Question()
            if 'question_data_idx' in item:
                question.question_data_idx = item['question_data_idx']
            question.message = item['message']
            if 'expected_type' in item:
                question.expected_type = item['expected_type']
            if 'suggestions' in item:
                question.suggestions = item['suggestions']
            task.questions.append(question)
        task.save()
        return task
コード例 #9
0
ファイル: list_crawler.py プロジェクト: xpao24/crawler
def build_task(url):
    task = Task(id=None,priority=0,type=1,state=0,link=url,avaliable_time=now(),start_time=None,end_time=None)
    return task
コード例 #10
0
def store(url):
    print url
    task = Task(id=None,priority=0,type=1,state=0,link=url,\
                avaliable_time=now(),start_time=None,end_time=None)
    dao.insert(task)