Ejemplo n.º 1
0
def mexsession(config):
    "Create a BQApi BQSession object based on config"
    host = config.get ( 'host.root')
    user = config.get ( 'host.user')
    passwd = config.get ( 'host.password')

    bq = BQSession()
    bq.config = config
    bq.init_local (user, passwd, bisque_root = host, create_mex = True)
    yield  bq
    bq.close()
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Load maize images and metadata')
    parser.add_argument('--imagebase',
                        default=BASE,
                        help='Directory to fetch images from  (%(default)s)')
    parser.add_argument('--bisque_host',
                        default=BISQUE_ROOT,
                        help="Upload images to (%(default)s)")
    parser.add_argument('--cas',
                        default=False,
                        action='store_true',
                        help="Use CAS for login ( %(default)s )")
    parser.add_argument('-n',
                        '--dryrun',
                        default=False,
                        action='store_true',
                        help="Print actions")
    parser.add_argument('-v',
                        '--verbose',
                        default=False,
                        action='store_true',
                        help="Dump alot of info")
    parser.add_argument('-u',
                        '--credentials',
                        help="A Bisuqe username:password")
    parser.add_argument('-l',
                        '--limit',
                        type=int,
                        help="Limit number of images ")
    parser.add_argument('csvfile',
                        nargs='?',
                        default='MaizeImaging.csv',
                        help="A local .csv file")

    args = parser.parse_args()
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    print "LIMIT", args.limit

    session = BQSession()
    session.args = args
    # Ensure we have a way to login
    if not args.dryrun:
        if not args.credentials:
            args.credentials = input("Please enter bisque credentials: ")
        if ':' not in args.credentials:
            password = input("Please enter password: "******":".join([args.credentials, password])
        user, password = args.credentials.split(":")

        if args.cas:
            session.init_cas(user,
                             password,
                             bisque_root=args.bisque_host,
                             create_mex=False)
        else:
            session.init_local(user,
                               password,
                               bisque_root=args.bisque_host,
                               create_mex=False)
    #
    #
    reader = readcsv(session)
    image_data = transform(session, reader)
    image_map = transfer_images(session, image_data)
    upload_dataset(session, 'maize', [x[1] for x in image_map])