autoimport: support protocols besides http
authorHelmut Grohne <helmut@subdivi.de>
Mon, 21 Apr 2014 10:50:15 +0000 (12:50 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Mon, 21 Apr 2014 10:50:15 +0000 (12:50 +0200)
autoimport.py

index d44c012..9c4c73e 100755 (executable)
@@ -60,7 +60,7 @@ def process_pkg(name, pkgdict, outpath):
     importcmd = ["python", "importpkg.py"]
     if "sha256hash" in pkgdict:
         importcmd.extend(["-H", pkgdict["sha256hash"]])
     importcmd = ["python", "importpkg.py"]
     if "sha256hash" in pkgdict:
         importcmd.extend(["-H", pkgdict["sha256hash"]])
-    if filename.startswith("http://"):
+    if filename.startswith(("http://", "https://", "ftp://", "file://")):
         with open(outpath, "w") as outp:
             dl = subprocess.Popen(["curl", "-s", filename],
                                   stdout=subprocess.PIPE, close_fds=True)
         with open(outpath, "w") as outp:
             dl = subprocess.Popen(["curl", "-s", filename],
                                   stdout=subprocess.PIPE, close_fds=True)
@@ -95,7 +95,7 @@ def main():
     pkgs = {}
     for d in args:
         print("processing %s" % d)
     pkgs = {}
     for d in args:
         print("processing %s" % d)
-        if d.startswith("http://"):
+        if d.startswith(("http://", "https://", "ftp://", "file://")):
             process_http(pkgs, d)
         elif os.path.isdir(d):
             process_dir(pkgs, d)
             process_http(pkgs, d)
         elif os.path.isdir(d):
             process_dir(pkgs, d)