Exemplo n.º 1
0
def main(argv):
    parser = make_parser()
    args = parser.parse_args(argv)
    log_level = getattr(logging, args.loglevel)
    kwargs = {"format": LOG_FORMAT, "datefmt": LOG_DATEFMT, "level": log_level}
    if args.logfile:
        kwargs["filename"] = args.logfile
    logging.basicConfig(**kwargs)
    logger = logging.getLogger()
    with nested(open(args.input_file), open(args.output_file, "w")) as (f, fo):
        reader = csv.DictReader(f, delimiter="\t")
        writer = csv.DictWriter(fo, reader.fieldnames, delimiter="\t", lineterminator=os.linesep)
        writer.writeheader()
        try:
            host = args.host or vlu.ome_host()
            user = args.user or vlu.ome_user()
            passwd = args.passwd or vlu.ome_passwd()
        except ValueError, ve:
            logger.critical(ve)
            sys.exit(ve)
        vid_mapper = VidMapper(host, user, passwd, logger, args.study)
        counter = Counter()
        for r in reader:
            counter["input_lines"] += 1
            try:
                vid_mapper.map_vid(r)
            except ValueError:
                counter["skipped_lines"] += 1
                continue
            else:
                counter["output_lines"] += 1
                writer.writerow(r)
        for k, v in counter.iteritems():
            logger.info("%s: %d" % (k, v))
Exemplo n.º 2
0
 def __init__(self, **kwargs):
   omero_host = vlu.ome_host()
   omero_user = vlu.ome_user()
   omero_passwd = vlu.ome_passwd()
   self.kb = KB(driver='omero')(omero_host, omero_user, omero_passwd)
   super(UniverseApplication, self).__init__(**kwargs)
   self.config.omero_default_host = kwargs.get('omero_default_host')
   self.config.omero_default_user = kwargs.get('omero_default_user')
   self.config.omero_default_passwd = kwargs.get('omero_default_passwd')
   self.config.vl_loglevel = kwargs.get('vl_loglevel', 'INFO')
   self.config.vl_import_enabled_users = kwargs.get('vl_import_enabled_users')
Exemplo n.º 3
0
def main(argv=None):
    app = App()
    parser = app.make_parser()
    args = parser.parse_args(argv)
    loglevel = getattr(logging, args.loglevel)
    kwargs = {'format': LOG_FORMAT, 'datefmt': LOG_DATEFMT, 'level': loglevel}
    if args.logfile:
        kwargs['filename'] = args.logfile
    logging.basicConfig(**kwargs)
    logger = logging.getLogger()
    try:
        host = args.host or vlu.ome_host()
        user = args.user or vlu.ome_user()
        passwd = args.passwd or vlu.ome_passwd()
    except ValueError, ve:
        logger.critical(ve)
        sys.exit(ve)
Exemplo n.º 4
0
def main(argv):
  parser = make_parser()
  args = parser.parse_args(argv)

  log_level = getattr(logging, args.loglevel)
  kwargs = {'format': LOG_FORMAT, 'datefmt': LOG_DATEFMT, 'level': log_level}
  if args.logfile:
    kwargs['filename'] = args.logfile
  logging.basicConfig(**kwargs)
  logger = logging.getLogger()

  try:
    host = args.host or vlu.ome_host()
    user = args.user or vlu.ome_user()
    passwd = args.passwd or vlu.ome_passwd()
  except ValueError, ve:
    logger.critical(ve)
    sys.exit(ve)
Exemplo n.º 5
0
def main(argv):
    parser = make_parser()
    args = parser.parse_args(argv)
    log_level = getattr(logging, args.loglevel)
    kwargs = {'format': LOG_FORMAT, 'datefmt': LOG_DATEFMT, 'level': log_level}
    if args.logfile:
        kwargs['filename'] = args.logfile
    logging.basicConfig(**kwargs)
    logger = logging.getLogger()
    with nested(open(args.input_file), open(args.output_file, "w")) as (f, fo):
        reader = csv.DictReader(f, delimiter="\t")
        writer = csv.DictWriter(fo,
                                reader.fieldnames,
                                delimiter="\t",
                                lineterminator=os.linesep)
        writer.writeheader()
        try:
            host = args.host or vlu.ome_host()
            user = args.user or vlu.ome_user()
            passwd = args.passwd or vlu.ome_passwd()
        except ValueError, ve:
            logger.critical(ve)
            sys.exit(ve)
        vid_mapper = VidMapper(host, user, passwd, logger, args.study)
        counter = Counter()
        for r in reader:
            counter["input_lines"] += 1
            try:
                vid_mapper.map_vid(r)
            except ValueError:
                counter["skipped_lines"] += 1
                continue
            else:
                counter["output_lines"] += 1
                writer.writerow(r)
        for k, v in counter.iteritems():
            logger.info("%s: %d" % (k, v))