fallback to default config if local fakehub/fakeweb config missing
This commit is contained in:
parent
1a3ac059a2
commit
b9c2a3f02f
3 changed files with 62 additions and 4 deletions
44
devtools/README.md
Normal file
44
devtools/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
Koji Developer Tools
|
||||
--------------------
|
||||
|
||||
This directory contains some tools that developers may find useful.
|
||||
|
||||
fakehub
|
||||
-------
|
||||
|
||||
This script runs a single hub call in the foreground (no httpd) and
|
||||
dumps the results. It runs using the code from the checkout.
|
||||
|
||||
The call to be executed is specified on the command line, much like
|
||||
the ``koji call`` command.
|
||||
|
||||
For example:
|
||||
```
|
||||
[mike@localhost koji]$ devtools/fakehub getTag 1
|
||||
```
|
||||
|
||||
You will see hub logs on the console. The call result is pretty printed
|
||||
at the end.
|
||||
|
||||
This tool makes it possible to run hub code through the debugger or
|
||||
or profiler with relative ease.
|
||||
|
||||
fakehub looks for ``fakehub.conf`` or ``fakehub.conf.d`` in the devtools
|
||||
directory. If either is present, then
|
||||
``koji.hub.ConfigFile`` and ``koji.hub.ConfigDir`` are set to these values.
|
||||
If neither is, then the code will fall back to the default (system) config.
|
||||
|
||||
|
||||
fakeweb
|
||||
-------
|
||||
|
||||
This tool is similar to the fakehub tool, instead of a single pass it starts
|
||||
a web server on port 8000 and starts serving.
|
||||
|
||||
As with the fakehub tool, fakeweb runs in the foreground in a single thread, making
|
||||
it possible to debug web code.
|
||||
|
||||
Similar to fakehub, fakeweb looks for ``fakeweb.conf`` or ``fakeweb.conf.d``
|
||||
in the devtools directory. If either is present, then
|
||||
``koji.web.ConfigFile`` and ``koji.web.ConfigDir`` are set to these values.
|
||||
If neither is, then the code will fall back to the default (system) config.
|
||||
|
|
@ -76,6 +76,14 @@ def parse_response(data):
|
|||
return result
|
||||
|
||||
|
||||
def set_config(environ):
|
||||
lconfig = "%s/devtools/fakehub.conf" % os.getcwd()
|
||||
lconfigd = "%s/devtools/fakehub.conf.d" % os.getcwd()
|
||||
if os.path.exists(lconfig) or os.path.exists(lconfigd):
|
||||
environ['koji.hub.ConfigFile'] = lconfig
|
||||
environ['koji.hub.ConfigDir'] = lconfigd
|
||||
|
||||
|
||||
def main():
|
||||
environ = {}
|
||||
environ['SCRIPT_FILENAME'] = kojixmlrpc.__file__
|
||||
|
|
@ -86,8 +94,7 @@ def main():
|
|||
environ['wsgi.input'] = cStringIO.StringIO(get_request())
|
||||
environ['REQUEST_METHOD'] = 'POST'
|
||||
environ['CONTENT_TYPE'] = 'text/xml'
|
||||
environ['koji.hub.ConfigFile'] = "%s/devtools/fakehub.conf" % os.getcwd()
|
||||
environ['koji.hub.ConfigDir'] = "%s/devtools/fakehub.conf.d" % os.getcwd()
|
||||
set_config(environ)
|
||||
print('RESULT:')
|
||||
data = kojixmlrpc.application(environ, start_response)
|
||||
result = parse_response(data)
|
||||
|
|
|
|||
|
|
@ -95,14 +95,21 @@ def redirect_static(environ, start_response):
|
|||
return [response]
|
||||
|
||||
|
||||
def set_config(environ):
|
||||
lconfig = "%s/devtools/fakeweb.conf" % os.getcwd()
|
||||
lconfigd = "%s/devtools/fakeweb.conf.d" % os.getcwd()
|
||||
if os.path.exists(lconfig) or os.path.exists(lconfigd):
|
||||
environ['koji.web.ConfigFile'] = lconfig
|
||||
environ['koji.web.ConfigDir'] = lconfigd
|
||||
|
||||
|
||||
def application(environ, start_response):
|
||||
global FIRST
|
||||
setup_testing_defaults(environ)
|
||||
# provide some needed info
|
||||
environ['SCRIPT_FILENAME'] = wsgi_publisher.__file__
|
||||
environ['REQUEST_URI'] = get_url(environ)
|
||||
environ['koji.web.ConfigFile'] = "%s/devtools/fakeweb.conf" % os.getcwd()
|
||||
environ['koji.web.ConfigDir'] = "%s/devtools/fakeweb.conf.d" % os.getcwd()
|
||||
set_config(environ)
|
||||
if FIRST:
|
||||
pprint.pprint(environ)
|
||||
FIRST = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue