]> gitweb.fluxo.info Git - ckandumper.git/commitdiff
Limit rate per download
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 8 May 2019 17:14:37 +0000 (14:14 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 8 May 2019 17:14:37 +0000 (14:14 -0300)
ckandumper

index c85a53d0e53ce0c367b606ff3e3aeb97ec6ae159..1ec05d3e27bdd54da843c51bc254f4a635567579 100755 (executable)
@@ -36,9 +36,12 @@ class ckandumper:
     self.tag_list     = '/api/3/action/tag_list'
     self.tag_show     = '/api/3/action/tag_show?'
 
+    if args.limit_rate != None
+        self.limit_rate = '--limit-rate=' + args.limit_rate
+
   # Using wget as it is more reliable
   def download(self, url, local_filename):
-    subprocess.call('/usr/bin/wget -c -O "' + local_filename + '" ' + url, shell=True)
+    subprocess.call('/usr/bin/wget ' + self.limit_rate + ' -c -O "' + local_filename + '" ' + url, shell=True)
 
   def ensuredir(self, dest):
     # Ensure that the destination folder exists
@@ -128,6 +131,7 @@ if __name__ == "__main__":
   parser = argparse.ArgumentParser(description='Dump CKAN metadata and datasets.')
   parser.add_argument('url',  nargs='+', help='CKAN instance URL')
   parser.add_argument('dest', nargs='+', help='Destination folder')
+  parser.add_argument("--limit-rate",    help="Limit the download speed to amount bytes per second, per download")
   args = parser.parse_args()
 
   # Dispatch