fixed a couple small issues:
- logging wasn't being initialized properly when entering via cli - added init
- typo-d variable name in loop
fixed a couple small issues:
unit tests ran, several local runs done to verify proper output
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | depcheck/__init__.py (16 lines) |
| Commit | Tree | Parents | Author | Summary | Date |
|---|---|---|---|---|---|
| b37cfa1084d9 | 39587b4282cb | c90da679b0ca | Tim Flink | fixed typo that lead to the same nvr being outputted over and over | Nov 3 2014, 9:44 PM |
| c90da679b0ca | 244653c98d41 | dc4f42723ee9 | Tim Flink | fixed logging output for local execution case, added debug option to parser… (Show More…) | Nov 3 2014, 9:44 PM |
| Show All 30 Lines | |||||
| 31 | Pass = 'PASSED' | 31 | Pass = 'PASSED' | ||
| 32 | Fail = 'FAILED' | 32 | Fail = 'FAILED' | ||
| 33 | 33 | | |||
| 34 | import os.path | 34 | import os.path | ||
| 35 | import sys | 35 | import sys | ||
| 36 | import argparse | 36 | import argparse | ||
| 37 | import tempfile | 37 | import tempfile | ||
| 38 | import platform | 38 | import platform | ||
| 39 | import logging | ||||
| 39 | 40 | | |||
| 40 | from . import depcheck | 41 | from . import depcheck | ||
| 41 | from . import metadata | 42 | from . import metadata | ||
| 42 | from . import exc | 43 | from . import exc | ||
| 43 | from . import squash_results | 44 | from . import squash_results | ||
| 44 | from . import log | 45 | from . import log | ||
| 45 | 46 | | |||
| 46 | from libtaskotron.python_utils import iterable | 47 | from libtaskotron.python_utils import iterable | ||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 66 | def run(rpms, arch, repos, report_format="updates", workdir=None): | |||
| 116 | log.logger.info("Running Depcheck") | 117 | log.logger.info("Running Depcheck") | ||
| 117 | depck = depcheck.Depcheck(str(arch), repomd_files, workdir=workdir) | 118 | depck = depcheck.Depcheck(str(arch), repomd_files, workdir=workdir) | ||
| 118 | run_result = depck.check_rpm_deps(rpmlist) | 119 | run_result = depck.check_rpm_deps(rpmlist) | ||
| 119 | 120 | | |||
| 120 | log.logger.info("Formatting output") | 121 | log.logger.info("Formatting output") | ||
| 121 | 122 | | |||
| 122 | # Sometimes, depcheck gets run with no rpms | 123 | # Sometimes, depcheck gets run with no rpms | ||
| 123 | if not run_result: | 124 | if not run_result: | ||
| 124 | log.logger.info("No results") | 125 | log.logger.warn("No results") | ||
| 125 | 126 | | |||
| 126 | output = squash_results.format_output(run_result, arch, report_format) | 127 | output = squash_results.format_output(run_result, arch, report_format) | ||
| 127 | log.logger.info(output) | 128 | log.logger.info(output) | ||
| 128 | 129 | | |||
| 129 | return output | 130 | return output | ||
| 130 | 131 | | |||
| 131 | def depcheck_cli(): | 132 | def depcheck_cli(): | ||
| 132 | parser = argparse.ArgumentParser() | 133 | parser = argparse.ArgumentParser() | ||
| 133 | parser.add_argument("rpm", nargs='+', help="RPMs to be tested") | 134 | parser.add_argument("rpm", nargs='+', help="RPMs to be tested") | ||
| 135 | parser.add_argument("-d", "--debug", action="store_true", help="enable debug logging for depcheck") | ||||
| 134 | parser.add_argument("-a", "--arch", choices=["i386", "x86_64", "armhfp"], help=""" | 136 | parser.add_argument("-a", "--arch", choices=["i386", "x86_64", "armhfp"], help=""" | ||
| 135 | Architecture to be tested. If omitted, defaults to the current | 137 | Architecture to be tested. If omitted, defaults to the current | ||
| 136 | machine's architecture. | 138 | machine's architecture. | ||
| 137 | """) | 139 | """) | ||
| 138 | parser.add_argument("-r", "--repo", action="append", dest="repos", help=""" | 140 | parser.add_argument("-r", "--repo", action="append", dest="repos", help=""" | ||
| 139 | Repo to be tested against. Repo can be local (in the form /dir/of/repo) | 141 | Repo to be tested against. Repo can be local (in the form /dir/of/repo) | ||
| 140 | or remote (direct link or standard metalink). | 142 | or remote (direct link or standard metalink). | ||
| 141 | Can be used multiple times, to specify more repos. | 143 | Can be used multiple times, to specify more repos. | ||
| 142 | """) | 144 | """) | ||
| 143 | parser.add_argument("-f", "--format", choices=["rpms", "updates"], help=""" | 145 | parser.add_argument("-f", "--format", choices=["rpms", "updates"], help=""" | ||
| 144 | Specify output format to override configuration. | 146 | Specify output format to override configuration. | ||
| 145 | """) | 147 | """) | ||
| 146 | parser.add_argument("-w", "--workdir", help="workdir to use for depcheck") | 148 | parser.add_argument("-w", "--workdir", help="workdir to use for depcheck") | ||
| 147 | 149 | | |||
| 148 | args = parser.parse_args() | 150 | args = parser.parse_args() | ||
| 151 | | ||||
| 152 | # initialize logging when entering depcheck via cli - this won't be executed | ||||
| 153 | # otherwise but in that case, taskotron is responsible for initialization | ||||
| 154 | logging.basicConfig() | ||||
| 155 | | ||||
| 156 | if args.debug: | ||||
| 157 | log.logger.setLevel(logging.DEBUG) | ||||
| 158 | | ||||
| 149 | # autodetect arch if none is passed in | 159 | # autodetect arch if none is passed in | ||
| 150 | arch = args.arch | 160 | arch = args.arch | ||
| 151 | if arch is None: | 161 | if arch is None: | ||
| 152 | arch = platform.machine() | 162 | arch = platform.machine() | ||
| 153 | 163 | | |||
| 154 | 164 | | |||
| 155 | repos = dict([(repo, repo) for repo in args.repos]) | 165 | repos = dict([(repo, repo) for repo in args.repos]) | ||
| 156 | 166 | | |||
| 157 | try: | 167 | try: | ||
| 158 | print run(args.rpm, arch, repos, args.format, args.workdir) | 168 | run(args.rpm, arch, repos, args.format, args.workdir) | ||
| 159 | except KeyboardInterrupt, e: | 169 | except KeyboardInterrupt: | ||
| 160 | print >> sys.stderr, ("\n\nExiting on user cancel.") | 170 | print >> sys.stderr, ("\n\nExiting on user cancel.") | ||
| 161 | sys.exit(1) | 171 | sys.exit(1) | ||
| 162 | 172 | | |||
| 163 | 173 | | |||