示例#1
0
    #                     help='filepath for YAML settings file')
    # args = parser.parse_args()

    import optparse
    parser = optparse.OptionParser()
    parser.add_option("-f",
                      "--force",
                      action="store_true",
                      dest="force",
                      default=True,
                      help='force action, rather than ask for confirmation')
    (options, args) = parser.parse_args()

    if not options.force:
        response = raw_input('about to delete everything; really sure? [n] > ')
        if not utils.to_bool(response):
            sys.exit('aborted')
    if len(args) == 0:
        filepath = None
    elif len(args) == 1:
        filepath = args[0]
    else:
        sys.exit('too many arguments')
    utils.load_settings(filepath=filepath)

    db = utils.get_db()
    wipeout_database(db)
    print 'wiped out database'
    load_designs(db)
    print 'loaded designs'
    default = 'dump.tar.gz'
示例#2
0
"""Development script for deleting explicitly a project and all its stuff.
WARNING: Destructive! Must not be used in the production instance."""

from charon import utils

if __name__ == '__main__':
    import sys
    if len(sys.argv) != 2:
        sys.exit('give project identifier')
    utils.load_settings()
    db = utils.get_db()
    view = db.view('project/projectid', include_docs=True, key=sys.argv[1])
    rows = list(view)
    if len(rows) != 1:
        sys.exit('no such project')
    project = rows[0].doc
    print 'Project', project['projectid'], project.get('title', '[no title]')
    answer = raw_input('really delete? (y/n) > ')
    if utils.to_bool(answer):
        utils.delete_project(db, project)
        print 'deleted'