Skip to content

Commit 85f753b

Browse files
committed
Add --show-header argument to print the first row as a header
1 parent 5d69776 commit 85f753b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

build-stats/create-diagrams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def prepare_data(filepath: str = "build-stats.csv") -> pd.DataFrame:
150150
df = pd.read_csv(
151151
filepath_or_buffer=filepath,
152152
parse_dates=True,
153-
delimiter=";",
153+
delimiter=",",
154154
header=0,
155155
names=[
156156
"date",

build-stats/get-build-stats.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/bin/env python3
22

3-
import sys;
4-
print(sys.path)
5-
63
import os
74
from datetime import datetime
85
import argparse
@@ -13,16 +10,28 @@
1310

1411

1512
def gather_build_stats(
16-
copr_ownername: str, copr_projectname: str, separator: str
13+
copr_ownername: str, copr_projectname: str, separator: str, show_header: bool
1714
) -> None:
18-
"""
19-
Prints stats for each build of the passed copr project
15+
"""Prints stats for each build of the passed copr project
16+
17+
Args:
18+
copr_ownername (str): The copr project's owner
19+
copr_projectname (str): The copr project's name
20+
separator (str): How to separate CSV data (e.g. by semicolon or comma)
21+
show_header (bool): Show a first line header
2022
"""
2123

2224
client = Client.create_from_config_file()
2325
current_GMT = time.gmtime()
2426
timestamp = calendar.timegm(current_GMT)
2527

28+
if show_header:
29+
print(
30+
"date{sep}package{sep}chroot{sep}build_time{sep}state{sep}build_id{sep}timestamp".format(
31+
sep=separator
32+
)
33+
)
34+
2635
try:
2736
monitor = client.monitor_proxy.monitor(
2837
ownername=copr_ownername, projectname=copr_projectname
@@ -88,15 +97,23 @@ def main():
8897
"--separator",
8998
dest="separator",
9099
type=str,
91-
default=";",
100+
default=",",
92101
help="separator to delimit fields",
93102
)
94103

104+
parser.add_argument(
105+
"--show-header",
106+
dest="show_header",
107+
action="store_true",
108+
help="The first row will be a header row",
109+
)
110+
95111
args = parser.parse_args()
96112
gather_build_stats(
97113
copr_ownername=args.copr_ownername,
98114
copr_projectname=args.copr_projectname,
99115
separator=args.separator,
116+
show_header=args.show_header,
100117
)
101118
sys.exit(0)
102119

0 commit comments

Comments
 (0)