コード例 #1
0
def new_dispute(message):
    cursor = db.cursor()
    text = str(message.text).replace('/new_dispute', '').strip()
    caption = text.split('\n')[0]
    content = ''
    try:
        content = text.split('\n', 1)[1]
    except IndexError:
        pass
    if len(content) + len(caption) > 160:
        bot.send_message(message.chat.id, 'Нельзя создавать вопрос длиной более 160 символов')
        cursor.close()
        return

    if caption:
        cursor.execute(
            "insert into Dispute(user_id,caption,content) VALUES  ({0},'{1}','{2}')".format(message.from_user.id,
                                                                                            caption, content))

        sent_message = bot.send_message(message.chat.id, 'Вопрос "{0}" создан'.format(caption),
                                        reply_markup=markup_common)
        connect_message(message, dispute_id=cursor.lastrowid)
        connect_message(sent_message, dispute_id=cursor.lastrowid)

        cursor.execute('update User set state=state||? WHERE id=?',
                       ['d{}/'.format(cursor.lastrowid), message.from_user.id])
        db.commit()

    cursor.close()
コード例 #2
0
def open_command(message):
    cursor = db.cursor()
    text = str(message.text.strip())

    cursor.execute('select dispute_id, feedback_id from Messages WHERE chat_id={0} and message_id={1} limit 1'.format(
        message.chat.id, message.reply_to_message.message_id))
    rows = cursor.fetchall()
    if not rows:
        bot.send_message(message.chat.id, 'Ой! Вы что-то перепутали, тут не на что отвечать!',
                         reply_markup=markup_common)
        cursor.close()
        return

    dispute_id, feedback_id = rows[0]
    if dispute_id is not None:
        step_type = 'd'
    else:
        cursor.execute('select is_answer from Feedback where id=?', [feedback_id])
        is_answer, = cursor.fetchall()[0]
        if is_answer:
            step_type = 'a'
        else:
            step_type = 'c'
    item_id = dispute_id or feedback_id
    cursor.execute('update User set state=state||? WHERE id=?',
                   ['{}{}/'.format(step_type, item_id), message.from_user.id])
    db.commit()
    cursor.close()
    send_stuff_by_state(message.from_user.id)
コード例 #3
0
ファイル: modelworker.py プロジェクト: mtpain/vwadaptor
def run_model(modelrun_id):
    modelrun = db.query(ModelRun).get(modelrun_id)
    try:
        tmp_dir = os.path.join('/tmp/modelruns/',str(modelrun.id))
        os.makedirs(tmp_dir)

        modelrun.progress_state = PROGRESS_STATES['RUNNING']
        db.commit()

        kwargs = {'db':db,'modelrun_id':modelrun.id}

        modelrunner = model_runners[modelrun.model_name]

        input_resource_map = modelrunner.get_resource_map()
        input_map = resolve_input_map(tmp_dir,input_resource_map,modelrun.resources)
        output_resource_map = modelrunner.get_resource_map(type='outputs')
        output_map = resolve_output_map(tmp_dir,output_resource_map)

        kwargs.update(input_map)
        kwargs.update(output_map)
        module, method = modelrunner.get_model_runner()
        method(event_emitter=ee,**kwargs)

        # save the output resources now
        resources = create_output_resources(modelrunner,output_map)

        modelrun.resources.extend(resources)
        modelrun.progress_state=PROGRESS_STATES['FINISHED']
    except:
        modelrun.progress_state=PROGRESS_STATES['ERROR']
    db.commit()

    # clean up
    shutil.rmtree(tmp_dir)
def post_question_md():
    if request.method == 'GET':
        return render_template('post_blog_md.html')
    if request.method == 'POST':
        try:
            cur = db.cursor()
            author = session.get('user_id')
            title = request.form.get('title')
            content = request.form.get('html_content')
            print(request.values)
            # 如果未登录 则跳转到登录页面
            if author is None:
                return redirect(url_for('login'))
            date = time.strftime("%Y-%m-%d %H:%M:%S")
            sql = "select max(bno) from SDWZCS.blog"
            db.ping(reconnect=True)
            cur.execute(sql)
            result = cur.fetchone()[0]
            if result is None:
                bno = 1
            else:
                bno = int(result) + 1
            sql = "insert into blog(bno, title, content, md_or_fwb, creatTime, author) VALUES ('%s','%s','%s','%s','%s','%s')" % (
                bno, title, content, '1', date, author)
            db.ping(reconnect=True)
            cur.execute(sql)
            db.commit()
            cur.close()

            return redirect(url_for('technology_Blog'))
        except Exception as e:
            raise e
