async def handlePicturePost(message): author = message.author if author.name in db.keys(): userJsonFromDB = json.loads(db[author.name]) userInfo = UserInfo(**userJsonFromDB) if (userInfo.postedToday() == True): await warn_user_daily_post(message.author) await message.delete() else: print("\n" + author.name + " posted a picture\n") userInfo.addPost() userJSON = json.dumps(userInfo.__dict__) db[author.name] = userJSON await changeServerIcon(message) await author.create_dm() await author.dm_channel.send("Great job! See you again tomorrow :smiley:") else: print("\n" + author.name + " posted a picture\n") userInfo = UserInfo(author.name, int(datetime.now().timestamp()), 0, 0, 0, 0, 0) userInfo.addPost() userJSON = json.dumps(userInfo.__dict__) db[author.name] = userJSON await changeServerIcon(message) await author.create_dm() await author.dm_channel.send("Great job! See you again tomorrow :smiley:")
def __init__(self, userInfo): if userInfo.__class__ == UserInfo: self.userInfo = userInfo else: self.userInfo = UserInfo(userInfo) self.data = []
def main(*args, **kwargs): win = visual.Window(fullscr=False, size=(1200, 800), color=(-1, -1, -1)) user_info = UserInfo() ##测试1 practice_1 = Practice_1(user_info, win, max_correct=2, max_total=5) practice_1.process() ##测试2 practice_2 = Practice_2(user_info, win, go_trail_number=3, stop_trail_number=1) practice_2.process() ##正式实验 formal_experiment = Formal_Experiment(user_info, win, go_trail_number=3, stop_trail_number=1) formal_experiment.process() formal_experiment.process() formal_experiment.process() win.close() return True
def __init__(self): super(Ui_MainWindow, self).__init__() self.userinfo = UserInfo("userinfo.txt") self.figure = Figure() self.stack1 = QWidget() self.stack2 = QWidget() self.stack3 = QWidget() self.init_main_window() self.init_parameter_window() self.init_egram_window() self.Stack = QStackedWidget(self) self.Stack.addWidget(self.stack1) self.Stack.addWidget(self.stack2) self.Stack.addWidget(self.stack3) hbox = QHBoxLayout(self) hbox.addWidget(self.Stack) self.setLayout(hbox) self.setGeometry(300, 50, 750, 400) self.setWindowTitle('Pacemaker DCM') self.show()
def InitNewUserInfo(self): userinfo = UserInfo() userinfo.active = 1 userinfo.pid = os.getpid() if ((self.user.HasPerm(User.PERM_CHATCLOAK) or self.user.HasPerm(User.PERM_CLOAK)) and (self.user.HasFlag(User.CLOAK_FLAG))): userinfo.invisible = 1 userinfo.mode = modes.XMPP userinfo.pager = 0 if (self.user.Defined(User.DEF_FRIENDCALL)): userinfo.pager |= User.FRIEND_PAGER if (self.user.HasFlag(User.PAGER_FLAG)): userinfo.pager |= User.ALL_PAGER userinfo.pager |= User.FRIEND_PAGER if (self.user.Defined(User.DEF_FRIENDMSG)): userinfo.pager |= User.FRIENDMSG_PAGER if (self.user.Defined(User.DEF_ALLMSG)): userinfo.pager |= User.ALLMSG_PAGER userinfo.pager |= User.FRIENDMSG_PAGER userinfo.uid = self.uid setattr(userinfo, 'from', self._fromip) userinfo.freshtime = int(time.time()) userinfo.userid = self.username userinfo.realname = 'ANONYMOUS' # XXX: fix later userinfo.username = self.user.userec.username return userinfo
def __init__(self, userInfo): if userInfo.__class__ != UserInfo: userInfo = UserInfo(userInfo) self.ids = userInfo.getID() self.foldersData = []
def RebuildList(): lock = Utmp.Lock() try: entries = [] hashes = {} active = set() for i in xrange(Config.USHM_SIZE): userinfo = UserInfo(i + 1) if userinfo.active == 1: entries.append((i, userinfo.userid)) hash = Utmp.Hash(userinfo.userid) hashes[hash] = hashes.get(hash, []) + [i] active.add(i) if entries == []: Log.info("NO USER! RESET!") Utmp.ResetUtmp(locked=True) else: cnt = len(entries) Log.info("Rebuild Utmp with %d entries" % cnt) entries.sort(key=lambda entry: entry[1]) UtmpHead.SetReadOnly(0) # rebuild list UtmpHead.SetListHead(entries[0][0] + 1) for i in xrange(len(entries)): pos = entries[i][0] next = entries[(i + 1) % cnt][0] prev = entries[(i - 1 + cnt) % cnt][0] UtmpHead.SetListNext(pos, next + 1) UtmpHead.SetListPrev(pos, prev + 1) print pos, "prev", prev, "next", next # rebuild hash for hash in hashes: cnt = len(hashes[hash]) UtmpHead.SetHashHead(hash, hashes[hash][0] + 1) print "hash", hash, "head", hashes[hash][0] for i in xrange(cnt): pos = hashes[hash][i] if i < cnt - 1: next = hashes[hash][i + 1] else: next = -1 UtmpHead.SetNext(pos, next + 1) print "next", pos, next for i in xrange(Config.UTMP_HASHSIZE): if i != 0 and UtmpHead.GetHashHead(i) != 0 and not i in hashes: UtmpHead.SetHashHead(i, 0) print "reset", i # TODO: rebuild free list at hash[0] #if min(active) > 0: # UtmpHead.SetHashHead(0, 1) UtmpHead.SetReadOnly(1) finally: Utmp.Unlock(lock)
def userSignup(): if request.method == 'POST': user = UserInfo(request) result = user.insertUser() if (result == '201'): user_id = user.get_user_id() return jsonify({'response': user_id}), 201 return result, 400 #here the result is not json , not sure how to return the response here (should it be json?)
def printDB(): print("-----------------------------------------------------") keys = db.keys() for key in keys: userJsonFromDB = json.loads(db[key]) userInfo = UserInfo(**userJsonFromDB) userInfo.printUserInfo() print("-----------------------------------------------------")
def Clear2(uent): userinfo = UserInfo(uent) Log.debug("clearing user %s uid %d loginid %d" % (userinfo.userid, userinfo.uid, uent)) user = UCache.UCache.GetUserByUid(userinfo.uid) UCache.UCache.DoAfterLogout(user, userinfo, uent, 0) login = Login.Login(uent) login.hash_remove() login.list_remove() if (userinfo.active): UtmpHead.DecNumber() Log.debug("zeroing utmp %d" % uent) zeroinfo = UserInfo() zeroinfo.SetIndex(uent) zeroinfo.save()
def getAllUser(self): userList = list() rows = self.__conn.execute("SELECT * FROM user") for row in rows: nickname, homedir, mail, fullname = row userInfo = UserInfo() userInfo.nickname = nickname userInfo.homedir = homedir userInfo.mail = mail userInfo.fullname = fullname userList.append(userInfo) return userList
def userLogin(): if request.method == 'POST': user = UserInfo(request) result = user.loginUser() if (result == 'fail'): return jsonify({'user': '******' }), 500 #(is this right?) elif (result == "true"): return jsonify({'response': 'ok'}) else: return jsonify({'response': 'user name or password incorrect'}), 401
def get_userlist(self, filename): ''' Read the user's id and password from a file ''' with open(filename, 'r') as f: # read data for line in f.readlines(): # remove '\n' and use ' ' split string, to get userid and password userid, password = line.replace('\n', '').split(' ') # store in the dict self.userlist[userid] = password self.userstatus[userid] = UserInfo(userid, '', '', '', STATUS_OFFLINT)
def getUser(self, nickname): userList = list() rows = self.__conn.execute("SELECT * FROM user WHERE nickname='" + nickname + "';") for row in rows: nickname, homedir, mail, fullname = row userInfo = UserInfo() userInfo.nickname = nickname userInfo.homedir = homedir userInfo.mail = mail userInfo.fullname = fullname userList.append(userInfo) if len(userList) < 1: return -1 else: return userList[0]
def extract_user_info(self, html): user_info_list = list() # get json reg = re.compile( r'<script>STK && STK\.pageletM && STK\.pageletM\.view\((\{"pid":"pl_user_feedList".+?)\)</script>', re.I) match = reg.search(html) if (match): m = match.group(1) header_json = json.loads(m) if (type(header_json) == types.DictType): soup = BeautifulSoup(header_json['html']) # 获取微博用户列表 user_list = soup.find_all("div", class_="person_detail") if (type(user_list) == types.NoneType): return None for user in user_list: user_info = UserInfo() # 获取用户的微博名称、ID、和博客地址 # 获取微博用户认证类型 p_tag = user.find("p", class_="person_name") self.extract_name_id_url_type(user_info, p_tag) #获取微博用户性别、地区 p_tag = user.find("p", class_="person_addr") self.extract_gender_location(user_info, p_tag) # 获取微博用户关注数、粉丝数和微博数 p_tag = user.find("p", class_="person_num") self.extract_friend_follower_wb_count(user_info, p_tag) # 获取微博用户简介 div_tag = user.find("div", class_="person_info") self.extract_user_description(user_info, div_tag) # 获取用户标签、教育信息、职业信息 p_tag = user.find_all("p", class_="person_label") self.extract_labels(user_info, p_tag) user_info_list.append(user_info) else: print "extract_user_info:get error" return user_info_list
def stat(): conn = db.connect_torndb() result = conn.query('select distinct(u.id) from deal_note dn ' 'left join user u on dn.userId = u.id ' 'where dn.iom = %s and dn.createTime > %s', 'Y', '2016-05-01') list = [] for item in result: info = conn.get("select * from user u " "left join user_organization_rel uor on u.id = uor.userId " "left join organization o on o.id = uor.organizationId" " where u.id =%s ", item['id']) count = conn.get('select count(*) as count from deal_note ' 'where userId=%s and createTime > %s', item['id'], '2016-05-01') listItem = UserInfo(info['username'], info['name'], info['email'], count['count']) list.append(listItem) result = sorted(list, key=getCount, reverse=True) id =0 for item in result: id += 1 print id, item.username, item.orgName, item.email, item.count conn.close()
def getUserInfo(self): userinfoprocessor = UserInfo(self.userinfofilename) self.userInfo = userinfoprocessor.readUserInfoFile()
from UserInfo import UserInfo from UserTopics import UserTopics from UserAsk import UserAsk from AskTopics import AskTopics from UserAnswer import UserAnswer UserInfo(1) # UserTopics(1) # UserAsk(1) # AskTopics(1) # UserAnswer(1)
def dump_userinfo(i): userinfo = UserInfo(i) print vars(userinfo)
def getUser(userKey): userJsonFromDB = json.loads(db[userKey]) return UserInfo(**userJsonFromDB)