-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_artifacts_status_fail.py
executable file
·64 lines (50 loc) · 1.62 KB
/
show_artifacts_status_fail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /usr/bin/env python3
import logging
from rl_scan_artifactory import (
MyArgs,
)
from rl_scan_artifactory.app_base_with_logging import AppBaseWithLogging
from rl_scan_artifactory.artifactory_api import ArtifactoryApi
logger = logging.getLogger(__name__)
class ArtifactoryCleanup(
AppBaseWithLogging,
):
def __init__(
self,
args: MyArgs,
) -> None:
super().__init__(args)
self.repo_list = self.cli_args["repo"]
self.artifactory_api = ArtifactoryApi(args=args)
self.verbose = self.cli_args["verbose"]
logger.debug("%s", args.cli_args)
def run(
self,
) -> None:
rr = self.artifactory_api.search_prop_fail()
logger.debug("%s", rr)
if "results" not in rr:
return
for item in rr["results"]:
uri = item.get("uri")
if not uri:
continue
repo_list = self.cli_args.get("repo")
if repo_list is None or len(repo_list) == 0:
print(uri)
continue
for repo in repo_list:
if f"/storage/{repo}/" in uri or f"/storage/{repo}-cache/" in uri:
print(uri)
def main() -> None:
for name in ["requests", "urllib3"]:
# https://stackoverflow.com/questions/11029717/how-do-i-disable-log-messages-from-the-requests-library
logging.getLogger(name).setLevel(logging.CRITICAL)
logging.getLogger(name).propagate = False
args = MyArgs(
repo_list_may_be_empty=True,
no_portal_or_cli=True,
)
ac = ArtifactoryCleanup(args=args)
ac.run()
main()