Python user.User() Examples
The following are 13
code examples of user.User().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
user
, or try the search function
.
Example #1
Source File: train.py From GO-Bot-DRL with MIT License | 6 votes |
def run_round(state, warmup=False): # 1) Agent takes action given state tracker's representation of dialogue (state) agent_action_index, agent_action = dqn_agent.get_action(state, use_rule=warmup) # 2) Update state tracker with the agent's action state_tracker.update_state_agent(agent_action) # 3) User takes action given agent action user_action, reward, done, success = user.step(agent_action) if not done: # 4) Infuse error into semantic frame level of user action emc.infuse_error(user_action) # 5) Update state tracker with user action state_tracker.update_state_user(user_action) # 6) Get next state and add experience next_state = state_tracker.get_state(done) dqn_agent.add_experience(state, agent_action_index, reward, next_state, done) return next_state, reward, done, success
Example #2
Source File: membership.py From stdm with GNU General Public License v2.0 | 6 votes |
def getUser(self,username): ''' Gets the user object based on the username. Returns 'None' if not found ''' user = None t = text("select valuntil from pg_user where usename = :uname") conn = self._engine.connect() result = conn.execute(t,uname = username).fetchone() if result is not None: user = User(username) #Get the date component only - first ten characters valDate = result["valuntil"] if valDate is not None: valDate = valDate[:10] user.Validity = valDate return user
Example #3
Source File: session.py From python-mal with Do What The F*ck You Want To Public License | 5 votes |
def __init__(self, username=None, password=None, user_agent="iMAL-iOS"): """Creates a new instance of Session. :type username: str :param username: A MAL username. May be omitted. :type password: str :param username: A MAL password. May be omitted. :type user_agent: str :param user_agent: A user-agent to send to MAL in requests. If you have a user-agent assigned to you by Incapsula, pass it in here. :rtype: :class:`.Session` :return: The desired session. """ self.username = username self.password = password self.session = requests.Session() self.session.headers.update({ 'User-Agent': user_agent }) """Suppresses any Malformed*PageError exceptions raised during parsing. Attributes which raise these exceptions will be set to None. """ self.suppress_parse_exceptions = False
Example #4
Source File: session.py From python-mal with Do What The F*ck You Want To Public License | 5 votes |
def user(self, username): """Creates an instance of myanimelist.User with the given username :type username: str :param username: The desired user's username. :rtype: :class:`myanimelist.user.User` :return: A new User instance with the given username. """ return user.User(self, username)
Example #5
Source File: test.py From GO-Bot-DRL with MIT License | 5 votes |
def test_run(): """ Runs the loop that tests the agent. Tests the agent on the goal-oriented chatbot task. Only for evaluating a trained agent. Terminates when the episode reaches NUM_EP_TEST. """ print('Testing Started...') episode = 0 while episode < NUM_EP_TEST: episode_reset() episode += 1 ep_reward = 0 done = False # Get initial state from state tracker state = state_tracker.get_state() while not done: # Agent takes action given state tracker's representation of dialogue agent_action_index, agent_action = dqn_agent.get_action(state) # Update state tracker with the agent's action state_tracker.update_state_agent(agent_action) # User takes action given agent action user_action, reward, done, success = user.step(agent_action) ep_reward += reward if not done: # Infuse error into semantic frame level of user action emc.infuse_error(user_action) # Update state tracker with user action state_tracker.update_state_user(user_action) # Grab "next state" as state state = state_tracker.get_state(done) print('Episode: {} Success: {} Reward: {}'.format(episode, success, ep_reward)) print('...Testing Ended')
Example #6
Source File: prog-o-meter.py From prog-o-meter with MIT License | 5 votes |
def main(): """Mainroutine to run the prog-o-meter program. Opens a window, which lets the user choose if they are a new or returning user. Opens a new window, which lets the user type their name. Opens a new window, which shows the user's progress, and how many days remains of the challenge. """ start_screen = StartGUI() user_state = start_screen.get_state() name_screen = UsernameGUI(user_state) username = name_screen.get_name() user = User(username, user_state == 2) logname = "".join((username.lower(), "_log.txt")) ProgressGUI(user, logname)
Example #7
Source File: tip.py From sodogetip with MIT License | 5 votes |
def set_sender(self, sender_username): self.sender = User(sender_username)
Example #8
Source File: tip.py From sodogetip with MIT License | 5 votes |
def set_receiver(self, receiver_username): # update only if previous is blank (other case it will be set in parse_message) if self.receiver is None: self.receiver = User(receiver_username)
Example #9
Source File: tip.py From sodogetip with MIT License | 5 votes |
def create_from_array(self, arr_tip): # import user self.receiver = User(arr_tip['receiver']) self.sender = User(arr_tip['sender']) del arr_tip['receiver'] del arr_tip['sender'] for key in arr_tip.keys(): setattr(self, key, arr_tip[key]) return self
Example #10
Source File: multipart.py From canvas with BSD 3-Clause "New" or "Revised" License | 5 votes |
def startElement(self, name, attrs, connection): if name == 'Initiator': self.initiator = user.User(self) return self.initiator elif name == 'Owner': self.owner = user.User(self) return self.owner elif name == 'Part': part = Part(self.bucket) self._parts.append(part) return part return None
Example #11
Source File: steam.py From pysteam with MIT License | 5 votes |
def local_users(self): """Returns an array of user ids for users on the filesystem""" # Any users on the machine will have an entry inside of the userdata # folder. As such, the easiest way to find a list of all users on the # machine is to just list the folders inside userdata userdirs = filter(self._is_user_directory, os.listdir(self.userdata_location())) # Exploits the fact that the directory is named the same as the user id return map(lambda userdir: user.User(self, int(userdir)), userdirs)
Example #12
Source File: package.py From daf-recipes with GNU General Public License v3.0 | 4 votes |
def set_rating(self, user_or_ip, rating): '''Record a user's rating of this package. The caller function is responsible for doing the commit. If a rating is outside the range MAX_RATING - MIN_RATING then a RatingValueException is raised. @param user_or_ip - user object or an IP address string ''' user = None from user import User from rating import Rating, MAX_RATING, MIN_RATING if isinstance(user_or_ip, User): user = user_or_ip rating_query = meta.Session.query(Rating)\ .filter_by(package=self, user=user) else: ip = user_or_ip rating_query = meta.Session.query(Rating)\ .filter_by(package=self, user_ip_address=ip) try: rating = float(rating) except TypeError: raise RatingValueException except ValueError: raise RatingValueException if rating > MAX_RATING or rating < MIN_RATING: raise RatingValueException if rating_query.count(): rating_obj = rating_query.first() rating_obj.rating = rating elif user: rating = Rating(package=self, user=user, rating=rating) meta.Session.add(rating) else: rating = Rating(package=self, user_ip_address=ip, rating=rating) meta.Session.add(rating)
Example #13
Source File: thesportsdb.py From script.module.thesportsdb with GNU General Public License v2.0 | 4 votes |
def Loves(self,user=None,objects=False): if user: userobj = _user.User() userobj.setUsername(user) playerlist = [] teamlist = [] leaguelist = [] eventlist = [] url = '%s/%s/searchloves.php?u=%s' % (API_BASE_URL,API_KEY,str(user)) data = json.load(urllib2.urlopen(url)) edits = data["players"] if edits: for edit in edits: if edit["idTeam"]: teamlist.append(edit["idTeam"]) if edit["idPlayer"]: playerlist.append(edit["idPlayer"]) if edit["idLeague"]: leaguelist.append(edit["idLeague"]) if edit["idEvent"]: eventlist.append(edit["idEvent"]) if objects: _teamlist = [] _playerlist = [] _eventlist = [] _leaguelist = [] if teamlist: for tmid in teamlist: try: _teamlist.append(Api(API_KEY).Lookups().Team(teamid=tmid)[0]) except: pass teamlist = _teamlist del _teamlist if playerlist: for plid in playerlist: try: _playerlist.append(Api(API_KEY).Lookups().Player(playerid=plid)[0]) except: pass playerlist = _playerlist del _playerlist if leaguelist: for lgid in leaguelist: try: _leaguelist.append(Api(API_KEY).Lookups().League(leagueid=lgid)[0]) except: pass leaguelist = _leaguelist del _leaguelist if eventlist: for evid in eventlist: try: _eventlist.append(Api(API_KEY).Lookups().Event(eventid=lgid)[0]) except: pass eventlist = _eventlist del _eventlist userobj.setTeams(teamlist) userobj.setPlayers(playerlist) userobj.setLeagues(leaguelist) userobj.setEvents(eventlist) return userobj else: xbmc.log(msg="[TheSportsDB] A user must be provided", level=xbmc.LOGERROR)