Exemplo n.º 1
0
 def __init__(self):
     super(MyDBDialog, self).__init__()
     self.setupUi(self)
     self.setWindowIcon(QIcon('./images/db.png'))
     self.buttonBox.clicked.connect(self.set_db_info)
     self.db_dict = utils.get_db_config()
     self.init_db_info()
Exemplo n.º 2
0
 def init_db_connect():
     db_dict = utils.get_db_config()
     db_password = utils.HashManager().back_aes_ecb(db_dict['db_password'])
     db_connect = DBSession(account=db_dict['db_account'],
                            password=db_password,
                            ip=db_dict['db_ip'],
                            port=db_dict['db_port'],
                            dbname=db_dict['db_dbname'])
     return db_connect
Exemplo n.º 3
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    
    parser.add_argument('-d', '--drop', action="store_true", default=False,
                        help="drop existing collections before importing")
    
    parser.add_argument("-s", "--source", default=None, type=str, help="db to import from")
    
    parser.add_argument("-t", "--target", default=None, type=str, help="db to import to")
    
    args = parser.parse_args()
    host, port = utils.get_db_config(args.source)
    
    utils.log("SOURCE: %s:%s" % (host, port))
    
    old_host        = host
    old_connection  = pymongo.Connection(host, port)
    old_database    = old_connection['stamped']
    collections     = old_database.collection_names()
    
    new_host        = args.target
    if new_host is None:
        dest            = MongoDBConfig.getInstance()
        new_host        = dest.host
    
    utils.log("DEST: %s:%s" % (new_host, port))
    
    if not os.path.isdir('/stamped/tmp/stamped/'):
       os.makedirs('/stamped/tmp/stamped')
    
    ignore = set([
        'tempentities', 'logs', 'logstats', 
    ])
    
    for collection in collections:
        print 'RUN %s' % collection
        
        if collection in ignore:
            print 'PASS'
        else:
            ret = mongoExportImport(collection, old_host, new_host)
            
            if 0 == ret:
                print 'COMPLETE'
            else:
                print "ERROR restoring collection '%s'" % collection
        
        print 
    
    try:
        utils.runMongoCommand('db.runCommand( {createCollection:"logs", capped:true, size:500000} )')
    except:
        utils.printException()
Exemplo n.º 4
0
def issueQueries(queries):
    # TODO: Pull this out to a named constant somewhere, or be more intelligent about this, or something.
    config = { 'mongodb' : { 'hosts': [get_db_config('peach.db3')] } }
    devDbConfig = MongoDBConfig()
    devDbConfig.config = AttributeDict(config)
    devDb = devDbConfig.connection.stamped
    # TODO: This whole "stamped_fixtures" thing really needs to be a constant.
    localDb = MongoDBConfig.getInstance().connection.stamped_fixtures
    for (collectionName, query) in queries:
        devCollection = getattr(devDb, collectionName)
        results = list(devCollection.find(query))
        localCollection = getattr(localDb, collectionName)
        localCollection.insert(results)