Exemplo n.º 1
0
def index():
    now = datetime.datetime.now()
    nowtime = now.strftime("%Y-%m-%d %H:%M:%S")
    if request.method != "POST":
        return ""
    if "password" not in request.form:
        return ""
    if request.form["password"] != password:
        return ""
    if "success" not in request.form:
        d = collections.OrderedDict()
        x = db.select("info", where="flag=0")
        if len(x) != 0:
            for key in x:
                d[key.msgid] = key.con
                db.insert("log", msgid=key.msgid, time=nowtime, state="send")
            return json.dumps(d)
        else:
            return ""
    else:
        msgid = request.form["success"]
        if msgid.isdigit():
            try:
                db.update("info", where="msgid=$msgid", flag=1, vars=locals())
                db.insert("log", msgid=msgid, time=nowtime, state="receive")
            except:
                pass
        return ""
Exemplo n.º 2
0
def index():
    now = datetime.datetime.now()
    nowtime = now.strftime('%Y-%m-%d %H:%M:%S')
    if request.method != 'POST':
        return ""
    if 'password' not in request.form:
        return ""
    if request.form['password'] != password:
        return ""
    if 'success' not in request.form:
        d = collections.OrderedDict()
        x = db.select('info', where="flag=0")
        if len(x) != 0:
            for key in x:
                d[key.msgid] = key.con
                db.insert("log", msgid=key.msgid, time=nowtime, state="send")
            return json.dumps(d)
        else:
            return ""
    else:
        msgid = request.form['success']
        if msgid.isdigit():
            try:
                db.update('info', where='msgid=$msgid', flag=1, vars=locals())
                db.insert("log", msgid=msgid, time=nowtime, state="receive")
            except:
                pass
        return ""
Exemplo n.º 3
0
    def add_from_reading(cls, db, key, reading):
        """Adds a reading to the database

        :param reading: the reading to add
        """

        # get allowed channels
        allowed_channels = key.get_writable_channels()

        insert_count = 0

        # start a transaction
        with db.transaction():
            # insert samples, checking channel access
            for sample in reading.sample_dict_gen():
                if sample["channel"] not in allowed_channels:
                    raise Exception("Channel {0} cannot be writen to with \
specified key".format(sample["channel"]))

                db.insert(cls.TABLE_NAME, \
                channel=sample["channel"], timestamp=sample["timestamp"], \
                value=sample["value"])

                insert_count += 1

        return insert_count
Exemplo n.º 4
0
def register(username, password, telephone, wechat, icon):
    db = connectDB()

    mmd5 = hashlib.md5()
    mmd5.update(password)
    pwd = mmd5.hexdigest()

    if not wechat:
        db.insert('user', username = username, password = pwd, telephone = telephone, icon = icon)
    else:
        db.insert('user', username = username, password = pwd, telephone = telephone, wechat = wechat, icon = icon)
Exemplo n.º 5
0
def release(userid, demand, quote, destination):
    db = web.database(
        dbn = 'mysql',
        host = sae.const.MYSQL_HOST,
        port = int(sae.const.MYSQL_PORT),
        user = sae.const.MYSQL_USER,
        passwd = sae.const.MYSQL_PASS,
        db = sae.const.MYSQL_DB
    )

    orderid = db.insert('orders', dmd = demand, quote = quote, requestid = userid, destination = destination)
    db.insert('dmdpool', orderid = orderid)
Exemplo n.º 6
0
def update_note_content(id, content, data=''):
    if id is None:
        return
    if content is None:
        content = ''
    if data is None:
        data = ''
    db = xtables.get_note_content_table()
    result = db.select_first(where=dict(id=id))
    if result is None:
        db.insert(id=id, content=content, data=data)
    else:
        db.update(where=dict(id=id), content=content, data=data)
Exemplo n.º 7
0
def register(username, password, telephone, wechat, icon):
    db = web.database(
        dbn = 'mysql',
        host = sae.const.MYSQL_HOST,
        port = int(sae.const.MYSQL_PORT),
        user = sae.const.MYSQL_USER,
        passwd = sae.const.MYSQL_PASS,
        db = sae.const.MYSQL_DB
    )

    mmd5 = hashlib.md5()
    mmd5.update(password)
    pwd = mmd5.hexdigest()

    if not wechat:
        db.insert('user', username = username, password = pwd, telephone = telephone, icon = icon)
    else:
        db.insert('user', username = username, password = pwd, telephone = telephone, wechat = wechat, icon = icon)