コード例 #5
0
 def on_delete(self, req, resq, id):
     customer = db.query(Customer).filter(Customer.id == id).first()
     if customer is None:
         raise falcon.HTTPNotFound()
     db.delete(customer)
     db.commit()
     db.close()
def post_questions():
    if request.method == 'GET':
        return render_template('post_question_fwb.html')
    else:
        try:
            cur = db.cursor()
            email = session.get('user_id')
            title = request.form.get('title')
            content = request.form.get('editorValue')
            date = time.strftime("%Y-%m-%d %H:%M:%S")
            sql = "select max(formula_id) from SDWZCS.formula_post"
            db.ping(reconnect=True)
            cur.execute(sql)
            result = cur.fetchone()[0]
            if result is None:
                formula_id = 1
            else:
                formula_id = int(result) + 1
            sql = "insert into SDWZCS.formula_post(SDWZCS.formula_post.formula_id, SDWZCS.formula_post.author, " \
                  "SDWZCS.formula_post.title,SDWZCS.formula_post.creat_time) values ('%s','%s','%s','%s')" % (
                formula_id,email,title,date)
            db.ping(reconnect=True)
            cur.execute(sql)
            db.commit()
            sql = "insert into question_detail(formula_id, qno, content, datetime, author) VALUES ('%s','1','%s','%s','%s')" % (
                formula_id, content, date, email)
            db.ping(reconnect=True)
            cur.execute(sql)
            db.commit()
            cur.close()

            return redirect(url_for('formula'))
        except Exception as e:
            raise e
def personal_change():
    if request.method == 'GET':
        cur = db.cursor()
        username_get = session.get('user_id')
        sql = "select email,nickname,phone from SDWZCS.userInformation where email = '%s'" % username_get
        db.ping(reconnect=True)
        cur.execute(sql)
        userinformation = cur.fetchone()
        email = userinformation[0]
        phone = userinformation[2]
        nickname = userinformation[1]
        return render_template('personal_change.html',
                               email=email,
                               phone=phone,
                               nickname=nickname)
    else:
        cur = db.cursor()
        username_get = session.get('user_id')
        nickname = request.form.get('nickname')
        email = request.form.get('email')
        phone = request.form.get('phone')
        sql = "update userInformation set SDWZCS.userInformation.nickname = '%s', SDWZCS.userInformation.phone = '%s' where SDWZCS.userInformation.email = '%s'" % (
            nickname, phone, username_get)
        try:
            db.ping(reconnect=True)
            cur.execute(sql)
            db.commit()
            return redirect(url_for('personal'))
        except Exception as e:
            raise e
コード例 #8
0
def run_model(modelrun_id):
    modelrun = db.query(ModelRun).get(modelrun_id)
    try:
        tmp_dir = os.path.join('/tmp/modelruns/',str(modelrun.id))
        os.makedirs(tmp_dir)

        modelrun.progress_state = PROGRESS_STATES['RUNNING']
        db.commit()

        kwargs = {'db':db,'modelrun_id':modelrun.id}

        modelrunner = model_runners[modelrun.model_name]

        input_resource_map = modelrunner.get_resource_map()
        input_map = resolve_input_map(tmp_dir,input_resource_map,modelrun.resources)
        output_resource_map = modelrunner.get_resource_map(type='outputs')
        output_map = resolve_output_map(tmp_dir,output_resource_map)

        kwargs.update(input_map)
        kwargs.update(output_map)
        module, method = modelrunner.get_model_runner()
        method(event_emitter=ee,**kwargs)

        # save the output resources now
        resources = create_output_resources(modelrunner,output_map)

        modelrun.resources.extend(resources)
        modelrun.progress_state=PROGRESS_STATES['FINISHED']
    except:
        modelrun.logs=traceback.format_exc()
        modelrun.progress_state=PROGRESS_STATES['ERROR']
    db.commit()

    # clean up
    shutil.rmtree(tmp_dir)
