url = arguments['--url'] output_path = arguments['<output_path>'] login = arguments['--login'] password = arguments['--password'] if login is None: login = raw_input('Login: '******'mediaeval.test', returns_id=True)[0] # teams teams = {team._id: team.name for team in client.getGroups() if team.name.startswith('team_') or team.name == 'organizer'} media = {medium._id: medium.name for medium in client.getMedia(test)} shotLayer = client.getLayers(test, name='mediaeval.submission_shot')[0]._id print "get the shot number" shots = {} for a in client.getAnnotations(shotLayer): shots.setdefault(a.id_medium, {}) shots[a.id_medium][a._id] = a.fragment.shot_number
# read config Config = ConfigParser.ConfigParser() Config.read("config.ini") server = Config.get('mainSection', 'url')+":"+Config.get('mainSection', 'port') userAdmin = Config.get('userSection', 'userAdmin') pwdAdmin = Config.get('userSection', 'pwdAdmin') user1 = Config.get('userSection', 'user1') pwdUser1 = Config.get('userSection', 'pwdUser1') roleUser1 = Config.get('userSection', 'roleUser1') corpusName = Config.get('ressourceSection', 'corpusName') client = Camomile(server) client.login(userAdmin, pwdAdmin) id_corpus = client.getCorpora(name=corpusName, returns_id=True) if id_corpus == []: print corpusName, 'is not found in the database' sys.exit(0) id_corpus = id_corpus[0] # id_layer = client.getLayers(name=shotLayerName, returns_id=True) # if id_layer == []: # print shotLayerName, 'is not found in the database' # sys.exit(0) # id_layer = id_layer[0] id_user = client.createUser(user1, pwdUser1, role=roleUser1, returns_id=True) client.setCorpusPermissions(id_corpus, client.ADMIN, user=id_user) # client.setLayerPermissions(id_layer, client.READ, user=id_user)
def initialize(url, username=None, password=None): if GLOBAL_DEBUG: debug('initialize') global GLOBAL_CLIENT global GLOBAL_CORPUS global GLOBAL_USERS global GLOBAL_GROUPS global GLOBAL_ME global GLOBAL_TEAM global GLOBAL_SUBMISSION_QUEUE # ------------------------------------------------------------------------- # connect to Camomile server # ------------------------------------------------------------------------- GLOBAL_CLIENT = Camomile(url) if username is None: username = raw_input('Login: '******'Unable to connect to %s with login %s' % (url, username)) # ------------------------------------------------------------------------- # find corpus identifier (development or test set) # ------------------------------------------------------------------------- try: name = (CORPUS_NAME_DEV if GLOBAL_DEV_OR_TEST == "dev" else CORPUS_NAME_TEST) corpora = GLOBAL_CLIENT.getCorpora(name=name) GLOBAL_CORPUS = corpora[0]._id except Exception: reportErrorAndExit( 'Unable to identify %s corpus.' % GLOBAL_DEV_OR_TEST) # ------------------------------------------------------------------------- # get list of users and groups # ------------------------------------------------------------------------- try: GLOBAL_GROUPS = GLOBAL_CLIENT.getGroups() GLOBAL_USERS = GLOBAL_CLIENT.getUsers() except Exception: reportErrorAndExit('Unable to obtain list of users and groups.') # ------------------------------------------------------------------------- # get (supposedly unique) team of current user # ------------------------------------------------------------------------- try: GLOBAL_TEAM = None userGroups = GLOBAL_CLIENT.getMyGroups() for group in GLOBAL_GROUPS: if group._id in userGroups and group.name.startswith('team_'): GLOBAL_TEAM = group break except Exception: pass if GLOBAL_TEAM is None: reportErrorAndExit('Unable to identify your team.') # ------------------------------------------------------------------------- # identify submission queue # ------------------------------------------------------------------------- if GLOBAL_DEBUG: debug('locate submission queue.') try: queues = [queue._id for queue in GLOBAL_CLIENT.getQueues() if queue.name == QUEUE_SUBMISSION] GLOBAL_SUBMISSION_QUEUE = queues[0] except Exception: reportErrorAndExit('Unable to locate submission queue.')