merged command line and gui app in one command
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from cement import Controller, ex
|
||||
|
||||
from ..database import KontorDB
|
||||
|
||||
|
||||
class Database(Controller):
|
||||
|
||||
class Meta:
|
||||
label = 'database'
|
||||
stacked_type = 'nested'
|
||||
stacked_on = 'base'
|
||||
|
||||
@ex(
|
||||
help='export database to given file',
|
||||
arguments=[
|
||||
(['-f', '--file'],
|
||||
{'help': 'file to store database content',
|
||||
'action': 'store',
|
||||
'dest': 'db_file'})
|
||||
],
|
||||
)
|
||||
def export(self):
|
||||
data = {
|
||||
'db_file': 'data.json',
|
||||
'export_type': 'JSON',
|
||||
}
|
||||
if self.app.pargs.db_file is not None:
|
||||
data['db_file'] = self.app.pargs.db_file
|
||||
kontor_db = KontorDB(self.app.session, self.app.log)
|
||||
table_list = kontor_db.get_table_names()
|
||||
kontor_db.export_db(data['export_type'], data['db_file'], table_list)
|
||||
self.app.render(data, 'command1.jinja2')
|
||||
Reference in New Issue
Block a user