コード例 #9
0
def submit_paper():
    sum = 0
    data = request.form['answers']
    # for i in range(1,47):
    #     if (dict(data).get('{}'.format(i))):
    #         print(data[i])
    dict_data = dict(eval(data))
    for i in range(1, 46 * paper_id + 1):
        if dict_data.get('{}'.format(i)):
            sql = 'select id,answer,q_value from questions where id = %s and paper_id = %s'
            cursor.execute(sql, (i, paper_id))
            database = cursor.fetchone()
            trueAnswer = database.get('answer')
            yourAnser = dict_data.get('{}'.format(i))
            if trueAnswer == yourAnser:
                sum = sum + float(database.get('q_value'))
                # print('{}'.format(i),cursor.fetchone().get('answer'),dict_data.get('{}'.format(i)))

    sql = 'select * from docx where id = %s'
    cursor.execute(sql, (paper_id, ))
    temp = cursor.fetchone()
    paper_name = temp.get('paper_name')

    sql = 'insert into user_grade (user_id, paper_id, exam_grade, create_time, paper_name,user_name) values (%s,%s,%s,now(), %s, %s)'
    cursor.execute(
        sql, (session.get('user_id'), paper_id, sum, paper_name, user_name))
    db.commit()
    return str(sum)
コード例 #10
0
ファイル: common.py プロジェクト: yue123161/BotMiner-x
    def insert_single_file(filename):
        pcap = rdpcap(filename)[TCP]
        for i in xrange(len(pcap)):
            length = len(pcap[i])
            try:
                timestamp = pcap[i].time - int(
                    pcap[i].time) / 100 * 100  # below 100s
                ip_src = pcap[i]['IP'].src
                ip_dst = pcap[i]['IP'].dst
                port_src = str(pcap[i]['IP'].sport)
                port_dst = str(pcap[i]['IP'].dport)
                apanel_cluster(pcap[i], group_id)  # a-panel聚类
            except:
                continue
            """
            <Ether  dst=00:23:89:3a:8b:08 src=00:0e:c6:c2:5f:d8 type=0x800 |<IP  version=4L ihl=5L tos=0x0 len=40 id=34019 flags=DF frag=0L ttl=64 proto=tcp chksum=0x9920 src=172.29.90.176 dst=42.156.235.98 options=[] |<TCP  sport=47571 dport=https seq=3681001345 ack=1822908669 dataofs=5L reserved=0L flags=A window=65280 chksum=0x1ce7 urgptr=0 |>>>
            """
            if bin(pcap[i][TCP].flags)[-1] == '1':
                flag = 'Fin'
            elif bin(pcap[i][TCP].flags)[-2] == '1':
                flag = 'Syn'
            else:
                flag = ''

            sql = "INSERT INTO Packets(GROUP_ID, TIMESTAMP,LENGTH,IP_SRC,IP_DST,PORT_SRC,PORT_DST,FLAG)VALUES (" + group_id + "," + str(
                timestamp
            ) + "," + str(
                length
            ) + ", '" + ip_src + "','" + ip_dst + "', '" + port_src + "', '" + port_dst + "', '" + flag + "')"
            cursor.execute(sql)
            db.commit()

        if delete:
            os.remove(filename)
コード例 #11
0
def turn_admin(user_id):
    user = get_by_id(user_id)
    print(f'User before change status {user["is_admin"]}')
    user['is_admin'] = False if user['is_admin'] == True else True
    print(f'User after change status {user["is_admin"]}')
    commit()
    return 'ok', 200
コード例 #12
0
def update_pet_resource():
    val = request.json
    for column in request.json.keys():
        if column != 'id':
            sql = "update pets set {0} = '{1}' where id = {2};" .format(column, val[column], val['id'])
            cur.execute(sql)
            db.commit()
    return jsonify({'Success': True})
