Example #1
0
 def test_all_test_cases(self):
     for test_string, expected_result in _test_cases:
         print >>sys.stderr, test_string
         if expected_result == "exception":
             self.assertRaises(InvalidNCLString, 
                               parse_ncl_string, 
                               test_string)
         else:
             result = parse_ncl_string(test_string)
             self.assertEqual(result, 
                              expected_result, 
                              (test_string, result)) 
Example #2
0
def main():
    """
    main entry point
    returns 0 on normal termination
    """
    _initialize_logging()
    log = logging.getLogger("main")
    args = _parse_commandline()

    try:
        identity = _load_identity(args)
    except InvalidIdentity:
        instance = sys.exc_info()[1]
        log.error("invalid identity: {0}".format(instance))
        return 1

    if len(args.residue) > 0:
        input_file = StringIO(" ".join(args.residue))
    else:
        input_file = sys.stdin

    for line in input_file:
        try:
            ncl_dict = parse_ncl_string(line)
            _dispatch_table[ncl_dict["command"]](args, identity, ncl_dict)
        except InvalidNCLString:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except NCLErrorResult:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except InvalidIdentity:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1 
        except LumberyardHTTPError:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1 
        except Exception:
            instance = sys.exc_info()[1]
            log.exception(line)
            return 1

    return 0
Example #3
0
def main():
    """
    main entry point
    returns 0 on normal termination
    """
    _initialize_logging()
    log = logging.getLogger("main")
    args = _parse_commandline()

    try:
        identity = _load_identity(args)
    except InvalidIdentity:
        instance = sys.exc_info()[1]
        log.error("invalid identity: {0}".format(instance))
        return 1

    if len(args.residue) > 0:
        input_file = StringIO(" ".join(args.residue))
    else:
        input_file = sys.stdin

    for line in input_file:
        try:
            ncl_dict = parse_ncl_string(line)
            _dispatch_table[ncl_dict["command"]](args, identity, ncl_dict)
        except InvalidNCLString:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except NCLErrorResult:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except InvalidIdentity:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except LumberyardHTTPError:
            instance = sys.exc_info()[1]
            log.error(str(instance))
            return 1
        except Exception:
            instance = sys.exc_info()[1]
            log.exception(line)
            return 1

    return 0