Exemplo n.º 1
0
def main():
    Usergrid.init(org_id='jwest1', app_id='sandbox')

    response = Usergrid.DELETE('pets', 'max')

    if not response.ok:
        print 'Failed to delete max: %s' % response
        exit()

    response = Usergrid.DELETE('owners', 'jeff')

    if not response.ok:
        print 'Failed to delete Jeff: %s' % response
        exit()

    response = Usergrid.POST('pets', {'name': 'max'})

    if response.ok:
        pet = response.first()

        print pet

        response = Usergrid.POST('owners', {'name': 'jeff'})

        if response.ok:
            owner = response.first()

            print owner

            response = pet.connect('ownedBy', owner)

            if response.ok:
                print 'Connected!'

                response = pet.disconnect('ownedBy', owner)

                if response.ok:
                    print 'all done!'
                else:
                    print response

            else:
                print 'failed to connect: %s' % response

        else:
            print 'Failed to create Jeff: %s' % response

    else:
        print response
Exemplo n.º 2
0
def main():
    Usergrid.init(org_id="jwest1", app_id="sandbox")

    response = Usergrid.DELETE("pets", "max")

    if not response.ok:
        print "Failed to delete max: %s" % response
        exit()

    response = Usergrid.DELETE("owners", "jeff")

    if not response.ok:
        print "Failed to delete Jeff: %s" % response
        exit()

    response = Usergrid.POST("pets", {"name": "max"})

    if response.ok:
        pet = response.first()

        print pet

        response = Usergrid.POST("owners", {"name": "jeff"})

        if response.ok:
            owner = response.first()

            print owner

            response = pet.connect("ownedBy", owner)

            if response.ok:
                print "Connected!"

                response = pet.disconnect("ownedBy", owner)

                if response.ok:
                    print "all done!"
                else:
                    print response

            else:
                print "failed to connect: %s" % response

        else:
            print "Failed to create Jeff: %s" % response

    else:
        print response
Exemplo n.º 3
0
def main():
    Usergrid.init(org_id='jwest1',
                  app_id='sandbox')

    response = Usergrid.DELETE('pets', 'max')
    if not response.ok:
        print 'Failed to delete max: %s' % response
        exit()

    response = Usergrid.DELETE('owners', 'jeff')
    if not response.ok:
        print 'Failed to delete Jeff: %s' % response
        exit()

    response = Usergrid.POST('pets', {'name': 'max'})

    if response.ok:
        pet = response.first()
        print pet
        response = Usergrid.POST('owners', {'name': 'jeff'})

        if response.ok:
            owner = response.first()
            print owner
            response = pet.connect('ownedBy', owner)

            if response.ok:
                print 'Connected!'

                response = pet.disconnect('ownedBy', owner)

                if response.ok:
                    print 'all done!'
                else:
                    print response
            else:
                print 'failed to connect: %s' % response

        else:
            print 'Failed to create Jeff: %s' % response

    else:
        print response
Exemplo n.º 4
0
def main():
    global config
    config = parse_args()

    init_logging()

    Usergrid.init(org_id=config.get('org'),
                  app_id=config.get('app'),
                  base_url=config.get('url'),
                  client_id=config.get('client_id'),
                  client_secret=config.get('client_secret'))

    tmp_dir = config.get('tmp_dir')
    file_path = config.get('file')

    if not os.path.isfile(file_path):
        logger.critical('File path specified [%s] is not a file!' % file_path)
        logger.critical('Unable to continue')
        exit(1)

    if not os.path.isdir(tmp_dir):
        logger.critical(
            'Temp Directory path specified [%s] is not a directory!' % tmp_dir)
        logger.critical('Unable to continue')
        exit(1)

    file_name = os.path.basename(file_path).split('.')[0]
    working_directory = os.path.join(tmp_dir, file_name)

    try:
        with zipfile.ZipFile(file_path, 'r') as z:
            logger.warn('Extracting files to directory: %s' %
                        working_directory)
            z.extractall(working_directory)
            logger.warn('Extraction complete')

    except Exception, e:
        logger.critical(traceback.format_exc(e))
        logger.critical('Extraction failed')
        logger.critical('Unable to continue')
        exit(1)
def main():
    global config
    config = parse_args()

    init_logging()

    Usergrid.init(org_id=config.get('org'),
                  app_id=config.get('app'),
                  base_url=config.get('url'),
                  client_id=config.get('client_id'),
                  client_secret=config.get('client_secret'))

    tmp_dir = config.get('tmp_dir')
    file_path = config.get('file')

    if not os.path.isfile(file_path):
        logger.critical('File path specified [%s] is not a file!' % file_path)
        logger.critical('Unable to continue')
        exit(1)

    if not os.path.isdir(tmp_dir):
        logger.critical('Temp Directory path specified [%s] is not a directory!' % tmp_dir)
        logger.critical('Unable to continue')
        exit(1)

    file_name = os.path.basename(file_path).split('.')[0]
    working_directory = os.path.join(tmp_dir, file_name)

    try:
        with zipfile.ZipFile(file_path, 'r') as z:
            logger.warn('Extracting files to directory: %s' % working_directory)
            z.extractall(working_directory)
            logger.warn('Extraction complete')

    except Exception, e:
        logger.critical(traceback.format_exc(e))
        logger.critical('Extraction failed')
        logger.critical('Unable to continue')
        exit(1)