コード例 #13
0
def search_message(message):
    cursor = db.cursor()
    text = str(message.text).replace('/search', '').strip().lower().replace('/', '\\x2f')
    cursor.execute('update User set state=state||? WHERE id=?',
                   ['s({})/'.format(text), message.from_user.id])
    db.commit()
    cursor.close()
    send_stuff_by_state(message.from_user.id)
コード例 #14
0
ファイル: common.py プロジェクト: yue123161/BotMiner-x
def insert_packets(delete=False):
    filename = sys.argv[1]
    group_id = sys.argv[2]
    upload_time = sys.argv[3]
    upload_name = sys.argv[4]

    cursor = db.cursor()
    sql = "INSERT INTO DataGroup(ID, UPLOAD_TIME, UPLOAD_NAME, START_TIME)VALUES (" + group_id + ", '" + upload_time + "','" + upload_name + "', '" + "1000" + "')"  # below 100s
    cursor.execute(sql)
    db.commit()

    def insert_single_file(filename):
        pcap = rdpcap(filename)[TCP]
        for i in xrange(len(pcap)):
            length = len(pcap[i])
            try:
                timestamp = pcap[i].time - int(
                    pcap[i].time) / 100 * 100  # below 100s
                ip_src = pcap[i]['IP'].src
                ip_dst = pcap[i]['IP'].dst
                port_src = str(pcap[i]['IP'].sport)
                port_dst = str(pcap[i]['IP'].dport)
                apanel_cluster(pcap[i], group_id)  # a-panel聚类
            except:
                continue
            """
            <Ether  dst=00:23:89:3a:8b:08 src=00:0e:c6:c2:5f:d8 type=0x800 |<IP  version=4L ihl=5L tos=0x0 len=40 id=34019 flags=DF frag=0L ttl=64 proto=tcp chksum=0x9920 src=172.29.90.176 dst=42.156.235.98 options=[] |<TCP  sport=47571 dport=https seq=3681001345 ack=1822908669 dataofs=5L reserved=0L flags=A window=65280 chksum=0x1ce7 urgptr=0 |>>>
            """
            if bin(pcap[i][TCP].flags)[-1] == '1':
                flag = 'Fin'
            elif bin(pcap[i][TCP].flags)[-2] == '1':
                flag = 'Syn'
            else:
                flag = ''

            sql = "INSERT INTO Packets(GROUP_ID, TIMESTAMP,LENGTH,IP_SRC,IP_DST,PORT_SRC,PORT_DST,FLAG)VALUES (" + group_id + "," + str(
                timestamp
            ) + "," + str(
                length
            ) + ", '" + ip_src + "','" + ip_dst + "', '" + port_src + "', '" + port_dst + "', '" + flag + "')"
            cursor.execute(sql)
            db.commit()

        if delete:
            os.remove(filename)

    if os.path.isfile(filename):
        insert_single_file(filename)
    elif os.path.isdir(filename):
        files = os.listdir(filename)
        total = len(files)
        print '[loader] Total pcap files: {}'.format(total)

        finished = 0
        for each in files:
            finished += 1
            insert_single_file(os.path.abspath(os.path.join(filename, each)))
            print '[loader] {}/{} finished.'.format(finished, total)
