Exemple #1
0
async def gather_esi_requests(paths):
    async with aiohttp.ClientSession() as session:
        tasks = []
        for path in paths:
            tasks.append(async_get_esi_data(path, session))
        results = await asyncio.gather(*tasks)
        return results
Exemple #2
0
async def send_daily_setu(group_id: int, bot: Bot, setu_list: list):
    # await bot.send_group_msg(group_id=group_id,message='test')
    tasks = []
    for setu in setu_list:
        message = '[CQ:image,file={file}]'.format(file='file:///' +
                                                  setu.pic_file)
        tasks.append(bot.send_group_msg(group_id=group_id, message=message))
    await asyncio.gather(*tasks)
    time.sleep(2)
    await bot.send_group_msg(group_id=group_id,
                             message='今日份涩图已准备好,美好的一天从看涩图开始!')
    return
Exemple #3
0
def add_task():
    # Get the task to add
    task = txt_input.get()
    # Make sure the task is not empty
    if task != "":
        # Append to the list
        tasks.append(task)
        # Update the listbox
        update_listbox()
    else:
        tkinter.messagebox.showwarning("Warning you need to enter a task.")
    txt_input.delete(0, "end")
Exemple #4
0
async def distribute_work(url, requests, concurrency, results):
    """ Divide up the work into batches and collect the final results """
    queue = asyncio.Queue()

    for _ in range(requests):
        queue.put_nowait(url)

    tasks = []
    for i in range(concurrency):
        task = asyncio.create_task(worker(f"worker-{i+1}", queue, results))
        tasks.append(task)

    started_at = time.monotonic()
    await queue.join()
    total_time = time.monotonic() - started_at

    for task in tasks:
        task.cancel()

    return total_time
    def view_mine():
        #adds the lines to a list line by line
        tasks_view = open("tasks.txt", "r").readlines()
        counter = -1
        #used for a list of line to rewrite the folder
        tasks = []
        #used to track the usernames task numbers
        task_numbers = []
        for line in tasks_view:
            tasks.append(line)
            #splits each section in the line by a comma
            split_task = line.split(",")
            counter += 1
            #checks for the username in the line to print those tasks only
            if username == (split_task[0]):
                print(f"Task number: {counter}")
                print(
                    f"Task: {split_task[1]}\nassingned to: {split_task[0]}\nTask decription: {split_task[2]}"
                )  # split print for easier reading
                print(
                    f"Date assigned: {split_task[3]}\nDue date: {split_task[4]}\nTask Complete? {split_task[5]}\n"
                )
                task_numbers.append(counter)

        valid = False
        while valid == False:
            task_number = int(
                input(
                    "please enter the task number you would like to select to edit:"
                ))
            if task_number in task_numbers and split_task[5] == " No":
                valid = True
                #checks if the task is complete and wont allow it through if it is
            elif split_task[5] == " Yes":
                print("you cannot edit a completed task please try again.")
            elif task_number not in task_numbers:
                print(
                    "You have entered a task number not corresponding to your username."
                )
        #reads the line from file
        line = tasks_view[task_number]
        #splits each line into a list and print the items in the list in thier specific spot
        split_task = line.split(",")
        print((f"Task number: {task_number}"))
        #split print for easier reading
        print(
            f"Task: {split_task[1]}\nassingned to: {split_task[0]}\nTask decription: {split_task[2]}"
        )
        print(
            f"Date assigned: {split_task[3]}\nDue date: {split_task[4]}\nTask Complete? {split_task[5]}\n"
        )

        choice = input(
            "would you like to edit the task above to complete enter 'complete' or 'edit' to edit the task or '-1' to exit: "
        ).lower()
        #exits to main menu
        if choice == "-1":
            return

        if choice == "complete":
            #clears file to make a new edited version
            tasks_view = open("tasks.txt", "w")
            #deletes the part im editing from the list
            del tasks[task_number]
            for lines in tasks:
                #this will start at first line and end at the last line where it stops used to add soemthing at the end
                tasks_view.seek(0, 2)
                #writes the new info to the bottom of the task list
                tasks_view.write(lines)
                # this will start at first line and end at the last line where it stops used to add soemthing at the end
            tasks_view.seek(0, 2)
            tasks_view.write(
                f"{split_task[0]},{split_task[1]},{split_task[2]},{split_task[3]},{split_task[4]}, Yes"
            )
            #writes the new info to the bottom of the task file
            tasks_view.close()

        if choice == "edit":
            user_list = []
            tasks_view = open("tasks.txt", "w")
            del tasks[task_number]
            for lines in tasks:
                # this will start at first line and end at the last line where it stops used to add something at the end
                tasks_view.seek(0, 2)
                #writes the new info to the bottom of the task list
                tasks_view.write(lines)
            user_valid = False
            #this loops will not allow a username to be assigned to a task that doesnt exist
            while user_valid == False:
                new_username = input(
                    "please enter the username of the new person assigned the to the task: "
                )
                users = open("user.txt", "r")
                for line in users:
                    #generates the new folder for users
                    line_strip = line.strip("\n")
                    #stips the new line command that is there in the other file to allow for easier handeling
                    split_line = line_strip.split(",")
                    #splits the username from password
                    user_list.append(split_line[0])
                    #makes list of user names
                if new_username in user_list:
                    #checks the new username to see if it exist
                    due_date = input(
                        "please enter the new due date of the task E.g 10 Oct 2019: "
                    )
                    tasks_view.write(
                        f"{new_username},{split_task[1]},{split_task[2]},{split_task[3]},{due_date}, No"
                    )
                    tasks_view.close()
                    user_valid = True
                else:
                    print(
                        "assignment cannot be assigned to that user as it does not exist, please try again."
                    )

        print("tasks have be succsefully updated.")
Exemple #6
0
tasks = []

layout = [
    [sg.Text('ToDo')],
    [sg.InputText('Enter ToDo Item', key='todo_item'), sg.Button(button_text='Add', key="add_save")],
    [sg.Listbox(values=tasks, size=(40, 10), key="items"), sg.Button('Delete'), sg.Button('Edit')],
]

window = sg.indow('LList', layout, icon=r'logo.ico', finalize=True)
window['todo_item'].update(select=True)
window['todo_item'].Widget.bind("<FocusIn>", focus_control)

while True:  # Event Loop
    event, values = window.Read()
    if event == "add_save":
        tasks.append(values['todo_item'])
        window.FindElement('items').Update(values=tasks)
        window.FindElement('add_save').Update("Add")
        window['todo_item'].update('')

    elif event == "Delete":
        tasks.remove(values["items"][0])
        window.FindElement('items').Update(values=tasks)

    elif event == "Edit":
        edit_val = values["items"][0]
        tasks.remove(values["items"][0])
        window.FindElement('items').Update(values=tasks)
        window.FindElement('todo_item').Update(value=edit_val)
        window.FindElement('add_save').Update("Save")