[sysadmin-bin] Add a script that will generate the mirrors list from the relevant mysql database
- From: Andrea Veri <av src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Add a script that will generate the mirrors list from the relevant mysql database
- Date: Sat, 14 Sep 2013 14:54:24 +0000 (UTC)
commit c7a37883c648494dc15777d84163b4b61973386a
Author: Andrea Veri <av gnome org>
Date: Sat Sep 14 16:54:08 2013 +0200
Add a script that will generate the mirrors list from the relevant mysql database
generate-mirror-list.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/generate-mirror-list.py b/generate-mirror-list.py
new file mode 100755
index 0000000..f4f2fac
--- /dev/null
+++ b/generate-mirror-list.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import MySQLdb
+from time import gmtime, strftime
+
+file = open('/home/admin/secret/mango','r')
+lines = file.readlines()
+
+for line in lines:
+ if line.find("mysql_password") > -1:
+ dirty_password = line.split()
+ mirrors_password = str(dirty_password)
+
+ sanitize_file=["\'","(",")","mysql_password","=","[","]","\"",";"]
+ for i in range(len(sanitize_file)):
+ mirrors_password = mirrors_password.replace(sanitize_file[i],"")
+file.close()
+
+db = MySQLdb.connect(host="drawable-back",
+ user="mirrors",
+ passwd=mirrors_password,
+ db="mirrors")
+cur = db.cursor()
+
+continents_list = ['Europe', 'Asia', 'South America', 'United States and Canada', 'Australia', 'Other']
+time = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
+
+f = open ('/ftp/pub/GNOME/MIRRORS', 'w' )
+f.write('GNOME HTTP and FTP mirrors list' + '\n')
+
+for location in continents_list:
+ f.write('\n' + location + '\n')
+ cur.execute("select url from ftpmirrors where location = '%s' and active = '1'" % location)
+ result = cur.fetchall()
+
+ if not result:
+ f.write('\n' + '\t' + "No available mirrors for this country / continent as of now." + '\n')
+ else:
+ for i in result:
+ f.write('\n' + '\t' + (str(i[0])))
+ f.write('\n')
+
+f.write('\n')
+f.write('------------------------------------------------------------' + '\n')
+f.write('Maintained by the Gnome Systems Administration Team <gnome-sysadmin gnome org>' + '\n')
+f.write('Last updated: %s' % time + '\n')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]