From abd41bbb51ea2340bd06648cc0cd5b9144cce91e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 1 Mar 2011 09:59:03 -0600 Subject: 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 Signed-off-by: Lukas Fleischer --- support/schema/gendummydata.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'support/schema/gendummydata.py') diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py index d51b16c..cdf365b 100755 --- a/support/schema/gendummydata.py +++ b/support/schema/gendummydata.py @@ -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 # -- cgit v1.2.3-54-g00ecf