You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2011/07/12 20:45:31 UTC
svn commit: r1145717 - /incubator/rat/eye/trunk/download-from-repo.py
Author: rdonkin
Date: Tue Jul 12 18:45:31 2011
New Revision: 1145717
URL: http://svn.apache.org/viewvc?rev=1145717&view=rev
Log:
Script that downloads release artifacts from a distribtion repository. Requires wget and is not yet OOP.
Added:
incubator/rat/eye/trunk/download-from-repo.py (with props)
Added: incubator/rat/eye/trunk/download-from-repo.py
URL: http://svn.apache.org/viewvc/incubator/rat/eye/trunk/download-from-repo.py?rev=1145717&view=auto
==============================================================================
--- incubator/rat/eye/trunk/download-from-repo.py (added)
+++ incubator/rat/eye/trunk/download-from-repo.py Tue Jul 12 18:45:31 2011
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import sys
+import urlparse
+import os.path
+import shutil
+import subprocess
+
+def endWithSlash(url):
+ if url.endswith("/"):
+ return url
+ else:
+ return url + "/"
+
+def toAbsolute(url, prefixForRelativePaths):
+ if url.startswith("http"):
+ return url
+ elif url.startswith("/"):
+ return prefixForRelativePaths + url
+ else:
+ return prefixForRelativePaths + "/" + url
+
+def normalise(baseUrl):
+ return toAbsolute(endWithSlash(baseUrl), "https://repository.apache.org/content/repositories")
+
+def hostname(url):
+ return urlparse.urlparse(url).hostname
+
+def clean(path):
+ if os.path.exists(path):
+ sys.stdout.write("Cleaning then downloading to directory: {0}\n".format(path))
+ shutil.rmtree(path)
+ else:
+ sys.stdout.write("Downloading to directory: {0}\n".format(path))
+
+def download(url):
+ relativeDownloadPath = hostname(url)
+ clean(relativeDownloadPath)
+ sys.stdout.write("Beginning download from {0}\n".format(url))
+ sys.exit(subprocess.call(['wget',
+ '--limit-rate=100k', '--recursive',
+ '--level=8', '--domains=repository.apache.org',
+ '--no-parent', '-e', 'robots=off', '--wait', '1', url]))
+
+
+def runDownload(baseUrl):
+ download(normalise(baseUrl))
+ sys.exit(0)
+
+def usage():
+ sys.stderr.write("Usage: <repository URL>\n")
+ sys.exit(1)
+
+if len(sys.argv) == 2:
+ runDownload(sys.argv[1])
+else:
+ usage()
+
Propchange: incubator/rat/eye/trunk/download-from-repo.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/rat/eye/trunk/download-from-repo.py
------------------------------------------------------------------------------
svn:executable = *