コード例 #1
0
def web_register(user_name):
    print(user_name)
    username = request.form.get('userName')
    pwd = request.form.get('pwd')
    userphone = request.form.get("userPhone")
    usermail = request.form.get("userMail")
    mailcode = request.form.get('mailCode')
    codeKey = "" + usermail + ":code"
    code = r.get(codeKey)
    user = wx_user.query.filter(wx_user.name == username
                                or wx_user.phone == userphone).first()
    #找到
    if user:
        return ("2")
    else:
        # 判断邮箱验证码是否正确
        if mailcode == '%s' % code:
            for k in r.scan_iter('wx_user*'):
                r.delete(k)
            webuser = wx_user(name=username,
                              email=usermail,
                              phone=userphone,
                              password=pwd,
                              wx_id=1,
                              info_number=0)
            db.session.add(webuser)
            db.session.commit()
            for k in r.scan_iter('wx_user*'):
                r.delete(k)
            return ("1")
        else:
            return ("0")
コード例 #2
0
def register():
    openid = request.values.get('openid')
    username = request.values.get('name')

    id = wx_user.query.filter(wx_user.wx_id == openid).first()
    if id:
        return '该用户已注册'
    else:
        for k in r.scan_iter('wx_user*'):
            r.delete(k)
        user = wx_user(name=username,
                       wx_id=openid,
                       phone='无',
                       email='无',
                       password='******',
                       info_number=0,
                       control_power=0)
        db.session.add(user)
        db.session.commit()

        for k in r.scan_iter('wx_user*'):
            r.delete(k)
        wxuser = wx_user.query.filter(wx_user.wx_id == openid).first()
        id = wxuser.id
        sql = 'select * from upload_img'
        cursor.execute(sql)
        image_id = cursor.fetchall()
        for i in image_id:
            unread = "insert into information(user_id,image_id,equip_id) VALUE (%s,%s,%s)" % (
                id, i[0], i[4])
            # unread = information(user_id=id,image_id=i[0],equip_id=i[4])
            cursor.execute(unread)
        database.commit()
        return ''
コード例 #3
0
    def ctreate_ThreadPool(self):
        recived = self.ws.receive()
        if not recived is None:
            # 接收传过来的用户名,设备id,时间戳,,图片数量,主题,描述
            rec = str(recived, encoding="utf8")
            # 此处为你需要传过来用户id,设备id,时间戳,图片数量,实验主题和实验描述
            username, pwd, equip_code, t, number, theme, description, resume = rec.split(
                SEPARATOR)

            u_name = '\'%s\'' % username
            u_pwd = '\'%s\'' % pwd
            sql = 'select id from wx_user where name=%s and password=%s' % (
                u_name, u_pwd)
            cursor.execute(sql)
            user_id = cursor.fetchall()
            data = json.dumps(user_id)
            if len(data) < 5:
                self.ws.send("登录失败")
            else:
                self.ws.send("核对成功")

                equip = equipment.query.filter(
                    equipment.equip_code ==
                    equip_code).first()  # 获取刚刚上传图片数据的id
                equip_id = equip.id
                number = int(number)  # 将number转为int型

                ###############此处直接调用信息处理类来处理信息############################
                if resume == 'False':
                    d = Data_deal(user_id, number, equip_id, description,
                                  theme)
                    d.update_info()
                    for j in r.scan_iter('imgs*'):
                        r.delete(j)
                    for k in r.scan_iter('upload_img*'):
                        r.delete(k)
                    for i in r.scan_iter("eqimfo*"):
                        r.delete(i)
                threadPool = ThreadPoolExecutor(
                    max_workers=number, thread_name_prefix="pro")  # 根据用户上传的文件
                # 一个用户来访问就会开一个线程,然后根据他传过来的图片数量,开启线程池读取文件
                for i in range(number):
                    future = threadPool.submit(self.re(username, user_id,
                                                       t))  # j将线程提交到线程池
                time.sleep(3)
                threadPool.shutdown()
                print('接收完!')
コード例 #4
0
 def ctreate_ThreadPool(self):
     recived = self.ws.receive()
     if not recived is None:
         rec = str(recived, encoding="utf8")
         equip_code, t, number, resume = rec.split(SEPARATOR)
         # 接收传过来的用户名,设备id,时间戳,,图片数量,主题,描述
         equip = equipment.query.filter(
             equipment.equip_code == equip_code).first()  # 获取刚刚上传图片数据的id
         equip_id = str(equip.id)
         sql = 'select user_id from upload_img where equip_id=%s and number<%s' % (
             equip_id, 30)
         cursor.execute(sql)
         data = cursor.fetchall()
         print(data, type(data))
         user_id = data[0][0]
         user = wx_user.query.filter(
             wx_user.id == user_id).first()  # 获取刚刚上传图片数据的id
         username = user.name
         self.ws.send("核对成功")
         ###############此处直接调用信息处理类来处理信息############################
         if resume == 'False':
             d = Data_deal(number, equip_id)
             d.update_info()
             for j in r.scan_iter('imgs*'):
                 r.delete(j)
             for k in r.scan_iter('upload_img*'):
                 r.delete(k)
             for i in r.scan_iter("eqimfo*"):
                 r.delete(i)
         number = int(number)  # 将number转为int型
         threadPool = ThreadPoolExecutor(
             max_workers=number, thread_name_prefix="pro")  # 根据用户上传的文件
         # 一个用户来访问就会开一个线程,然后根据他传过来的图片数量,开启线程池读取文件
         for i in range(number):
             future = threadPool.submit(self.re(username, user_id,
                                                t))  # j将线程提交到线程池
         time.sleep(3)
         threadPool.shutdown()
         print('接收完!')
コード例 #5
0
def clearkey():
    userid = request.form.get('userid')
    r.delete(userid)
    return ''