def detail_question():
    formula_id = request.values.get('formula_id')
    if formula_id is None:
        return redirect(url_for('formula'))
    if request.method == 'GET':
        page = request.values.get('page')
        if page is None:
            page = int(1)
        page = int(page)
        try:
            cur = db.cursor()
            sql = "select max(qno) from question_detail where formula_id = '%s'" % formula_id
            db.ping(reconnect=True)
            cur.execute(sql)
            question = cur.fetchone()[0]
            page_num = int(question / 20 + 0.96)
            # 防止页码溢出
            if page < 1:
                page = int(1)
            if page > page_num:
                page = int(page_num)
            cur = db.cursor()
            sql = "select title from SDWZCS.formula_post where formula_id = '%s'" % formula_id
            db.ping(reconnect=True)
            cur.execute(sql)
            title = cur.fetchone()[0]
            sql = "select formula_id, qno, content, datetime, nickname from question_detail,SDWZCS.userInformation where question_detail.author = userInformation.email and formula_id = '%s'" % formula_id
            db.ping(reconnect=True)
            cur.execute(sql)
            result = cur.fetchall()
            return render_template('detail_question.html',
                                   question_inf=result,
                                   title=title,
                                   page=page,
                                   page_num=page_num,
                                   formula_id=formula_id)
        except Exception as e:
            raise e
    if request.method == 'POST':
        content = request.form.get('editorValue')
        datetime = date = time.strftime("%Y-%m-%d %H:%M:%S")
        username = session.get('user_id')
        try:
            cur = db.cursor()
            sql = "select max(qno) from question_detail where formula_id = '%s'" % formula_id
            db.ping(reconnect=True)
            cur.execute(sql)
            qno = int(cur.fetchone()[0]) + 1
            sql = "insert into question_detail(formula_id, qno, content, datetime, author) VALUES ('%s','%s','%s','%s','%s')" % (
                formula_id, qno, content, datetime, username)
            db.ping(reconnect=True)
            cur.execute(sql)
            db.commit()
            cur.close()

            return redirect(url_for('detail_question', formula_id=formula_id))
        except Exception as e:
            raise e
コード例 #16
0
def modify(sql, keys):
    try:
        with db:
            cur = db.cursor()
            cur.execute(sql, keys)
        db.commit()
        return 1
    except:
        return 0
コード例 #17
0
def get_all_users():
    cur = db.cursor()
    sql = "select email from user"
    db.ping(reconnect=True)
    cur.execute(sql)
    result = cur.fetchall()
    db.commit()
    cur.close()
    return result
コード例 #18
0
def reply_messages(message):
    cursor = db.cursor()
    text = str(message.text.strip())

    cursor.execute('select dispute_id, feedback_id from Messages WHERE chat_id={0} and message_id={1} limit 1'.format(
        message.chat.id, message.reply_to_message.message_id))
    rows = cursor.fetchall()
    if not rows:
        bot.send_message(message.chat.id, 'Ты чот попутал, не на что отвечать)', reply_markup=markup_common)
        cursor.close()
        return

    dispute_id, feedback_id = rows[0]

    is_answer = dispute_id is not None
    parent_id = dispute_id or feedback_id

    first_line = text.splitlines()[0].strip()
    if first_line == '+':
        for_sign = True
    elif first_line == '-':
        for_sign = False
    else:
        for_sign = None
    if for_sign is not None:
        try:
            content = text.split('\n', 1)[1].strip()
        except IndexError:
            content = None
    else:
        content = text

    if is_answer and for_sign is not None:
        bot.send_message(message.chat.id, 'Нельзя оценить вопрос.',
                         reply_markup=markup_common)
        cursor.close()
        return

    params = [message.from_user.id, for_sign, parent_id, content, is_answer]
    cursor.execute("insert into Feedback(user_id, for, parent_id, rating, content, is_answer) VALUES (?,?,?,0,?,?)",
                   params)
    sent_message = bot.send_message(message.chat.id,
                                    (('Ответ' if is_answer else 'Комментарий') + ' успешно создан') if content else (
                                        'Ответ/комментарий успешно оценён'),
                                    reply_markup=markup_common)
    if not is_answer:
        update_feedback_rating(feedback_id)
    feedback_id = cursor.lastrowid
    if content:
        connect_message(message, feedback_id=feedback_id)
        connect_message(sent_message, feedback_id=feedback_id)
        cursor.execute('update User set state=state||? WHERE id=?',
                       ['{}{}/'.format('a' if is_answer else 'c', cursor.lastrowid), message.from_user.id])
        db.commit()
        send_stuff_by_state(message.from_user.id)
    cursor.close()
コード例 #19
0
def register():
    if request.method == 'GET':
        return render_template('register.html')
    elif request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        user = User(username, password)
        db.add(user)
        db.commit()
        return render_template('info.html', message=u'注册成功', redirect='/login')
