configurable through environment variable
This commit is contained in:
parent
3b33ee01f6
commit
34650682dc
3 changed files with 24 additions and 9 deletions
|
@ -1 +1,6 @@
|
|||
OUTPUT_DIR='output'
|
||||
HOST='localhost'
|
||||
PORT='8000'
|
||||
DEBUG=True
|
||||
DB_URI='sqlite:///techrec.db'
|
||||
AUDIO_OUTPUT='output/'
|
||||
|
|
|
@ -65,7 +65,7 @@ class RecServer:
|
|||
self._app = Bottle()
|
||||
self._route()
|
||||
|
||||
self.db = RecDB()
|
||||
self.db = RecDB(get_config()['DB_URI'])
|
||||
|
||||
def _route(self):
|
||||
### This is the API part of the app
|
||||
|
@ -172,7 +172,7 @@ class RecServer:
|
|||
create_mp3,
|
||||
start=rec.starttime,
|
||||
end=rec.endtime,
|
||||
outfile=rec.filename)
|
||||
outfile=os.path.join(get_config()['AUDIO_OUTPUT'], rec.filename))
|
||||
print "SUBMITTED: %d" % job_id
|
||||
return self.rec_msg("Aggiornamento completato!",
|
||||
job_id=job_id,
|
||||
|
@ -250,8 +250,21 @@ class RecServer:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
configs = ['default_config.py']
|
||||
if 'TECHREC_CONFIG' in os.environ:
|
||||
for conf in os.environ['TECHREC_CONFIG'].split(':'):
|
||||
if not conf:
|
||||
continue
|
||||
path = os.path.realpath(conf)
|
||||
if not os.path.exists(path):
|
||||
logger.warn("Configuration file '%s' does not exist; skipping"
|
||||
% path)
|
||||
continue
|
||||
configs.append(path)
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
get_config().from_pyfile("default_config.py")
|
||||
for conf in configs:
|
||||
get_config().from_pyfile(conf)
|
||||
c = RecServer()
|
||||
c._app.mount('/date', DateApp())
|
||||
c._app.run(host="localhost", port="8000", debug=True)
|
||||
c._app.run(host=get_config()['HOST'], port=get_config()['PORT'],
|
||||
debug=get_config()['DEBUG'])
|
||||
|
|
|
@ -58,8 +58,8 @@ class Rec(Base):
|
|||
|
||||
|
||||
class RecDB:
|
||||
def __init__(self):
|
||||
self.engine = create_engine('sqlite:///techrec.db', echo=False)
|
||||
def __init__(self, uri):
|
||||
self.engine = create_engine(uri, echo=False)
|
||||
self.conn = self.engine.connect()
|
||||
|
||||
logging.getLogger('sqlalchemy.engine').setLevel(logging.FATAL)
|
||||
|
@ -186,9 +186,6 @@ if __name__ == "__main__":
|
|||
_endtime = datetime(2014,05,24,17,45,17)
|
||||
|
||||
a = Rec(name="Mimmo1", starttime=_mytime, endtime=_endtime)
|
||||
j = RecJob( a )
|
||||
print (j)
|
||||
j.extract()
|
||||
printall( db._search() )
|
||||
sys.exit("End test job")
|
||||
|
||||
|
|
Loading…
Reference in a new issue