diff options
author | Priit Laes <plaes@plaes.org> | 2010-07-09 14:08:39 +0300 |
---|---|---|
committer | Priit Laes <plaes@plaes.org> | 2010-07-09 14:08:39 +0300 |
commit | aff2d813947e5b87acde461ec009b3a20dcfac90 (patch) | |
tree | f73ed75fcf580d7befcdbbf4654ae3fb2afaf8dd | |
parent | Move grumpy.cfg to separate dir (diff) | |
download | gsoc2010-grumpy-aff2d813947e5b87acde461ec009b3a20dcfac90.tar.gz gsoc2010-grumpy-aff2d813947e5b87acde461ec009b3a20dcfac90.tar.bz2 gsoc2010-grumpy-aff2d813947e5b87acde461ec009b3a20dcfac90.zip |
Added configuration file handling
-rw-r--r-- | conf/grumpy.cfg | 3 | ||||
-rwxr-xr-x | utils/grumpy_sync.py | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/conf/grumpy.cfg b/conf/grumpy.cfg index 6abcad8..b74ab79 100644 --- a/conf/grumpy.cfg +++ b/conf/grumpy.cfg @@ -11,3 +11,6 @@ SECRET_KEY='Change me' # Database configuration SQLALCHEMY_ECHO=False SQLALCHEMY_DATABASE_URI='postgresql://grumpy:grumpy@localhost/grumpy' + +# Grumpy configuration +GRUMPY_PORTAGE_DIR='/usr/portage' diff --git a/utils/grumpy_sync.py b/utils/grumpy_sync.py index 58f0083..b6c6bde 100755 --- a/utils/grumpy_sync.py +++ b/utils/grumpy_sync.py @@ -250,11 +250,14 @@ def main(path): package_sync(cat, pkg, files, int(os.stat(dir).st_mtime)) if __name__ == '__main__': - parser = OptionParser(usage="usage: %prog [options] portagedir") + parser = OptionParser(usage="usage: %prog [options] CONFFILE") (opts, args) = parser.parse_args() if len(args) != 1: - parser.error("please provide path to portagedir as first argument") + parser.error("provide path to configuration file as first argument") sys.exit(1) - # Setup database for application with app.test_request_context(): - main(args[0]) + 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) |