コード例 #1
0
ファイル: ndexport.py プロジェクト: mlclemente/notredam
                      help="Set option if you want only metadata backup." )
    
    (options, args) = op.parse_args()

    return options
        
if __name__ == '__main__':

    options = main()
    
    archive_name = options.filename + '.tar'    
    backup_file = os.path.join(options.path,archive_name)
    
    basedir = tempfile.mkdtemp()
    try:
        e = Exporter(options.host, options.port, options.api_key, options.user, options.password)
        e.login()
        json_enc = JSONEncoder()    
    
        #backup degli utenti
        f = file(os.path.join(basedir, 'users.json'), 'w')
        f.write(json_enc.encode(e._api_get_users()))
        f.close()
        
        
        for w in e._workspace_get_list():
            #Backup workspace
            logger.info("Export workspace %s" % w['id'])
            workspacedir = os.path.join(basedir,'w_' + str(w['id']))
            os.mkdir(workspacedir)
            items = e._workspace_get_items(w['id'])
コード例 #2
0
ファイル: ndimport.py プロジェクト: mlclemente/notredam
            logger.debug('tar opened')
            if os.path.exists(path_extract + tar.getmembers()[0].name):
                logger.info('removing all')
                removeall(path_extract + tar.getmembers()[0].name)
            logger.info('extracting tar...')
            for tarinfo in tar:
                tar.extract(tarinfo, path=path_extract)
            tar.close()
            logger.info('tar extracted!')
            #unzip tar file into path_extract/backup
            path_extract += 'backup'
        
            i = Importer(options.host, options.port, options.api_key, options.user, options.password)
            i.login() 
            logger.debug('login ok')
            e = Exporter(options.host, options.port, options.api_key, options.user, options.password)
            e.login()
            logger.info( "add users")
            try:
                users = add_users(i,path_extract)
                logger.info('added user')
            except:
                if not options.force:
                    raise
                else:
                    logger.info('error in adding users... passing by')

            #ws_origTows_new {'id_ws_orig': id_ws_new}
            ws_origTows_new = {}
            add_workspaces(i,e,users,path_extract,ws_origTows_new)
            #match between id_item_old and id_item_new
コード例 #3
0
            if os.path.exists(path_extract + tar.getmembers()[0].name):
                logger.info('removing all')
                removeall(path_extract + tar.getmembers()[0].name)
            logger.info('extracting tar...')
            for tarinfo in tar:
                tar.extract(tarinfo, path=path_extract)
            tar.close()
            logger.info('tar extracted!')
            #unzip tar file into path_extract/backup
            path_extract += 'backup'

            i = Importer(options.host, options.port, options.api_key,
                         options.user, options.password)
            i.login()
            logger.debug('login ok')
            e = Exporter(options.host, options.port, options.api_key,
                         options.user, options.password)
            e.login()
            logger.info("add users")
            try:
                users = add_users(i, path_extract)
                logger.info('added user')
            except:
                if not options.force:
                    raise
                else:
                    logger.info('error in adding users... passing by')

            #ws_origTows_new {'id_ws_orig': id_ws_new}
            ws_origTows_new = {}
            add_workspaces(i, e, users, path_extract, ws_origTows_new)
            #match between id_item_old and id_item_new
コード例 #4
0
    (options, args) = op.parse_args()

    return options


if __name__ == '__main__':

    options = main()

    archive_name = options.filename + '.tar'
    backup_file = os.path.join(options.path, archive_name)

    basedir = tempfile.mkdtemp()
    try:
        e = Exporter(options.host, options.port, options.api_key, options.user,
                     options.password)
        e.login()
        json_enc = JSONEncoder()

        #backup degli utenti
        f = file(os.path.join(basedir, 'users.json'), 'w')
        f.write(json_enc.encode(e._api_get_users()))
        f.close()

        for w in e._workspace_get_list():
            #Backup workspace
            logger.info("Export workspace %s" % w['id'])
            workspacedir = os.path.join(basedir, 'w_' + str(w['id']))
            os.mkdir(workspacedir)
            items = e._workspace_get_items(w['id'])