aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriit Laes <plaes@plaes.org>2010-08-22 11:13:33 +0300
committerPriit Laes <plaes@plaes.org>2010-08-22 11:13:33 +0300
commitbbcde4a3a4bd411f143e49cf7205061360cd3e8b (patch)
tree9cad7c4bdd7523090df794b73ad440a3bbb7335f
parentClean up request_context hacks in tests (diff)
downloadgsoc2010-grumpy-bbcde4a3a4bd411f143e49cf7205061360cd3e8b.tar.gz
gsoc2010-grumpy-bbcde4a3a4bd411f143e49cf7205061360cd3e8b.tar.bz2
gsoc2010-grumpy-bbcde4a3a4bd411f143e49cf7205061360cd3e8b.zip
Clean up request_context hacks in utils
-rw-r--r--utils/grumpy_init_schema.py9
-rwxr-xr-xutils/grumpy_sync.py12
-rw-r--r--utils/qa_check_developer.py36
-rw-r--r--utils/qa_check_herd.py32
4 files changed, 43 insertions, 46 deletions
diff --git a/utils/grumpy_init_schema.py b/utils/grumpy_init_schema.py
index 0bd96f6..6720e68 100644
--- a/utils/grumpy_init_schema.py
+++ b/utils/grumpy_init_schema.py
@@ -1,9 +1,6 @@
#! /usr/bin/env python
import os, sys
-import urllib2
-from datetime import datetime
-from lxml.html import fromstring
from optparse import OptionParser
path = os.path.join(os.path.dirname(__file__), os.path.pardir)
@@ -19,6 +16,6 @@ if __name__ == '__main__':
if len(args) != 1:
parser.error("provide path to configuration file as first argument")
sys.exit(1)
- with app.test_request_context():
- app.config.from_pyfile(args[0])
- db.create_all()
+ app.test_request_context().push()
+ app.config.from_pyfile(args[0])
+ db.create_all()
diff --git a/utils/grumpy_sync.py b/utils/grumpy_sync.py
index a0409e1..41fba51 100755
--- a/utils/grumpy_sync.py
+++ b/utils/grumpy_sync.py
@@ -181,9 +181,9 @@ if __name__ == '__main__':
if len(args) != 1:
parser.error("provide path to configuration file as first argument")
sys.exit(1)
- with app.test_request_context():
- app.config.from_pyfile(args[0])
- if 'GRUMPY_PORTAGE_DIR' in app.config.keys():
- portagedir = app.config['GRUMPY_PORTAGE_DIR']
- if os.path.isdir(portagedir):
- main(portagedir)
+ app.test_request_context().push()
+ app.config.from_pyfile(args[0])
+ if 'GRUMPY_PORTAGE_DIR' in app.config.keys():
+ portagedir = app.config['GRUMPY_PORTAGE_DIR']
+ if os.path.isdir(portagedir):
+ main(portagedir)
diff --git a/utils/qa_check_developer.py b/utils/qa_check_developer.py
index e31f533..cd0b436 100644
--- a/utils/qa_check_developer.py
+++ b/utils/qa_check_developer.py
@@ -60,21 +60,21 @@ if __name__ == '__main__':
devs = download_and_parse_devs()
b0rks = []
timestamp = datetime.now()
- with app.test_request_context():
- # Load configuration
- app.config.from_pyfile(args[0])
- # Fetch list of developers from db
- dbdevs = [d.email for d in Developer.query.filter( \
- Developer.email.like('%@gentoo.org')).all()]
- for dev in dbdevs:
- if dev in devs:
- devs.remove(dev)
- else:
- b0rks.append(dev)
- insert_issues(b0rks)
- # Clean up issues < timestamp
- gc_collect(timestamp)
- # Update settings and add info about last run..
- Setting.query.filter_by(name=PLUGIN_NAME).delete(False)
- db.session.add(Setting(PLUGIN_NAME, str(timestamp)))
- db.session.commit()
+ app.test_request_context().push()
+ # Load configuration
+ app.config.from_pyfile(args[0])
+ # Fetch list of developers from db
+ dbdevs = [d.email for d in Developer.query.filter( \
+ Developer.email.like('%@gentoo.org')).all()]
+ for dev in dbdevs:
+ if dev in devs:
+ devs.remove(dev)
+ else:
+ b0rks.append(dev)
+ insert_issues(b0rks)
+ # Clean up issues < timestamp
+ gc_collect(timestamp)
+ # Update settings and add info about last run..
+ Setting.query.filter_by(name=PLUGIN_NAME).delete(False)
+ db.session.add(Setting(PLUGIN_NAME, str(timestamp)))
+ db.session.commit()
diff --git a/utils/qa_check_herd.py b/utils/qa_check_herd.py
index b8bdf5f..33c0f9f 100644
--- a/utils/qa_check_herd.py
+++ b/utils/qa_check_herd.py
@@ -68,19 +68,19 @@ if __name__ == '__main__':
herds = download_and_parse_herds()
b0rks = []
timestamp = datetime.now()
- with app.test_request_context():
- # Load configuration
- app.config.from_pyfile(args[0])
- # Fetch list of herds from db
- for herd in Herd.query.all():
- if herd.name in herds:
- herds.remove(herd.name)
- else:
- b0rks.append(herd.name)
- update_issues(b0rks)
- # Clean up issues < timestamp
- gc_collect(timestamp)
- # Update settings and add info about last run..
- Setting.query.filter_by(name=PLUGIN_NAME).delete(False)
- db.session.add(Setting(PLUGIN_NAME, str(timestamp)))
- db.session.commit()
+ app.test_request_context().push()
+ # Load configuration
+ app.config.from_pyfile(args[0])
+ # Fetch list of herds from db
+ for herd in Herd.query.all():
+ if herd.name in herds:
+ herds.remove(herd.name)
+ else:
+ b0rks.append(herd.name)
+ update_issues(b0rks)
+ # Clean up issues < timestamp
+ gc_collect(timestamp)
+ # Update settings and add info about last run..
+ Setting.query.filter_by(name=PLUGIN_NAME).delete(False)
+ db.session.add(Setting(PLUGIN_NAME, str(timestamp)))
+ db.session.commit()