Allow DB connection values to come from the environment

Stop hardcoding everything everywhere for those of us that don't use the
localhost/aur/aur/AUR setup. Also allow for the dummy data to be created
in the reload script if it does not exist. Finally, remove two
assumptions that the AUR database already exists.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Dan McGee 2011-03-01 09:59:03 -06:00 committed by Lukas Fleischer
parent b9690972d0
commit abd41bbb51
3 changed files with 33 additions and 21 deletions

View file

@ -9,13 +9,20 @@ usage: gendummydata.py outputfilename.sql
# package names. It generates the SQL statements to
# insert these users/packages into the AUR database.
#
import random
import time
import os
import sys
import cStringIO
import commands
DBUG = 1
SEED_FILE = "/usr/share/dict/words"
DB_HOST = "localhost"
DB_NAME = "AUR"
DB_USER = "aur"
DB_PASS = "aur"
DB_HOST = os.getenv("DB_HOST", "localhost")
DB_NAME = os.getenv("DB_NAME", "AUR")
DB_USER = os.getenv("DB_USER", "aur")
DB_PASS = os.getenv("DB_PASS", "aur")
USER_ID = 5 # Users.ID of first bogus user
PKG_ID = 1 # Packages.ID of first package
MAX_USERS = 300 # how many users to 'register'
@ -39,14 +46,6 @@ RANDOM_LOCS = ("pub", "release", "files", "downloads", "src")
FORTUNE_CMD = "/usr/bin/fortune -l"
import random
import time
import os
import sys
import cStringIO
import commands
if len(sys.argv) != 2:
sys.stderr.write("Missing output filename argument");
raise SystemExit
@ -60,6 +59,7 @@ out.write("BEGIN;\n")
#
if not os.path.exists(SEED_FILE):
sys.stderr.write("Please install the 'words' Arch package\n");
raise SystemExit
# Make sure database access will be available
#