From a1181c4afd8e8295fac6697cc83bb390c3466b8f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 06 2017 20:15:03 +0000 Subject: Use PAGURE_CONFIG or default to /etc/pagure/pagure.cfg for configuration And just be use possibility to read this file as check to allow the user to run pagure-admin --- diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py index c6353ce..b292e9f 100644 --- a/pagure/cli/admin.py +++ b/pagure/cli/admin.py @@ -11,6 +11,12 @@ from __future__ import print_function import argparse import logging +import os + +if 'PAGURE_CONFIG' not in os.environ \ + and os.path.exists('/etc/pagure/pagure.cfg'): + print('Using configuration file `/etc/pagure/pagure.cfg`') + os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg' import pagure.exceptions import pagure.lib @@ -98,11 +104,6 @@ def do_generate_hook_token(): def main(): """ Start of the application. """ - # TODO: figure out if the user is allowed to run this tool at all - # -> require root? - # -> check if pagure's config file is readable? - # -> Ask for something private in pagure's config file? - # Parse the arguments args = parse_arguments()