-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdump-pub-staged
More file actions
executable file
·81 lines (61 loc) · 2.24 KB
/
dump-pub-staged
File metadata and controls
executable file
·81 lines (61 loc) · 2.24 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
import os
import json
import logging
import shutil
import datetime
from xmlrpc.client import ServerProxy
from argparse import ArgumentParser
from pushsource import Source
log = logging.getLogger("dump-pub-staged")
def run(args):
pub = ServerProxy(args.pub_url + "client/")
kwargs = {"source": "staged"}
for kv_str in args.kv:
key, value = kv_str.split("=")
kwargs[key] = value
# If no date was applied, always force one to avoid overloading
if "date_from" not in kwargs:
date_from = datetime.date.today() - datetime.timedelta(days=365)
kwargs["date_from"] = date_from.strftime("%Y-%m-%d")
found = pub.client.push_query(kwargs)
found = reversed(json.loads(found))
for push in found:
task_info = pub.client.task_info(push["task_id"])
dump_task(task_info)
def dump_task(task_info):
log.info("\n========= Pub task: %s =============================", task_info["id"])
stagedirs = (task_info.get("args") or {}).get("file_list") or []
if not stagedirs:
log.warning("<no staging directories found>")
return
log.info("STAGED: %s", ", ".join(stagedirs))
with Source.get("staged:", url=stagedirs) as source:
count = 0
for pushitem in source:
log.info(" %s", pushitem)
count += 1
log.info("=========== %s item(s) ================================", count)
def main():
log.setLevel(logging.INFO)
parser = ArgumentParser(
description="Look at staged push task(s) from Pub and dump contents of staging areas"
)
parser.add_argument("--debug", action="store_true")
parser.add_argument("--pub-url", default="https://pub.devel.redhat.com/pub/xmlrpc/")
parser.add_argument(
"kv",
nargs="*",
help="Extra keys/values for search, e.g. target=cdn-live, date_from=2020-01-01",
)
p = parser.parse_args()
if p.debug:
logging.basicConfig(format="%(threadName)s %(message)s")
logging.getLogger().setLevel(logging.DEBUG)
log.setLevel(logging.DEBUG)
logging.getLogger("pushsource").setLevel(logging.DEBUG)
else:
logging.basicConfig(format="%(message)s")
run(p)
if __name__ == "__main__":
main()