From ceb9ff5ba1f4191a7533d2ed6e1e8a9faf579d4c Mon Sep 17 00:00:00 2001 From: Tom Gross Date: Sat, 24 Jun 2023 18:06:25 +0200 Subject: [PATCH] readd --- src/pcloud/api.py | 3 +++ src/pcloud/tests/server.py | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pcloud/api.py b/src/pcloud/api.py index 58283f6..487ce95 100644 --- a/src/pcloud/api.py +++ b/src/pcloud/api.py @@ -357,6 +357,9 @@ def deletetoken(self, **kwargs): return self._do_request("deletetoken", **kwargs) # Streaming + def getfilelink(self, **kwargs): + raise OnlyPcloudError(ONLY_PCLOUD_MSG) + def getvideolink(self, **kwargs): raise OnlyPcloudError(ONLY_PCLOUD_MSG) diff --git a/src/pcloud/tests/server.py b/src/pcloud/tests/server.py index 0a468e7..846f64d 100644 --- a/src/pcloud/tests/server.py +++ b/src/pcloud/tests/server.py @@ -10,14 +10,19 @@ class MockHandler(BaseHTTPRequestHandler): # Handler for GET requests def do_GET(self): # Send the json message - method = self.path[1:].split("?") + methodparts = self.path[1:].split("?") basepath = path.join(path.dirname(__file__), "data") - safemethod = path.realpath(method[0] + ".json") + method = path.join(basepath, methodparts[0] + ".json") + safemethod = path.realpath(method) prefix = path.commonpath((basepath, safemethod)) if prefix == basepath: - code = 200 - with open(path.join(basepath, safemethod)) as f: - data = f.read() + try: + code = 200 + with open(safemethod) as f: + data = f.read() + except FileNotFoundError: + code = 404 + data = '{"Error": "Path not found or not accessible!"}' else: code = 404 data = '{"Error": "Path not found or not accessible!"}'