Add checkMirrors script by davivercillo.
This commit is contained in:
parent
13f9f2450b
commit
20bf0ce068
2 changed files with 57 additions and 0 deletions
4
scripts/checkMirrors/README
Normal file
4
scripts/checkMirrors/README
Normal file
|
@ -0,0 +1,4 @@
|
|||
Mirror checking script by davivercillo
|
||||
======================================
|
||||
Currently only checks the mirrors returned in the mirrorlist, perhaps add a
|
||||
&country=global to try and get all mirrors back.
|
53
scripts/checkMirrors/checkMirrors.py
Normal file
53
scripts/checkMirrors/checkMirrors.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
#! /usr/bin/env python
|
||||
#
|
||||
# [Author]
|
||||
# Davi Vercillo C. Garcia (davivercillo@gmail.com)
|
||||
#
|
||||
# [License]
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print "Use: ./mirror_checker.py updates 11 x86_64"
|
||||
sys.exit(-1)
|
||||
|
||||
main_mirror = "http://download.fedora.redhat.com/pub/fedora/linux/%s/%s/%s/repodata/"
|
||||
mirror_list = "http://mirrors.fedoraproject.org/mirrorlist?path=/pub/fedora/linux/%s/%s/%s/repodata"
|
||||
xml_file = "repomd.xml"
|
||||
|
||||
directory = sys.argv[1]
|
||||
version = sys.argv[2]
|
||||
architecture = sys.argv[3]
|
||||
|
||||
try:
|
||||
mirrors = urllib.urlopen(mirror_list % (directory, version, architecture)).read().split("\n")
|
||||
repomd = urllib.urlopen(main_mirror % (directory, version, architecture) + xml_file).read()
|
||||
except Exception, err:
|
||||
print "[ERROR] Cannot get info from URLs. Please check the parameters."
|
||||
sys.exit(-1)
|
||||
|
||||
print "\nUsing:", main_mirror % (directory, version, architecture), "\n"
|
||||
for url in mirrors:
|
||||
if "#" in url or not url:
|
||||
continue
|
||||
if urllib.urlopen(url + xml_file).read() == repomd:
|
||||
print url, "[Good]"
|
||||
else:
|
||||
print url, "[Bad]"
|
||||
print "\n"
|
||||
sys.exit(0)
|
Loading…
Add table
Add a link
Reference in a new issue