コード例 #20
0
def edit_meeting_to_database(sql):
    try:
        cur = db.cursor()
        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()

    except Exception as e:
        print(e)
コード例 #21
0
ファイル: app.py プロジェクト: Germey/Publish
def register():
    if request.method == 'GET':
        return render_template('register.html')
    elif request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        user = User(username, password)
        db.add(user)
        db.commit()
        return render_template('info.html', message=u'注册成功', redirect='/login')
コード例 #22
0
def add_sponsor(sql):
    try:

        cur = db.cursor()
        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()

    except Exception as e:
        print(e)
コード例 #23
0
def feed(message):
    cursor = db.cursor()
    cursor.execute('SELECT last_dispute_id FROM User WHERE id=?', [message.from_user.id])
    user_last_id, = cursor.fetchall()[0]
    cursor.execute('SELECT id FROM Dispute ORDER BY  -id LIMIT 1;')
    real_last_id, = cursor.fetchall()[0]  # todo fix falling
    cursor.execute('UPDATE User SET last_dispute_id=?,state=state||? WHERE id=?',
                   [real_last_id, 'f({}-{})/'.format(user_last_id, real_last_id), message.from_user.id])
    db.commit()
    cursor.close()
    send_stuff_by_state(message.from_user.id)
コード例 #24
0
ファイル: leave.py プロジェクト: gutongww/AUCSS-StaffPlatform
def add_leave_to_leave_history(mid, email, processor):
    try:
        cur = db.cursor()
        sql = "INSERT INTO leave_history(user_email, meeting_id, processor) VALUES ('%s',%s,'%s')" % (
            email, mid, processor)
        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()
    except Exception as e:
        print(e)
コード例 #25
0
 def detect(self,
            parsed_data,
            sensitivity=Sensitivity.Regular,
            forbidden=None,
            legitimate=None):
     """
     The method will check path that are in the forbidden list, for every path in this list
     the method will perform brute force check by number of request in the last 1min.
     :param parsed_data: Parsed Data (from the parser module) of the request / response
     :param sensitivity: The sensitivity of the detection
     :param forbidden: list of paths to protect
     :param legitimate: The path's that legitimate in any case for cross-site (list)
     :return: boolean
     """
     # Pre Processing
     legitimate = self.kb["legitimate"] if type(
         legitimate) is not list else legitimate + self.kb["legitimate"]
     check_pre_processing = self._pre_processing(forbidden, legitimate,
                                                 parsed_data)
     if check_pre_processing == Classification.Clean:
         return False
     elif check_pre_processing == Classification.Detected:
         return True
     # ------ This code will run if the path is in the forbidden list ------ #
     req_path = parsed_data.path.strip("/")
     client_ip = parsed_data.from_ip
     bf_item = self._get_previous_request_info(client_ip, req_path,
                                               parsed_data.host_name)
     last_request, counter = bf_item.time_stamp, bf_item.counter
     # Sensitivity will determinate the max_counter.
     if sensitivity == Sensitivity.Regular:
         max_counter = self.kb["sensitivity"][str(
             Sensitivity.Regular.value
         )]  # TODO: discuss about the const numbers.
     elif sensitivity == Sensitivity.Sensitive:
         max_counter = self.kb["sensitivity"][str(
             Sensitivity.Sensitive.value)]
     elif sensitivity == Sensitivity.VerySensitive:
         max_counter = self.kb["sensitivity"][str(
             Sensitivity.VerySensitive.value)]
     else:
         max_counter = self.kb["sensitivity"]["else"]
     # Check if the last request was more that 1min ago
     bf_item.counter += 1
     bf_item.time_stamp = time.time()
     if time.time() - last_request > self.kb[
             "time_interval_in_sec"]:  # TODO: discuss about the const 1min.
         bf_item.counter = 0
     elif counter >= max_counter:
         db.commit()
         return True
     # --- The counter is < max_counter --- #
     db.commit()
     return False
