Skip to content

Commit 053a647

Browse files
Update refresh_project_copyrights.py
Added dry run option
1 parent 5ed3923 commit 053a647

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/client/refresh_project_copyrights.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def RepWarning(msg):
4848
parser.add_argument("--max-versions-per-project", dest='max_versions_per_project', type=int, help="Maximum versions per project to inspect else all")
4949
parser.add_argument("--max-components", dest='max_components', type=int, help="Maximum components to inspect in total else all")
5050

51-
parser.add_argument("--debug", dest='debug', type=int, default=0, help="Debug verbosity (0=none)")
51+
parser.add_argument("--debug", dest='debug', type=int, default=0, help="Debug verbosity (0=none 'n'=level)")
52+
parser.add_argument("--dryrun", dest='dry_run', type=int, default=0, help="Dry run test (0=no 1=yes)")
5253

5354
parser.add_argument("--no-verify", dest='verify', action='store_false', help="Disable TLS certificate verification")
5455
parser.add_argument("-t", "--timeout", default=15, type=int, help="Adjust the (HTTP) session timeout value (default: 15s)")
@@ -228,13 +229,17 @@ def RepWarning(msg):
228229
# refresh end point
229230
url += "/copyrights-refresh"
230231

231-
try:
232-
response = bd.session.put(url, data=None, **refresh_kwargs)
233-
RepDebug(5,'Refresh response %s' % response)
234-
except urllib3.exceptions.ReadTimeoutError:
235-
print('Failed to confirm copyrights refresh')
232+
if args.dry_run != 0:
233+
RepDebug(1, "DryRun: %s" % url)
234+
else:
235+
try:
236+
response = bd.session.put(url, data=None, **refresh_kwargs)
237+
RepDebug(5,'Refresh response %s' % response)
238+
except ReadTimeoutError:
239+
print('Failed to confirm copyrights refresh')
240+
241+
my_statistics['_cntRefresh'] += 1
236242

237-
my_statistics['_cntRefresh'] += 1
238243
else:
239244
my_statistics['_cntNoOrigins'] += 1
240245
url = 'n/a'

0 commit comments

Comments
 (0)