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

add support for backup caucase database to cli

parent 5f6857b7
......@@ -16,34 +16,32 @@
# You should have received a copy of the GNU General Public License
# along with caucase. If not, see <http://www.gnu.org/licenses/>.
import os
import argparse
from caucase.web import app, db
from caucase 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):
"""
Start Storage housekeep method to cleanup garbages
"""
app.config.update(
app.config.update(
DEBUG=False,
CSRF_ENABLED=True,
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
storage = Storage(db)
storage.housekeep()
def main():
parser = parseArguments()
config = parser.parse_args()
housekeeping(config)
\ No newline at end of file
manager.run()
......@@ -52,6 +52,7 @@ setup(name=name,
install_requires=[
'Flask', # needed by servers
'flask_user',
'Flask-AlchemyDumps',
'setuptools', # namespaces
'pyOpenSSL', # manage ssl 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