-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from al4/master
Merry Christmas 🎄 (also, a large addition)
- Loading branch information
Showing
28 changed files
with
2,591 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,5 @@ | ||
#!/usr/share/python/python-orlo/bin/python | ||
#!/bin/bash | ||
|
||
import argparse | ||
/usr/share/python/python-orlo/bin/python /usr/share/python/python-orlo/lib/python2.7/site-packages/orlo/cli.py $@ | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
|
||
p_config = argparse.ArgumentParser(add_help=False) | ||
p_config.add_argument('--file', '-f', dest='filepath', help="File to write to", | ||
default='/etc/orlo.conf') | ||
|
||
p_database = argparse.ArgumentParser(add_help=False) | ||
p_server = argparse.ArgumentParser(add_help=False) | ||
p_server.add_argument('--host', '-H', dest='host', default='127.0.0.1', help="Address to listen on") | ||
p_server.add_argument('--port', '-P', dest='port', type=int, default=5000, help="Port to listen on") | ||
|
||
subparsers = parser.add_subparsers(dest='action') | ||
sp_config = subparsers.add_parser( | ||
'write_config', help="Write config file", | ||
parents=[p_config]) | ||
sp_config.set_defaults(func=write_config) | ||
|
||
sp_database = subparsers.add_parser( | ||
'setup_database', help="Initialise the configured DB", | ||
parents=[p_database]) | ||
sp_database.set_defaults(func=setup_database) | ||
|
||
sp_run_server = subparsers.add_parser( | ||
'run_server', help="Run a test server", | ||
parents=[p_server]) | ||
sp_run_server.set_defaults(func=run_server) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def write_config(args): | ||
from orlo import config | ||
config_file = open(args.filepath, 'w') | ||
config.write(config_file) | ||
|
||
|
||
def setup_database(args): | ||
from orlo.orm import db | ||
from orlo.config import config | ||
|
||
if config.get('db', 'uri') == 'sqlite://': | ||
print("Warning: setting up in-memory database, this is " | ||
"probably not what you want!\n" | ||
"Please configure db:uri in /etc/orlo.conf") | ||
db.create_all() | ||
|
||
|
||
def run_server(args): | ||
print("Warning: this is a development server and not suitable " | ||
"for production, we recommend running under gunicorn.") | ||
|
||
from orlo import app | ||
app.config['DEBUG'] = True | ||
app.config['TRAP_HTTP_EXCEPTIONS'] = True | ||
app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False | ||
app.run(host=args.host, port=args.port, debug=True, use_reloader=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
args.func(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
python-orlo (0.0.4) stable; urgency=medium | ||
|
||
* Update debian description | ||
* Rename /import/release to /releases/import, update docstring | ||
* Fix release import error | ||
* Add .deb files to gitignore | ||
* Bump version | ||
* Handle import of documents that omit optional parameters | ||
* Add support for importing notes | ||
|
||
-- Alex Forbes <[email protected]> Fri, 11 Dec 2015 12:52:59 +0000 | ||
|
||
python-orlo (0.0.3) stable; urgency=medium | ||
|
||
* Multiple changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ server { | |
|
||
server_name <my-host-name>; | ||
|
||
location / { | ||
location /api/ { | ||
try_files $uri @proxy_to_app; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from __future__ import print_function | ||
import argparse | ||
|
||
__author__ = 'alforbes' | ||
|
||
""" | ||
Command line interface | ||
Generally setup/initialisation functions and the like, called by /usr/bin/orlo | ||
""" | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
|
||
p_config = argparse.ArgumentParser(add_help=False) | ||
p_config.add_argument('--file', '-f', dest='filepath', help="File to write to", | ||
default='/etc/orlo.conf') | ||
|
||
p_database = argparse.ArgumentParser(add_help=False) | ||
p_server = argparse.ArgumentParser(add_help=False) | ||
p_server.add_argument('--host', '-H', dest='host', default='127.0.0.1', help="Address to listen on") | ||
p_server.add_argument('--port', '-P', dest='port', type=int, default=5000, help="Port to listen on") | ||
|
||
subparsers = parser.add_subparsers(dest='action') | ||
sp_config = subparsers.add_parser( | ||
'write_config', help="Write config file", | ||
parents=[p_config]) | ||
sp_config.set_defaults(func=write_config) | ||
|
||
sp_database = subparsers.add_parser( | ||
'setup_database', help="Initialise the configured DB", | ||
parents=[p_database]) | ||
sp_database.set_defaults(func=setup_database) | ||
|
||
sp_run_server = subparsers.add_parser( | ||
'run_server', help="Run a test server", | ||
parents=[p_server]) | ||
sp_run_server.set_defaults(func=run_server) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def write_config(args): | ||
from orlo import config | ||
config_file = open(args.filepath, 'w') | ||
config.write(config_file) | ||
|
||
|
||
def setup_database(args): | ||
from orlo.orm import db | ||
from orlo.config import config | ||
|
||
if config.get('db', 'uri') == 'sqlite://': | ||
print("Warning: setting up in-memory database, this is " | ||
"probably not what you want!\n" | ||
"Please configure db:uri in /etc/orlo.conf") | ||
db.create_all() | ||
|
||
|
||
def run_server(args): | ||
print("Warning: this is a development server and not suitable " | ||
"for production, we recommend running under gunicorn.") | ||
|
||
from orlo import app | ||
app.config['DEBUG'] = True | ||
app.config['TRAP_HTTP_EXCEPTIONS'] = True | ||
app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False | ||
app.run(host=args.host, port=args.port, debug=True, use_reloader=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
args.func(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import print_function | ||
from flask import jsonify, request | ||
from orlo import app | ||
from orlo.exceptions import InvalidUsage | ||
|
||
__author__ = 'alforbes' | ||
|
||
|
||
@app.errorhandler(404) | ||
def page_not_found(error): | ||
d = {'message': "404 Not Found", 'url': request.url} | ||
return jsonify(d), 404 | ||
|
||
|
||
@app.errorhandler(InvalidUsage) | ||
def handle_invalid_usage(error): | ||
response = jsonify(error.to_dict()) | ||
response.status_code = error.status_code | ||
return response | ||
|
||
|
||
@app.errorhandler(400) | ||
def handle_400(error): | ||
response = jsonify(error.to_dict()) | ||
response.status_code = error.status_code | ||
return response | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.