summaryrefslogtreecommitdiffstats
path: root/support/schema/gendummydata.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-03-01 16:59:03 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2011-03-04 10:29:14 +0100
commitabd41bbb51ea2340bd06648cc0cd5b9144cce91e (patch)
treeafbaae2fb8cc2bbdc71ccbe9b87419fc47cee270 /support/schema/gendummydata.py
parentb9690972d084c09f5cc080322db29c54be872045 (diff)
downloadaur-abd41bbb51ea2340bd06648cc0cd5b9144cce91e.tar.gz
aur-abd41bbb51ea2340bd06648cc0cd5b9144cce91e.tar.xz
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>
Diffstat (limited to 'support/schema/gendummydata.py')
-rwxr-xr-xsupport/schema/gendummydata.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index d51b16c8..cdf365bc 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
#