9393 id_of ,
9494 get_properties ,
9595 MB ,
96+ memoize ,
9697 is_json ,
9798 extract_synapse_id_from_query ,
9899 find_data_file_handle ,
@@ -497,7 +498,7 @@ def login(
497498 cached_sessions .set_most_recent_user (self .credentials .username )
498499
499500 if not silent :
500- profile = self .getUserProfile ()
501+ profile = self .getUserProfile (refresh = True )
501502 # TODO-PY3: in Python2, do we need to ensure that this is encoded in utf-8
502503 self .logger .info (
503504 "Welcome, %s!\n "
@@ -611,23 +612,26 @@ def invalidateAPIKey(self):
611612 if self ._is_logged_in ():
612613 self .restDELETE ("/secretKey" , endpoint = self .authEndpoint )
613614
614- @functools . lru_cache ()
615+ @memoize
615616 def getUserProfile (
616617 self ,
617618 id : Union [str , int , UserProfile , TeamMember ] = None ,
618619 sessionToken : str = None ,
620+ refresh : bool = False ,
619621 ) -> UserProfile :
620622 """
621623 Get the details about a Synapse user.
622624 Retrieves information on the current user if 'id' is omitted.
623625 :param id: The 'userId' (aka 'ownerId') of a user or the userName
624626 :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
625628 :returns: The user profile for the user of interest.
626629
627630 Example::
628631 my_profile = syn.getUserProfile()
629632 freds_profile = syn.getUserProfile('fredcommo')
630633 """
634+
631635 try :
632636 # if id is unset or a userID, this will succeed
633637 id = "" if id is None else int (id )
@@ -648,6 +652,7 @@ def getUserProfile(
648652 else : # no break
649653 raise ValueError ('Can\' t find user "%s": ' % id )
650654 uri = "/userProfile/%s" % id
655+
651656 return UserProfile (
652657 ** self .restGET (
653658 uri , headers = {"sessionToken" : sessionToken } if sessionToken else None
@@ -2644,7 +2649,7 @@ def _download_from_URL(
26442649 else :
26452650 mode = "wb"
26462651 previouslyTransferred = 0
2647- sig = hashlib .new ( " md5" , usedforsecurity = False )
2652+ sig = hashlib .md5 ( )
26482653
26492654 try :
26502655 with open (temp_destination , mode ) as fd :
@@ -4766,6 +4771,7 @@ def _generate_headers(self, headers=None):
47664771
47674772 if headers is None :
47684773 headers = dict (self .default_headers )
4774+
47694775 headers .update (synapseclient .USER_AGENT )
47704776
47714777 return headers
@@ -4801,7 +4807,6 @@ def _rest_call(
48014807 uri , headers = self ._build_uri_and_headers (
48024808 uri , endpoint = endpoint , headers = headers
48034809 )
4804-
48054810 retryPolicy = self ._build_retry_policy (retryPolicy )
48064811 requests_session = requests_session or self ._requests_session
48074812
@@ -4818,7 +4823,6 @@ def _rest_call(
48184823 verbose = self .debug ,
48194824 ** retryPolicy ,
48204825 )
4821-
48224826 self ._handle_synapse_http_error (response )
48234827 return response
48244828
0 commit comments