118118 id_of ,
119119 get_properties ,
120120 MB ,
121- memoize ,
122121 is_json ,
123122 extract_synapse_id_from_query ,
124123 find_data_file_handle ,
@@ -525,7 +524,7 @@ def login(
525524 cached_sessions .set_most_recent_user (self .credentials .username )
526525
527526 if not silent :
528- profile = self .getUserProfile (refresh = True )
527+ profile = self .getUserProfile ()
529528 # TODO-PY3: in Python2, do we need to ensure that this is encoded in utf-8
530529 self .logger .info (
531530 "Welcome, %s!\n "
@@ -639,21 +638,19 @@ def invalidateAPIKey(self):
639638 if self ._is_logged_in ():
640639 self .restDELETE ("/secretKey" , endpoint = self .authEndpoint )
641640
642- @memoize
643- def getUserProfile (self , id = None , sessionToken = None , refresh = False ):
641+ @functools . lru_cache ()
642+ def getUserProfile (self , id = None , sessionToken = None ):
644643 """
645644 Get the details about a Synapse user.
646645 Retrieves information on the current user if 'id' is omitted.
647646 :param id: The 'userId' (aka 'ownerId') of a user or the userName
648647 :param sessionToken: The session token to use to find the user profile
649- :param refresh: If set to True will always fetch the data from Synape otherwise will use cached information
650648 :returns: The user profile for the user of interest.
651649
652650 Example::
653651 my_profile = syn.getUserProfile()
654652 freds_profile = syn.getUserProfile('fredcommo')
655653 """
656-
657654 try :
658655 # if id is unset or a userID, this will succeed
659656 id = "" if id is None else int (id )
@@ -674,7 +671,6 @@ def getUserProfile(self, id=None, sessionToken=None, refresh=False):
674671 else : # no break
675672 raise ValueError ('Can\' t find user "%s": ' % id )
676673 uri = "/userProfile/%s" % id
677-
678674 return UserProfile (
679675 ** self .restGET (
680676 uri , headers = {"sessionToken" : sessionToken } if sessionToken else None
@@ -2589,7 +2585,7 @@ def _download_from_URL(
25892585 else :
25902586 mode = "wb"
25912587 previouslyTransferred = 0
2592- sig = hashlib .md5 ()
2588+ sig = hashlib .md5 (usedforsecurity = False )
25932589
25942590 try :
25952591 with open (temp_destination , mode ) as fd :
@@ -4681,7 +4677,6 @@ def _generate_headers(self, headers=None):
46814677
46824678 if headers is None :
46834679 headers = dict (self .default_headers )
4684-
46854680 headers .update (synapseclient .USER_AGENT )
46864681
46874682 return headers
@@ -4717,6 +4712,7 @@ def _rest_call(
47174712 uri , headers = self ._build_uri_and_headers (
47184713 uri , endpoint = endpoint , headers = headers
47194714 )
4715+
47204716 retryPolicy = self ._build_retry_policy (retryPolicy )
47214717 requests_session = requests_session or self ._requests_session
47224718
@@ -4733,6 +4729,7 @@ def _rest_call(
47334729 verbose = self .debug ,
47344730 ** retryPolicy ,
47354731 )
4732+
47364733 self ._handle_synapse_http_error (response )
47374734 return response
47384735
0 commit comments