summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/get_debian_mirrors.py14
-rwxr-xr-xutils/get_ubuntu_mirrors.py20
-rwxr-xr-xutils/get_ubuntu_mirrors_from_lp.py15
-rwxr-xr-xutils/mirrortest4
4 files changed, 28 insertions, 25 deletions
diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py
index ccddf8ed..2e3c7296 100755
--- a/utils/get_debian_mirrors.py
+++ b/utils/get_debian_mirrors.py
@@ -2,23 +2,23 @@
#
# get_debian_mirrors.py
#
-# Download the latest list with available mirrors from the Debian
+# Download the latest list with available mirrors from the Debian
# website and extract the hosts from the raw page
#
# Copyright (c) 2006 Free Software Foundation Europe
#
# Author: Sebastian Heinlein <glatzor@ubuntu.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -39,11 +39,13 @@ req = urllib2.Request("http://www.debian.org/mirror/mirrors_full")
match = re.compile("^.*>([A-Za-z0-9-.\/_]+)<\/a>.*\n$")
match_location = re.compile('^<strong><a name="([A-Z]+)">.*')
+
def add_sites(line, proto, sites, mirror_type):
path = match.sub(r"\1", line)
for site in sites:
mirror_type.append("%s://%s%s\n" % (proto, site.lstrip(), path))
+
try:
print "Downloading mirrors list from the Debian website..."
uri=urllib2.urlopen(req)
diff --git a/utils/get_ubuntu_mirrors.py b/utils/get_ubuntu_mirrors.py
index 62b18ba6..ddd1e369 100755
--- a/utils/get_ubuntu_mirrors.py
+++ b/utils/get_ubuntu_mirrors.py
@@ -8,17 +8,17 @@
# Copyright (c) 2006 Free Software Foundation Europe
#
# Author: Sebastian Heinlein <glatzor@ubuntu.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -42,10 +42,10 @@ try:
uri=urllib2.urlopen(req)
p = re.compile('^.*((http|ftp):\/\/[A-Za-z0-9-.:\/_]+).*\n*$')
for line in uri.readlines():
- if r"[[Anchor(dvd-images)]]" in line:
- break
- if "http://" in line or "ftp://" in line:
- mirrors.append(p.sub(r"\1", line))
+ if r"[[Anchor(dvd-images)]]" in line:
+ break
+ if "http://" in line or "ftp://" in line:
+ mirrors.append(p.sub(r"\1", line))
uri.close()
except:
print "Failed to download or extract the mirrors list!"
@@ -57,5 +57,3 @@ for mirror in mirrors:
list.write("%s\n" % mirror)
list.close()
print "Done."
-
-
diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py
index 7d9116f2..b912f28d 100755
--- a/utils/get_ubuntu_mirrors_from_lp.py
+++ b/utils/get_ubuntu_mirrors_from_lp.py
@@ -8,17 +8,17 @@
# Copyright (c) 2006 Free Software Foundation Europe
#
# Author: Sebastian Heinlein <glatzor@ubuntu.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -64,11 +64,13 @@ content_splits = re.split(r'<tr class="highlighted"',
'id="mirrors_list">.+?</table>',
content)[0])
lines=[]
+
+
def find(split):
country = re.search(r"<strong>(.+?)</strong>", split)
if not country:
return
- if countries.has_key(country.group(1)):
+ if country.group(1) in countries:
lines.append("#LOC:%s" % countries[country.group(1)].upper())
else:
lines.append("#LOC:%s" % country.group(1))
@@ -78,6 +80,7 @@ def find(split):
split)
map(lambda u: lines.append(u[0]), urls)
+
map(find, content_splits)
print "Writing local mirrors list: %s" % list_path
diff --git a/utils/mirrortest b/utils/mirrortest
index 75ef917b..a724c81f 100755
--- a/utils/mirrortest
+++ b/utils/mirrortest
@@ -24,8 +24,8 @@ class MirrorTest:
host = mirror.hostname
except:
continue
- print "Pinging (Worker %s) %s (%s) ..." % (self.id,
- host,
+ print "Pinging (Worker %s) %s (%s) ..." % (self.id,
+ host,
MirrorTest.completed_pings)
commando = os.popen("ping -q -c 4 -W 2 -i 0.3 %s" % host,
"r")