9393 id_of ,
9494 get_properties ,
9595 MB ,
96- memoize ,
9796 is_json ,
9897 extract_synapse_id_from_query ,
9998 find_data_file_handle ,
@@ -498,7 +497,7 @@ def login(
498497 cached_sessions .set_most_recent_user (self .credentials .username )
499498
500499 if not silent :
501- profile = self .getUserProfile (refresh = True )
500+ profile = self .getUserProfile ()
502501 # TODO-PY3: in Python2, do we need to ensure that this is encoded in utf-8
503502 self .logger .info (
504503 "Welcome, %s!\n "
@@ -612,26 +611,23 @@ def invalidateAPIKey(self):
612611 if self ._is_logged_in ():
613612 self .restDELETE ("/secretKey" , endpoint = self .authEndpoint )
614613
615- @memoize
614+ @functools . lru_cache ()
616615 def getUserProfile (
617616 self ,
618617 id : Union [str , int , UserProfile , TeamMember ] = None ,
619618 sessionToken : str = None ,
620- refresh : bool = False ,
621619 ) -> UserProfile :
622620 """
623621 Get the details about a Synapse user.
624622 Retrieves information on the current user if 'id' is omitted.
625623 :param id: The 'userId' (aka 'ownerId') of a user or the userName
626624 :param sessionToken: The session token to use to find the user profile
627- :param refresh: If set to True will always fetch the data from Synape otherwise will use cached information
628625 :returns: The user profile for the user of interest.
629626
630627 Example::
631628 my_profile = syn.getUserProfile()
632629 freds_profile = syn.getUserProfile('fredcommo')
633630 """
634-
635631 try :
636632 # if id is unset or a userID, this will succeed
637633 id = "" if id is None else int (id )
@@ -652,7 +648,6 @@ def getUserProfile(
652648 else : # no break
653649 raise ValueError ('Can\' t find user "%s": ' % id )
654650 uri = "/userProfile/%s" % id
655-
656651 return UserProfile (
657652 ** self .restGET (
658653 uri , headers = {"sessionToken" : sessionToken } if sessionToken else None
@@ -2649,7 +2644,7 @@ def _download_from_URL(
26492644 else :
26502645 mode = "wb"
26512646 previouslyTransferred = 0
2652- sig = hashlib .md5 ( )
2647+ sig = hashlib .new ( "md5" , usedforsecurity = False )
26532648
26542649 try :
26552650 with open (temp_destination , mode ) as fd :
@@ -4771,7 +4766,6 @@ def _generate_headers(self, headers=None):
47714766
47724767 if headers is None :
47734768 headers = dict (self .default_headers )
4774-
47754769 headers .update (synapseclient .USER_AGENT )
47764770
47774771 return headers
@@ -4807,6 +4801,7 @@ def _rest_call(
48074801 uri , headers = self ._build_uri_and_headers (
48084802 uri , endpoint = endpoint , headers = headers
48094803 )
4804+
48104805 retryPolicy = self ._build_retry_policy (retryPolicy )
48114806 requests_session = requests_session or self ._requests_session
48124807
@@ -4823,6 +4818,7 @@ def _rest_call(
48234818 verbose = self .debug ,
48244819 ** retryPolicy ,
48254820 )
4821+
48264822 self ._handle_synapse_http_error (response )
48274823 return response
48284824
0 commit comments