Ejemplo n.º 1
0
 def setUp(self):
     date = dt.strptime('2018-01-01', '%Y-%m-%d')
     classes.Task.tasks = [
         classes.Task('Task1', date, None, None),
         classes.Task('Task2', date, 7, None),
         classes.Task('Task2', dt.now(), {'mon', 'fri'}, None)
     ]
     self.completed = {'tasks': [], 'goals': []}
Ejemplo n.º 2
0
 def setUp(self):
     classes.Task.tasks = [
         classes.Task('Task1', 'date', None, None),
         classes.Task('Task2', 'date', None, None)
     ]
     classes.Goal.goals = [
         classes.Goal('Goal1', None, None),
         classes.Goal('Goal2', None, None)
     ]
Ejemplo n.º 3
0
 def setUp(self):
     over = dt.strptime('2017-12-01', '%Y-%m-%d')
     self.date = dt.strptime('2018-01-01', '%Y-%m-%d')
     future = dt.strptime('2018-01-05', '%Y-%m-%d')
     classes.Task.tasks = [
         classes.Task('Task1', over, None, None, num=1),
         classes.Task('Task2', over, 2, None, num=2),
         classes.Task('Task3', self.date, 7, None, num=3),
         classes.Task('Task4', future, None, None, num=4)
     ]
     self.completed = {'tasks': [], 'goals': []}
Ejemplo n.º 4
0
def create_task(id_server):
  choice = ''
  while choice != 'q':

    choice = get_task_choice()
    display_title_bar()
    if choice == '1': 
         task_name = input("Input name of task: ")
         pg_user = input("Input postgreSQL username:[postgres] ")
        
         if pg_user=="":
             pg_user="******"
         print("\nList of existing databases\n")
         get_database_info(pg_user)
         source = input("Enter a comma-separated [,] list of required databases: ")
         dest = input("Enter a destination path: ")
         sel_day = input("Enter days of the week when to run a task: ")
         task_time = input("Enter time when to run a task: example 22:00:00 ")
         next_start = mics.get_next_time(sel_day, task_time)
         time_live = input("Enter the number of days to store the backup: ")
         extension = "zip"
         password = pg_user
         exeption = "psql"
         task = cs.Task(task_name,source,dest,sel_day,task_time,id_server,next_start,time_live,extension,password,exeption)
         sql_function.add_full_task(task)
         print("\nTask successfully added, next start time at %s\n" %next_start)
    elif choice == '2':
         print("\nThanks for playing. Bye.")
Ejemplo n.º 5
0
    def add_entry():
        header('Add a Task')
        while True:
            try:
                task_date = datetime.datetime.strptime(
                    input('\n Enter task date as MM/DD/YYYY: '), '%m/%d/%Y')
                task_date = task_date.strftime('%m/%d/%Y')
                break
            except ValueError:
                header('Add a Task')
                print('\n Please enter a valid date.')
        task_name = input('\n What is the task name?: ')
        while len(task_name) > 40:
            header('Add a Task')
            print('\n Enter task date as MM/DD/YYYY: {}'.format(task_date))
            task_name = input(
                '\n I\'m sorry your task name is too long. Try again: ')
        try:
            time_spent = input(
                '\n How many minutes were spent on this task?: ')
            if int(time_spent) > 999:
                raise ValueError
        except ValueError:
            header('Add a Task')
            print('\n Enter task date as MM/DD/YYYY: {}'.format(task_date))
            print('\n What is the task name?: {}'.format(task_name))
            return '\n Minutes spent must be an integer less than 1,000. Try again: '

        print('\n-----------(Optional)-----------')
        notes = input(' Enter any notes: ')
        task = classes.Task(task_date, task_name, time_spent, notes)
        task.write_to_file()
        clear()
        return "New entry was added successfully!"
Ejemplo n.º 6
0
def add_task(extra, current_date):
    """Instantiate a new task with optional attributes."""
    opt_date = current_date
    opt_repeat = None
    opt_tags = None

    keyword_order = re.findall(r'\s(\w+)=', extra)
    keyword_values = re.split(r'\s\w+=', extra)
    task = keyword_values.pop(0)
    values = zip(keyword_order, keyword_values)

    for value in values:
        if value[0] in ('date', 'd'):
            opt_date = dt.strptime(value[1], '%Y-%m-%d')

        elif value[0] in ('repeat', 'r'):
            if value[1].isnumeric():
                opt_repeat = int(value[1])
            else:
                value_list = value[1].split(',')
                to_check = set([day.strip().lower() for day in value_list])
                for day in to_check:
                    if day not in ('mon', 'tue', 'wed', 'thu', 'fri', 'sat',
                                   'sun'):
                        print("  Repeat days not in three letter format")
                    else:
                        opt_repeat = to_check

        elif value[0] in ('tag', 't'):
            if ',' in value[1]:
                opt_tags = [tag.strip() for tag in value[1].split(',')]
            else:
                opt_tags = [value[1]]

    cl.Task(task, opt_date, opt_repeat, opt_tags)
Ejemplo n.º 7
0
def get_task_settings(id_task):
    connection = pypyodbc.connect(cfg.connection_string)
    cursor = connection.cursor()
    SQLCommand = ("Select * from task where id_task =?")
    cursor.execute(SQLCommand, [id_task])
    for row in cursor:
        task = cs.Task(row[1], row[2], row[3], row[6], row[7], row[9], row[5],
                       row[11], row[12], row[13], row[16])

    cursor.close()
    connection.close()
    return task
Ejemplo n.º 8
0
 def setUp(self):
     classes.Task.tasks = [classes.Task('Retrieve', 'date', None, None)]
     classes.Goal.goals = [classes.Goal('Goal Retrieve', None, None)]
     self.completed = {'tasks': [], 'goals': []}
     self.deleted = {'tasks': [], 'goals': []}
Ejemplo n.º 9
0
 def setUp(self):
     classes.Task.tasks = [
         classes.Task('Task1', '2018-01-01', None, None),
         classes.Task('Task2', '2018-01-01', None, None)
     ]
     self.deleted = {'tasks': [], 'goals': []}
Ejemplo n.º 10
0
 def setUp(self):
     date = dt.strptime('2018-01-01', '%Y-%m-%d')
     self.task = classes.Task('Title', date, None, None)