~abentley/ci-director/building-trumps-result

« back to all changes in this revision

Viewing changes to cidirector/cidirector.py

  • Committer: Aaron Bentley
  • Date: 2016-08-29 15:01:47 UTC
  • mfrom: (179.1.4 log-exceptions)
  • Revision ID: aaron.bentley@canonical.com-20160829150147-547c84wu7unvrao2
Add exception logging to start-builds, update-outcome.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    StateFileInUse,
51
51
    TERMINAL_STATUS,
52
52
)
53
 
from utility import S3Storage
 
53
from utility import (
 
54
    log_exceptions,
 
55
    S3Storage,
 
56
    )
54
57
 
55
58
 
56
59
__metaclass__ = type
1028
1031
    args = get_arg_parser().parse_args(argv)
1029
1032
    setup_logging(args.log_path, args.log_count, args.verbose)
1030
1033
    logger = logging.getLogger('cidirector')
1031
 
    try:
1032
 
        build_revision(args.branch)
1033
 
    except StateFileInUse:
1034
 
        logger.warning('State file already in use.')
1035
 
        return 1
1036
 
    except Exception:
1037
 
        logger.exception("exception during build revision:")
1038
 
        return 1
1039
 
    return 0
 
1034
    with log_exceptions(logger) as result:
 
1035
        try:
 
1036
            build_revision(args.branch)
 
1037
        except StateFileInUse:
 
1038
            logger.warning('State file already in use.')
 
1039
            return 1
 
1040
    return result.exit_status
1040
1041
 
1041
1042
 
1042
1043
if __name__ == '__main__':