SynologyDSM/SynologyDSM.py
def _execute_get_url(self, request_url, append_sid=True):
        """Function to execute and handle a GET request"""
        # Prepare Request
        self._debuglog("Requesting URL: '" + request_url + "'")
        if append_sid:
            self._debuglog("Appending access_token (SID: " +
                           self.access_token + ") to url")
            request_url = "%s&_sid=%s" % (
                request_url, self.access_token)

        # Execute Request
        try:
            resp = self._session.get(request_url)
            self._debuglog("Request executed: " + str(resp.status_code))
            if resp.status_code == 200:
                # We got a response
                json_data = json.loads(resp.text)

                if json_data["success"]:
                    self._debuglog("Succesfull returning data")
                    self._debuglog(str(json_data))
                    return json_data
                else:
                    if json_data["error"]["code"] in {105, 106, 107, 119}:
                        self._debuglog("Session error: " +
                                       str(json_data["error"]["code"]))
                        self._session_error = True
                    else:
                        self._debuglog("Failed: " + resp.text)
            else:
                # We got a 404 or 401
                return None
        #pylint: disable=bare-except
        except:
            return None
def _execute_get_url(self, request_url, append_sid=True):
        # Prepare Request
        self._debuglog("Requesting URL: '" + request_url + "'")
        if append_sid:
            self._debuglog("Appending access_token (SID: " +
                           self.access_token + ") to url")
            request_url = "%s&_sid=%s" % (
                request_url, self.access_token)

        # Execute Request
        try:
            resp = self._session.get(request_url)
            self._debuglog("Request executed: " + str(resp.status_code))
            if resp.status_code == 200:
                # We got a response
                json_data = json.loads(resp.text)

                if json_data["success"]:
                    self._debuglog("Succesfull returning data")
                    self._debuglog(str(json_data))
                    return json_data
                else:
                    if json_data["error"]["code"] in {105, 106, 107, 119}:
                        self._debuglog("Session error: " +
                                       str(json_data["error"]["code"]))
                        self._session_error = True
                    else:
                        self._debuglog("Failed: " + resp.text)
            else:
                # We got a 404 or 401
                return None
        #pylint: disable=bare-except
        except:
            return None
def _execute_get_url ( self , request_url , append_sid = True ) : # Prepare Request
 self . _debuglog ( "Requesting URL: '" + request_url + "'" ) if append_sid : self . _debuglog ( "Appending access_token (SID: " + self . access_token + ") to url" ) request_url = "%s&_sid=%s" % ( request_url , self . access_token ) # Execute Request
 try : resp = self . _session . get ( request_url ) self . _debuglog ( "Request executed: " + str ( resp . status_code ) ) if resp . status_code == 200 : # We got a response
 json_data = json . loads ( resp . text ) if json_data [ "success" ] : self . _debuglog ( "Succesfull returning data" ) self . _debuglog ( str ( json_data ) ) return json_data else : if json_data [ "error" ] [ "code" ] in { 105 , 106 , 107 , 119 } : self . _debuglog ( "Session error: " + str ( json_data [ "error" ] [ "code" ] ) ) self . _session_error = True else : self . _debuglog ( "Failed: " + resp . text ) else : # We got a 404 or 401
 return None #pylint: disable=bare-except
 except : return None
Function to execute and handle a GET request
Function to execute and handle a GET request