Exemplo n.º 8
0
def AddUserMessage(userid, clienttime, inputmsg,isvalid):
     # Response and session
    if isvalid == 1:        
        session = get_session(userid, inputmsg)        
        response = get_response(userid, inputmsg)
    else:
        response = ''
        session = ''
        
    # Insert to db    
    utctime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(time.time()))
    id = db.insert('User_Message', UserOpenId=userid, ClientTime=clienttime, UTCTIME = utctime, 
                     InputMessage=inputmsg, Version = numVersion, IsValid = isvalid,
                     Session = session, Response = response)
    # id reserve for future use
    
    return response
Exemplo n.º 9
0
def create_note(note_dict):
    content = note_dict["content"]
    data = note_dict["data"]
    creator = note_dict["creator"]
    priority = note_dict["priority"]
    mtime = note_dict["mtime"]

    if xconfig.DB_ENGINE == "sqlite":
        db = xtables.get_file_table()
        id = db.insert(**note_dict)
        update_note_content(id, content, data)
        return id
    else:
        id = dbutil.timeseq()
        key = "note_full:%s" % id
        note_dict["id"] = id
        dbutil.put(key, note_dict)
        score = "%02d:%s" % (priority, mtime)
        dbutil.zadd("note_recent:%s" % creator, score, id)
        update_children_count(note_dict["parent_id"])
        return id
Exemplo n.º 10
0
def new_todo(text):
    return db.insert('todo', titel=text)
def insert_URL(_url, _push_id):
    db.insert("URL", url = _url, push_id = _push_id)
Exemplo n.º 12
0
def add_new(user, username,phone,num,time):
    return db.insert('morning_enroll', user=user, username=username,phone=phone,num=num,time=time)
Exemplo n.º 13
0
def addfk(username, fktime, fkcontent):
    return db.insert('fk', user=username, time=fktime, fk_content=fkcontent)
def insert_news(_url, _title, _image, _date, _word):
    db.insert("news", url = _url, title = _title, image = _image, date = _date, word = _word)
Exemplo n.º 15
0
def get_insert(_table, _openID, _keyword):
    return db.insert(_table, openID = _openID, keyword = _keyword)
def insert_feedback(_user, _fktime, _fkcontent):
    db.insert("feedback", user = _user, fktime = _fktime, fkcontent = _fkcontent)
Exemplo n.º 17
0
def add_new(username, time):
    return db.insert('morning_time_backup', username=username, sign_time=time)
Exemplo n.º 18
0
def add_new(user,username,stuid,total,istoday,timetoday,all_record,phone):
    return db.insert('morning_sign', user=user, username=username,stuid=stuid,total=total,istoday=istoday,timetoday=timetoday,all_record=all_record,phone=phone)
Exemplo n.º 19
0
def get_insert_feedback(_table, _user, _fktime, _fkcontent):
    return db.insert(_table, user = _user, fktime = _fktime, fkcontent = _fkcontent)
Exemplo n.º 20
0
def get_insert_news(_table, _url, _title, _date):
    return db.insert(_table, url = _url, title = _title, date = _date)
Exemplo n.º 21
0
def addfk(username, fktime, fkcontent):
    return db.insert('fk', user=username, time=fktime, fk_content=fkcontent)
def insert_push_time(_push_id, _time, _last_id):
    db.insert("push_time", push_id = _push_id, time = _time, last_id = _last_id)
Exemplo n.º 23
0
def wuru(username, product_details):
    #New Product
    #Return product id
    product_id = db.insert('shareit', product_details = product_details, product_owner = username, product_user = username, checkcode_user = '******')
    return str(product_id)
Exemplo n.º 24
0
def addip(addip):  # 增加一个代理IP
	return db.insert('dailiip',ip=addip)
Exemplo n.º 25
0
def release(userid, demand, quote, destination):
    db = connectDB()

    orderid = db.insert('orders', dmd = demand, quote = quote, requestid = userid, destination = destination)
    db.insert('dmdpool', orderid = orderid)
def insert_keyword(_push_id, _word):
    db.insert("keyword", push_id = _push_id, word = _word)