示例#1
0
def backupFiles():
    backup_paths = inexcess.read_config('paths')
    for key, path in backup_paths:
        #THIS CRAZY HACK LOOKING THING IS TO GET ME ALL THE FILES
        files = ["{}/{}".format(root, file) for root,file in list(itertools.chain(*[list(itertools.product([root], files)) for root, dirs, files in os.walk(path)]))]
        for single_file in files:
            mongo.uploadFile(single_file, 'files')
    return
示例#2
0
def connect():
    mongo_settings = dict(inexcess.read_config('mongo'))
    user = mongo_settings['user']
    port = mongo_settings['port']
    host = mongo_settings['url']
    password = mongo_settings['pass']
    db = mongo_settings['db']
    uri = 'mongodb://'+user+':'+password+'@'+host+':'+port+'/'+db

    database = MongoClient(uri)[db]
    database.authenticate(user,password)
    return database