Skip to content

Instantly share code, notes, and snippets.

@duk3luk3
Created November 9, 2017 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duk3luk3/f247be7844646929729bf2ed5d9d3dd7 to your computer and use it in GitHub Desktop.
Save duk3luk3/f247be7844646929729bf2ed5d9d3dd7 to your computer and use it in GitHub Desktop.
# Script to download most expected files in the database from production server.
# Run from within an container with db access like this:
# docker run -it --rm --name python_migrate --network faf_faf --network host -v /opt/faf/data/content:/content -v /opt/faf/scripts:/scripts python:latest bash
# and install mysql lib with apt-get update && apt-get install python-mysqldb
import MySQLdb
import urllib
import os
db = MySQLdb.connect("172.19.0.3","root","banana","faf_lobby")
cursor = db.cursor()
cursor.execute("select filename from map_version")
print("Maps")
while True:
mapfile = cursor.fetchone()
if mapfile == None:
break
destname = "/content/%s" % mapfile
if not os.path.exists(destname):
try:
os.makedirs(os.path.dirname(destname))
except:
pass
print(" downloading %s to %s" % (mapfile, destname))
urllib.urlretrieve("http://content.faforever.com/%s" % mapfile, destname)
print("Mods")
cursor.execute("select filename from mod_version")
while True:
modfile = cursor.fetchone()
if modfile == None:
break
destname = "/content/%s" % modfile
if not os.path.exists(destname):
try:
os.makedirs(os.path.dirname(destname))
except:
pass
print(" downloading %s to %s" % (modfile, destname))
urllib.urlretrieve("http://content.faforever.com/%s" % modfile, destname)
print("FAF")
cursor.execute("select name from updates_faf_files")
while True:
updatefile = cursor.fetchone()
if updatefile == None:
break
destname = "/content/faf/updaterNew/updates_faf_files/%s" % updatefile
if not os.path.exists(destname):
try:
os.makedirs(os.path.dirname(destname))
except:
pass
print(" downloading %s to %s" % (updatefile, destname))
urllib.urlretrieve("http://content.faforever.com/faf/updaterNew/updates_faf_files/%s" % updatefile, destname)
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment