Пример #1
0
def setup():

    global MONGO_DIR
    global MONGO_PROCESS
    global NODE_PROCESS
    global CLIENT

    # create MONGO_DIR
    MONGO_DIR = tempfile.mkdtemp()
    print(MONGO_DIR)

    # launch MongoDB
    sys.stdout.write('Running MongoDB instance... ')
    sys.stdout.flush()
    cmd = ['mongod', '--dbpath={dbpath:s}'.format(dbpath=MONGO_DIR)]
    MONGO_PROCESS = subprocess.Popen(cmd, stdout=subprocess.PIPE)

    # testing MongoDB
    client = pymongo.MongoClient('localhost', 27017)
    try:
        # will block until MongoDB is ready
        client.database_names()
    except Exception:
        MONGO_PROCESS.kill()
        assert False, 'Cannot connect to the MongoDB instance.'

    sys.stdout.write('DONE\n')
    sys.stdout.flush()

    # launch API
    sys.stdout.write('Running Camomile test instance... ')
    sys.stdout.flush()
    cmd = [
        'node', 'app.js', '--root-password', ROOT_PASSWORD, '--mongodb-host',
        'localhost', '--mongodb-port', '27017'
    ]
    NODE_PROCESS = subprocess.Popen(cmd, stdout=subprocess.PIPE)

    # testing if server is running
    for i in range(15):
        time.sleep(1)
        try:
            Camomile(URL, username=ROOT_USERNAME, password=ROOT_PASSWORD)
        except Exception:
            continue
        else:
            break
    else:
        NODE_PROCESS.kill()
        assert False, 'Cannot connect to the Camomile test instance.'

    sys.stdout.write('DONE\n')
    sys.stdout.flush()
Пример #2
0
import sys

if __name__ == '__main__':
    # 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)
Пример #3
0
SERVER = 'http://localhost:32769'
ROOT_PASSWORD = '******'

# admin usernname and password
ADMIN = 'administrator'
ADMIN_PASSWORD = '******'

# template of path to video files (relative to /media)
URL = 'REPERE/phase2/test/{name}'

# =============================================================================

from camomile import Camomile

client = Camomile(SERVER)

# login as root
client.login('root', ROOT_PASSWORD)

# create new admin user
admin = client.createUser(ADMIN, ADMIN_PASSWORD, role='admin', returns_id=True)

# login as admin
client.login(ADMIN, ADMIN_PASSWORD)

# create new corpus
corpus = client.createCorpus('REPERE', returns_id=True)

# add media to corpus and keep track of their IDs
mediaID = {}
Пример #4
0
    # 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')
    corpusName = Config.get('ressourceSection', 'corpusName')
    shotLayerName = Config.get('ressourceSection', 'shotLayerName')
    shotList = Config.get('ressourceSection', 'shotList')
    submissionName = Config.get('ressourceSection', 'submissionName')

    inQueueEvidence = Config.get('ressourceSection', 'inQueueEvidence')
    outQueueEvidence = Config.get('ressourceSection', 'outQueueEvidence')

    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    # create queue
    id_queueIn = client.createQueue(inQueueEvidence, returns_id=True)
    id_queueOut = client.createQueue(outQueueEvidence, returns_id=True)

    id_corpus = client.getCorpora(corpusName, returns_id=True)
    if id_corpus == []:
        print args['<corpusName>'], 'is not found in the database'
        sys.exit(0)
    id_corpus = id_corpus[0]

    id_layerEvidence = client.getLayers(corpus=id_corpus, name=submissionName+".evidence", returns_id=True)
    if id_layerEvidence == []:
        print shotLayerName, 'is not found in the database'
        p = p[:-1]

    return p


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"
Пример #6
0
if __name__ == '__main__':
    # read config
    Config = ConfigParser.ConfigParser()
    Config.read("config.ini")

    server = Config.get('mainSection', 'url')+":"+Config.get('mainSection', 'port')
    user1 = Config.get('userSection', 'user1')
    pwdUser1 = Config.get('userSection', 'pwdUser1')
    corpusName = Config.get('ressourceSection', 'corpusName')
    shotLayerName = Config.get('ressourceSection', 'shotLayerName')    
    submissionName = Config.get('ressourceSection', 'submissionName')
    labelFile = Config.get('ressourceSection', 'label')
    evidenceFile = Config.get('ressourceSection', 'evidence')

    client = Camomile(server)
    client.login(user1, pwdUser1)
    
    # find id corpus and id layer
    id_corpus = client.getCorpora(corpusName, returns_id=True)
    if id_corpus == []:
        print args['<corpusName>'], 'is not found in the database'
        sys.exit(0)
    id_corpus = id_corpus[0]

    id_layer = client.getLayers(corpus=id_corpus, name=shotLayerName, returns_id=True)
    if id_layer == []:
        print shotLayerName, 'is not found in the database'
        sys.exit(0)
    id_layer = id_layer[0]
    print(' Writing objects into Objects.txt...')
    # Output the file corrected
    # with open('Objects.txt', 'w') as f:
    #     f.write(json.dumps(objets, sort_keys=True, indent=2, separators=(',', ': ')))

    print(' Reading endroits file...')
    with open(path + '/Endroits.txt', 'r') as f:
        read_data = f.read()  # Get the string
    endroits = json.loads(read_data)  # Load the data into a json object

    print(' Creating metadata on the server...')
    # Adds the metadata into the server
    client.setCorpusMetadata(corpus_actif._id, {'objet': objets, 'endroit': endroits})

    print(' Done.')


# Login into Camomile
print(' Connecting...')
client = Camomile('http://localhost:3000')
print(' Logging in...')
client.login('root', 'admin')

if __name__ == "__main__":
    build_db(sys.argv[1])
    #correct_extensions()

print(' Logging out...')
client.logout()  # Logout of the camomile server
Пример #8
0
from __future__ import unicode_literals
import tempfile
import subprocess
import pymongo
import shutil
import time
import sys

from camomile import Camomile

URL = 'http://localhost:3000'
CLIENT = Camomile(URL, debug=False)

MONGO_DIR = None
MONGO_PROCESS = None
NODE_PROCESS = None

ROOT_USERNAME = '******'
ROOT_PASSWORD = '******'


def setup():

    global MONGO_DIR
    global MONGO_PROCESS
    global NODE_PROCESS
    global CLIENT

    # create MONGO_DIR
    MONGO_DIR = tempfile.mkdtemp()
    print(MONGO_DIR)
Пример #9
0
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.')
Пример #10
0
import sys
from itertools import product

if __name__ == '__main__':
    # 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')
    corpusName = Config.get('ressourceSection', 'corpusName')
    mediaList = Config.get('ressourceSection', 'mediaList')
    mediaPath = Config.get('ressourceSection', 'mediaPath')

    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    # get corpus id
    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]

    mediumNames = [line.rstrip('\n') for line in open(mediaList)]
    mediumPaths = [line.rstrip('\n') for line in open(mediaPath)]

    # add media to corpus
    for i in range(0, len(mediumNames)):
        client.createMedium(id_corpus, mediumNames[i], url=mediumPaths[i])
Пример #11
0
if __name__ == '__main__':
    # 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')
    shotLayerName = Config.get('ressourceSection', 'shotLayerName')    

    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)
Пример #12
0
import ConfigParser
from camomile import Camomile
import sys

if __name__ == '__main__':
	# read config
    Config = ConfigParser.ConfigParser()
    Config.read("config.ini")

    server = Config.get('mainSection', 'url')+":"+Config.get('mainSection', 'port')
    corpusName = Config.get('ressourceSection', 'corpusName')

    userAdmin = sys.argv[1]
    pwdAdmin = sys.argv[2]

    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]


    users = client.getUsers()
    layers = client.getLayers()
    
	for u in users:
		if u.role == 'user':
			for l in layers:
Пример #13
0
SERVER = 'http://localhost:12345'
ROOT_PASSWORD = '******'

# admin usernname and password
ADMIN = 'administrator'
ADMIN_PASSWORD = '******'

# template of path to video files (relative to /media)
URL = 'REPERE/phase2/test/{name}'

# =============================================================================

from camomile import Camomile

client = Camomile(SERVER)

# login as root
client.login('root', ROOT_PASSWORD)

# create new admin user
admin = client.createUser(ADMIN, ADMIN_PASSWORD, role='admin', returns_id=True)

# login as admin
client.login(ADMIN, ADMIN_PASSWORD)

# create new corpus
corpus = client.createCorpus('REPERE', returns_id=True)

# add media to corpus and keep track of their IDs
mediaID = {}
Пример #14
0
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


import ConfigParser
from camomile import Camomile

if __name__ == '__main__':
    # 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')

    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    
    count = 0
    deleted = 0

    for l in client.getLayers():
        # if "annotateur" in l.name:
        print l.name
        annotations = client.getAnnotations(l._id)
        print('annotations : %d' % len(annotations))

        # tmp = [[(u'start', a['fragment']['start']), (u'end', a['fragment']['end']), (u'data', a['data'])] for a in annotations]
        # tmp = []
        # for a in annotations:
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


import ConfigParser
from camomile import Camomile
import sys

if __name__ == '__main__':
    # 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')
    corpusName = Config.get('ressourceSection', 'corpusName')
    pathToVideo = Config.get('ressourceSection', 'pathToVideo')
    mediaList = Config.get('ressourceSection', 'mediaList')

    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    # create new corpus
    id_corpus = client.createCorpus(corpusName, returns_id=True)

    # add media to corpus
    for mediumName in open(mediaList).read().splitlines():
        client.createMedium(id_corpus, mediumName, url=pathToVideo+mediumName)