check-mirrors return-mirrorlist.py,1.5,1.6
Seth Vidal (skvidal)
fedora-extras-commits at redhat.com
Mon Jul 17 20:43:27 UTC 2006
Author: skvidal
Update of /cvs/fedora/check-mirrors
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7419
Modified Files:
return-mirrorlist.py
Log Message:
make sure global is returned if the requesting url does not specify a
country in the get
Index: return-mirrorlist.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/return-mirrorlist.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- return-mirrorlist.py 13 Jul 2006 15:06:34 -0000 1.5
+++ return-mirrorlist.py 17 Jul 2006 20:43:25 -0000 1.6
@@ -114,12 +114,13 @@
# open and return
# otherwise return global
-
+ country_specified = False
if not form.has_key('country'):
reqip = os.environ['REMOTE_ADDR']
gi = GeoIP.new(GeoIP.GEOIP_STANDARD)
country = gi.country_code_by_addr(reqip)
else:
+ country_specified = True
country = form['country'].value
if not country:
@@ -127,16 +128,25 @@
return_file = '%s/%s-%s-%s.txt' % (lists_path, prefix, country, arch)
rp = os.path.realpath(return_file)
+
+ # if they didn't specify a country name in the variables and their country code
+ # doesn't exist - then give them global
- if not rp.startswith(lists_path):
- print "# someone is messing with the path via get-string %s not inside %s" % (rp, lists_path)
- sys.exit()
-
+ if country != 'global'and not country_specified and not os.path.exists(rp):
+ country = 'global'
+ return_file = '%s/%s-%s-%s.txt' % (lists_path, prefix, country, arch)
+ rp = os.path.realpath(return_file)
+
if not os.path.exists(return_file):
print '# no file found for repo = %s, country = %s, arch = %s' % (repo, country,arch)
print '# filename was: %s' % os.path.basename(return_file)
sys.exit()
-
+
+
+ if not rp.startswith(lists_path):
+ print "# someone is messing with the path via get-string %s not inside %s" % (rp, lists_path)
+ sys.exit()
+
print '# repo = %s country = %s arch = %s ' % (repo, country, arch)
fo = open(return_file, 'r')
for line in fo.readlines():
More information about the fedora-extras-commits
mailing list