Beispiel #1
0
def undo(update, context):
    task_ids = db.get_task_ids_from_context(update.effective_user, context)

    for task_id in task_ids:
        task = db.get_task(update.effective_user, task_id)
        task.undo()
        db.update_task(update.effective_user, task)

    for id in task_ids:
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text='undone task: ' +
                                 str(db.get_task(update.effective_user, id)))
Beispiel #2
0
def gettask(id):
    get_json = get_task(id)
    if get_json:
        result = jsonify(get_json)
    else:
        result = "該当idのデータはありません"
    return result
Beispiel #3
0
def api_tasks(task_id):
    """ Get task by id
    """
    # try to get task with completions first
    task_data = db.get_completion(task_id)
    task_data = db.get_task(task_id) if task_data is None else task_data
    return make_response(jsonify(task_data), 200)
Beispiel #4
0
def index():
    """ Main page: index.html
    """
    global c

    # load config at each page reload (for fast changing of config/input_path/output_path)
    c = load_config()

    # find editor files to include in html
    editor_dir = c['editor']['build_path']
    editor_js_dir = os.path.join(editor_dir, 'js')
    editor_js = ['/static/editor/js/' + f for f in os.listdir(editor_js_dir) if f.endswith('.js')]
    editor_css_dir = os.path.join(editor_dir, 'css')
    editor_css = ['/static/editor/css/' + f for f in os.listdir(editor_css_dir) if f.endswith('.css')]

    # load editor config from XML
    label_config_line = config_line_stripped(open(c['label_config']).read())

    # task data: load task or task with completions if it exists
    task_data = None
    task_id = request.args.get('task_id', None)

    if task_id is not None:
        task_data = db.get_completion(task_id)
        if task_data is None:
            task_data = db.get_task(task_id)

    return flask.render_template('index.html', config=c, label_config_line=label_config_line,
                                 editor_css=editor_css, editor_js=editor_js,
                                 task_id=task_id, task_data=task_data)
Beispiel #5
0
def buy_callback(query):
    print(query.data.split("_"))
    task = db.get_task(query.data.split("_")[1])
    task_text = """Задание №{}
	Подпишитесь на канал - {} и получите {} CWD от {}"""
    bot.send_message(query.message.chat.id,
                     task_text.format(task[0], task[3], task[1], task[2]),
                     reply_markup=kb.check(task[0]))
Beispiel #6
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]))
Beispiel #7
0
    def run(self):
        signal.signal(signal.SIGINT, (lambda signum, frame: self.stop()))

        while not self.is_stopped:
            try:
                tasks = db.get_task()
                if not tasks:
                    continue

                for track_id, url_disk, in tasks:
                    try:
                        _, file_name = os.path.split(url_disk)
                        fp = self.get_fingerprint(file_name)
                        for index, fp_band in enumerate(fp):
                            HEngine.write_hashes_all(fp_band, track_id)
                            print(file_name, len(fp_band))
                    except Exception as e:
                        db.mark_task_as(track_id, 'ps_error')
                        print(e)

            except Exception as e:
                print(e)
Beispiel #8
0
    def run(self):
        signal.signal(
            signal.SIGINT, (lambda signum, frame: self.stop()))

        while not self.is_stopped:
            try:
                tasks = db.get_task()
                if not tasks:
                    continue

                for track_id, url_disk, in tasks:
                    try:
                        _, file_name = os.path.split(url_disk)
                        fp = self.get_fingerprint(file_name)
                        for index, fp_band in enumerate(fp):
                            HEngine.write_hashes_all(fp_band, track_id)
                            print(file_name, len(fp_band))
                    except Exception as e:
                        db.mark_task_as(track_id, 'ps_error')
                        print(e)

            except Exception as e:
                print(e)