Commit 7a09ecac authored by Alain Takoudjou's avatar Alain Takoudjou

add support for backup caucase database to cli

parent 5f6857b7
...@@ -16,34 +16,32 @@ ...@@ -16,34 +16,32 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with caucase. If not, see <http://www.gnu.org/licenses/>. # along with caucase. If not, see <http://www.gnu.org/licenses/>.
import os import os
import argparse from caucase import app, db
from caucase.web import app, db from flask_alchemydumps import AlchemyDumps, AlchemyDumpsCommand
from flask_script import Manager, Command
def parseArguments():
"""
Parse arguments for Certificate Authority cli instance.
"""
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--db-file', required=True,
help='Certificate authority data base file path')
return parser
def housekeeping(config): app.config.update(
"""
Start Storage housekeep method to cleanup garbages
"""
app.config.update(
DEBUG=False, DEBUG=False,
CSRF_ENABLED=True, CSRF_ENABLED=True,
TESTING=False, TESTING=False,
SQLALCHEMY_DATABASE_URI='sqlite:///%s' % config.db_file SQLALCHEMY_DATABASE_URI='sqlite:///%sca.db' % os.environ.get('CAUCASE_DIR', '')
) )
manager = Manager(app)
# init Alchemy Dumps
alchemydumps = AlchemyDumps(app, db)
manager.add_command('database', AlchemyDumpsCommand)
@manager.command
def housekeep():
"""
Start Storage housekeep method to cleanup garbages
"""
from caucase.storage import Storage from caucase.storage import Storage
storage = Storage(db) storage = Storage(db)
storage.housekeep() storage.housekeep()
def main(): def main():
parser = parseArguments() manager.run()
config = parser.parse_args()
housekeeping(config)
\ No newline at end of file
...@@ -52,6 +52,7 @@ setup(name=name, ...@@ -52,6 +52,7 @@ setup(name=name,
install_requires=[ install_requires=[
'Flask', # needed by servers 'Flask', # needed by servers
'flask_user', 'flask_user',
'Flask-AlchemyDumps',
'setuptools', # namespaces 'setuptools', # namespaces
'pyOpenSSL', # manage ssl certificates 'pyOpenSSL', # manage ssl certificates
'pyasn1', # ASN.1 types and codecs for certificates 'pyasn1', # ASN.1 types and codecs for certificates
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment