Explorar o código

BatcaveClient: check for valid URL

Helge Jung %!s(int64=9) %!d(string=hai) anos
pai
achega
ba9618229f
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      modules/batcave/client.py

+ 6 - 2
modules/batcave/client.py

@@ -5,8 +5,12 @@ from urllib2 import urlopen, URLError
 
 
 class BatcaveClient(object):
-    def __init__(self, base_url):
-        self.base_url = base_url
+    def __init__(self, url):
+        assert url.startswith("http://") or url.startswith("https://"), \
+            "BATCAVE URL must use http(s) protocol"
+        assert url.endswith("/"), "BATCAVE URL must end with slash."
+
+        self.base_url = url
         self.logger = logging.getLogger('BATCAVE')
 
     def __load_response(self, url, error_context):