|
1 | 1 | #!/bin/env python3
|
2 | 2 |
|
3 |
| -import sys; |
4 |
| -print(sys.path) |
5 |
| - |
6 | 3 | import os
|
7 | 4 | from datetime import datetime
|
8 | 5 | import argparse
|
|
13 | 10 |
|
14 | 11 |
|
15 | 12 | 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 |
17 | 14 | ) -> 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 |
20 | 22 | """
|
21 | 23 |
|
22 | 24 | client = Client.create_from_config_file()
|
23 | 25 | current_GMT = time.gmtime()
|
24 | 26 | timestamp = calendar.timegm(current_GMT)
|
25 | 27 |
|
| 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 | + |
26 | 35 | try:
|
27 | 36 | monitor = client.monitor_proxy.monitor(
|
28 | 37 | ownername=copr_ownername, projectname=copr_projectname
|
@@ -88,15 +97,23 @@ def main():
|
88 | 97 | "--separator",
|
89 | 98 | dest="separator",
|
90 | 99 | type=str,
|
91 |
| - default=";", |
| 100 | + default=",", |
92 | 101 | help="separator to delimit fields",
|
93 | 102 | )
|
94 | 103 |
|
| 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 | + |
95 | 111 | args = parser.parse_args()
|
96 | 112 | gather_build_stats(
|
97 | 113 | copr_ownername=args.copr_ownername,
|
98 | 114 | copr_projectname=args.copr_projectname,
|
99 | 115 | separator=args.separator,
|
| 116 | + show_header=args.show_header, |
100 | 117 | )
|
101 | 118 | sys.exit(0)
|
102 | 119 |
|
|
0 commit comments