コード例 #26
0
ファイル: app.py プロジェクト: birukbelay/flaskbookreview
def create_book():
    form = BookForm()
    if request.method == 'POST' and form.validate_on_submit():
        db.execute(
            "INSERT INTO books (title, author) VALUES (:title, :author);", {
                "title": form.title.data,
                'author': form.author.data
            })
        db.commit()
        # data = Book(form.title.data, form.author.data, form.isbn.data, form.year.data, )
    return render_template('book.html', form=form)
コード例 #27
0
def add_all_staff_to_meeting(id):
    users = get_all_users()
    sql = "INSERT INTO need_to_meeting (user_email,meeting_id) VALUES"
    for email in users:
        sql += "('%s',%s)," % (email[0], id)
    sql = sql[:-1] + ";"
    cur = db.cursor()
    db.ping(reconnect=True)
    cur.execute(sql)
    db.commit()
    cur.close()
コード例 #28
0
def transcation2():
    db.begin_transaction()
    try:
        db.table('user').where('id', 26).update({'name': 'hehe'})
        db.table('user').insert([
            {'uid': 111, 'name': '111', 'email': '*****@*****.**'},
            {'uid': 222, 'name': '222', 'email': '*****@*****.**'}
        ])
        db.commit()
    except:
        db.rollback()
        raise
def password_reset():
    try:
        cur = db.cursor()
        sql = "update userInformation set SDWZCS.userInformation.password = '******'12321', method="pbkdf2:sha256",
            salt_length=8) + "'where email = 'demo1';"
        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()
    except Exception as e:
        raise e
コード例 #30
0
def start(message):
    cursor = db.cursor()
    try:
        cursor.execute("insert into User(id,state) values ({0},'{1}')".format(message.from_user.id, '/'))
        db.commit()
        bot.send_message(message.from_user.id, 'Добро пожаловать! Введи /help, чтобы получить помощь')
    except Exception as e:
        if 'UNIQUE' in e.args[0]:
            bot.send_message(message.from_user.id, 'С возвращением!')
        else:
            raise
    cursor.close()
コード例 #31
0
ファイル: leave.py プロジェクト: gutongww/AUCSS-StaffPlatform
def approve_status(mid, email):
    try:
        cur = db.cursor()
        sql = "update meeting_leave set status='Approved' " \
              "where meeting_id=%s and user_email='%s'" % (mid, email)
        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()

    except Exception as e:
        print(e)
コード例 #32
0
ファイル: app.py プロジェクト: Germey/Publish
def publish():
    if request.method == 'GET':
        if not session.has_key('username'):
            return render_template('info.html', message=u'尚未登录', redirect='/login')
        return render_template('publish.html')
    elif request.method == 'POST':
        title = request.form['title'].encode('utf-8', 'ignore')
        content = request.form['content'].encode('utf-8', 'ignore')
        username = session['username']
        post = Post(title, content, username)
        db.add(post)
        db.commit()
        return render_template('info.html', message=u'发布成功', redirect='/posts')
コード例 #33
0
ファイル: leave.py プロジェクト: gutongww/AUCSS-StaffPlatform
def list_leave_apply_of_user(email):
    try:
        cur = db.cursor()
        sql = "SELECT M.meeting_title,M.meeting_date,L.status FROM meeting AS M,meeting_leave AS L " \
              "WHERE M.meeting_id =L.meeting_id AND L.user_email='%s'" % email
        db.ping(reconnect=True)
        cur.execute(sql)
        result = cur.fetchall()
        db.commit()
        cur.close()
        return result
    except Exception as e:
        print(e)
コード例 #34
0
ファイル: leave.py プロジェクト: gutongww/AUCSS-StaffPlatform
def apply_leave(email, mid, reason):
    try:
        status = "Processing"
        cur = db.cursor()
        sql = "INSERT INTO meeting_leave (meeting_id,user_email,reason,status)VALUES (%s,\"%s\",\"%s\",\"%s\")" % (
            mid, email, pymysql.escape_string(reason), status)

        db.ping(reconnect=True)
        cur.execute(sql)
        db.commit()
        cur.close()
    except Exception as e:
        print(e)
コード例 #35
0
ファイル: models.py プロジェクト: txsl/MADMail
def mark_merge_as_sent(mail):
    mail.Sent=True
    db.commit()