SynologyDSM/SynologyDSM.py
def _get_url(self, url, retry_on_error=True):
        """Function to handle sessions for a GET request"""
        # Check if we failed to request the url or need to login
        if self.access_token is None or \
           self._session is None or \
           self._session_error:
            # Clear Access Token en reset session error
            self.access_token = None
            self._session_error = False

            # First Reset the session
            if self._session is not None:
                self._session = None
            self._debuglog("Creating New Session")
            self._session = requests.Session()
            
            # disable SSL certificate verification
            if self._use_https:
                self._session.verify = False


            # We Created a new Session so login
            if self._login() is False:
                self._session_error = True
                self._debuglog("Login Failed, unable to process request")
                return

        # Now request the data
        response = self._execute_get_url(url)
        if (self._session_error or response is None) and retry_on_error:
            self._debuglog("Error occured, retrying...")
            self._get_url(url, False)

        return response
def _get_url(self, url, retry_on_error=True):
        """Function to handle sessions for a GET request"""
        # Check if we failed to request the url or need to login
        if self.access_token is None or \
           self._session is None or \
           self._session_error:
            # Clear Access Token en reset session error
            self.access_token = None
            self._session_error = False

            # First Reset the session
            if self._session is not None:
                self._session = None
            self._debuglog("Creating New Session")
            self._session = requests.Session()
            
            # disable SSL certificate verification
            if self._use_https:
                self._session.verify = False


            # We Created a new Session so login
            if self._login() is False:
                self._session_error = True
                self._debuglog("Login Failed, unable to process request")
                return

        # Now request the data
        response = self._execute_get_url(url)
        if (self._session_error or response is None) and retry_on_error:
            self._debuglog("Error occured, retrying...")
            self._get_url(url, False)

        return response
def _get_url ( self , url , retry_on_error = True ) : # Check if we failed to request the url or need to login
 if self . access_token is None or self . _session is None or self . _session_error : # Clear Access Token en reset session error
 self . access_token = None self . _session_error = False # First Reset the session
 if self . _session is not None : self . _session = None self . _debuglog ( "Creating New Session" ) self . _session = requests . Session ( ) # disable SSL certificate verification
 if self . _use_https : self . _session . verify = False # We Created a new Session so login
 if self . _login ( ) is False : self . _session_error = True self . _debuglog ( "Login Failed, unable to process request" ) return # Now request the data
 response = self . _execute_get_url ( url ) if ( self . _session_error or response is None ) and retry_on_error : self . _debuglog ( "Error occured, retrying..." ) self . _get_url ( url , False ) return response
Function to handle sessions for a GET request
Function to handle sessions for a GET request