Exemplo n.º 1
0
def submenu(conn, cipher):
    print("**[1] Update; [2] Delete [3]Copy to clip board**")
    option = input("Enter above option numnber or any other keys to return: ")
    if option == '1':
        pwdid = input("What is the id of the password need to be updated? ")
        pwdid = int(pwdid)
        pwd = input(
            "What is the new password?(enter 'a' for auto generated password) "
        )
        if pwd == 'a':
            pwd = autopwd.autopwd()
        pwd = crypt.encrypt_pwd(cipher, pwd)
        db.update_pwd_by_id(conn, pwd, pwdid)
        print("Password updated")
    elif option == '2':
        pwdid = input("Enter the id of the password need to delete: ")
        pwdid = int(pwdid)
        db.delete_task(conn, pwdid)
        print("Password deleted")
    elif option == '3':
        pwdid = input("Enter the id of the password need to be copied: ")
        pwdid = int(pwdid)
        rows = db.select_by_id(conn, pwdid)
        for row in rows:
            pwd = crypt.decrypt_pwd(cipher, row[3])
            pyperclip.copy(pwd)
        print("Password copied to clipboard")
def handle_delete_task(description):
    if description is None:
        return question(render_template("no_desc"))\
            .reprompt(render_template("reprompt"))

    matches = search_for_task(description)
    descriptions = list(map(lambda task: task['description'], matches))
    if len(matches) == 0:
        return statement(render_template("no_matches"))
    if len(matches) > 1:
        if len(set(descriptions)) == 1:
            # All descriptions are identical; just delete them all
            for task in matches:
                db.delete_task(session.user.userId, task['task_id'])
            return statement(
                render_template("deleting_tasks", descriptions=descriptions))
        else:
            return statement(
                render_template("more_than_one_match",
                                num=len(matches),
                                descriptions=str([
                                    match['description'] for match in matches
                                ])))
    else:
        match = matches[0]
        db.delete_task(session.user.userId, match['task_id'])
        return statement(
            render_template("deleting_task", description=match['description']))
Exemplo n.º 3
0
def remove_task_item():
    item_id = tree.item(tree.selection()[0], "text")
    db.delete_task(item_id)
    tree.delete(item_id)

    task_name.set("")
    priority_of_task.set("")
    category.set("")
    deadline.set("")
    is_done.set(False)

    create_button["state"] = "normal"
    change_button["state"] = "disabled"
Exemplo n.º 4
0
def stuff_callback(query):
    print(query.data.split("_"))
    task = db.get_task(query.data.split("_")[1])
    #добалвяем баланс пользователю
    #db.add_balance(query.message.from_user.id, task[1] )
    #уменьшаем у работодателя
    db.subs_balance(task[2], task[1])
    bot.send_message(task[2], "Задание {} выполнено".format(task[0]))
    #убираем заадние
    db.delete_task(task[0])
    bot.send_message(
        query.message.chat.id,
        "Задание успешно выполнено! На ваш счет зачислено {} CWD".format(
            task[1]))
Exemplo n.º 5
0
    def cycle(self):
        while(True):
            time.sleep(10)
            now_time = datetime.now()
            task = db.get_top_task()
            if len(task) > 0:

                task_date = datetime.strptime(task[0], '%Y-%m-%d %H:%M:%S')
                task_name = task[2]
                task_options = task[3]

                if now_time > task_date:
                    if now_time > task_date + timedelta(hours=1):
                        db.delete_task(task_name)
                    else:
                        if task[1] == 0:
                            print("[INFO] Running task: ", task_name)
                            db.setran_task(task_name)
                            self.deploy(task_options)
Exemplo n.º 6
0
def delete(card_id):
    if request.method == 'POST':
        username = request.headers['Referer'].split('/')[-1]
        delete_task(username, card_id)
    return 'ITS OK'
Exemplo n.º 7
0
def delete_entry(task_id):
    db.delete_task(task_id)
    flash('The task was marked as deleted.')
    return redirect(url_for('tasks'))
Exemplo n.º 8
0
def delete():
    if delete_task(name=request.get_json(silent=True)["name"]):
        d = {"status": "DELETED"}
    else:
        d = {"status": "FAIL", "desc": "Not Found"}
    return jsonify(d)
Exemplo n.º 9
0
def delete(id):
    username = session['human']
    delete_task(username, id)
    return redirect(url_for('user_page', name=username))
Exemplo n.º 10
0
def deploy():
    """
      - Allows for creation of timed deploy tasks
      - Needs to choose a time, userlist and vapp
      - Will use Catalog.getTemplates() (validate template immediately)

    """
    form = DeployForm(dm)
    error = None
    task_name = "Create a new task..."
    task_selected = ("", "", "", ("", ""), "")
    error = None

    # If POST, Add, Edit, or Delete
    if request.method == 'POST':
        if "action" in request.form:
            action = request.form["action"]
            (error, result) = form.validate_on_submit()
            if "name" in request.form and "vapp" in request.form:
                task_selected = ("", "", request.form["name"], {
                    "vapp_name": request.form["vapp"]
                }, "")
            if result and action == "Add":
                error = form.add_valid_task()
                if not error:
                    task_name = request.form["name"]
                    flask.flash("Task " + task_name + " added!")
            elif result and action == "Update":
                error = form.edit_valid_task()
                if not error:
                    task_name = request.form["name"]
                    flask.flash("Task " + task_name + " edited!")
            elif action == "Delete":
                if "name" in request.form:
                    error = db.delete_task(request.form["name"])
                    if not error:
                        flask.flash("Task deleted!")
            else:
                task_name = request.form["name"]

    # Grab updated task list after possible post
    tasks = db.get_deploys()
    task_queue, task_history = [], []
    for task in tasks:
        if task[4] == 0:
            task_queue.append(task)
        else:
            if len(task_history) < 5:
                task_history.append(task)
            else:
                db.delete_task(task[2])

    # If get, either display task requested or new deploy form
    if "task" in request.args or task_name != "Create a new task...":
        if "task" in request.args:
            task_name = request.args["task"]
        for task in tasks:
            if task_name == task[2]:
                task_selected = task
        if task_selected[0] == "":
            task_name = "Create a new task..."
            error = "Sorry, specified task does not exist."

    return render_template('deploy.html',
                           form=form,
                           task_queue=task_queue,
                           task_history=task_history,
                           task_name=task_name,
                           task_selected=task_selected,
                           error=error)
Exemplo n.º 11
0
 def finish(self):
     db.delete_task(self.id)
     self.button.destroy()
     self.label.destroy()
Exemplo n.º 12
0
import logging
import sys

from telebot import types

from db import delete_task
from main import bot

logging.basicConfig(filename="send_message.log", level=logging.INFO)


def send_message(id, text):  # Функция отправляет сообщения в чат пользователю
    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(
        types.InlineKeyboardButton(text='Напомнить через 15 минут',
                                   callback_data=' через 15 минут'))
    keyboard.add(
        types.InlineKeyboardButton(text='Напомнить через час',
                                   callback_data=' через час'))
    keyboard.add(
        types.InlineKeyboardButton(text='Напомнить завтра',
                                   callback_data=' завтра'))
    bot.send_message(id, text, reply_markup=keyboard)
    logging.info(id)
    logging.info(text)


if __name__ == "__main__":
    send_message(sys.argv[1], sys.argv[2])
    delete_task(uid=sys.argv[3])