Skip to content

Commit 3f4a517

Browse files
committed
Updated commands that display Chrome device counts to display the date in the output
1 parent 6185431 commit 3f4a517

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/GamUpdate.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
7.28.04
2+
3+
Updated commands that display Chrome device counts to display the date in the output.
4+
5+
* See: https://github.com/GAM-team/GAM/wiki/Chrome-Device-Counts
6+
17
7.28.03
28

39
Improved commands to display Chrome device counts.

src/gam/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"""
2626

2727
__author__ = 'GAM Team <[email protected]>'
28-
__version__ = '7.28.03'
28+
__version__ = '7.28.04'
2929
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
3030

3131
#pylint: disable=wrong-import-position
@@ -31946,7 +31946,7 @@ def _showNeedsAttn(needsattn, i=0, count=0):
3194631946
def doPrintShowChromeDeviceCounts():
3194731947
cm = buildGAPIObject(API.CHROMEMANAGEMENT)
3194831948
customerId = _getCustomersCustomerIdWithC()
31949-
csvPF = CSVPrintFile() if Act.csvFormat() else None
31949+
csvPF = CSVPrintFile(['date']) if Act.csvFormat() else None
3195031950
FJQC = FormatJSONQuoteChar(csvPF)
3195131951
pdate = todaysDate()
3195231952
functionList = []
@@ -31966,9 +31966,10 @@ def doPrintShowChromeDeviceCounts():
3196631966
if not functionList:
3196731967
mode = titleMode = 'all'
3196831968
functionList = CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode]
31969+
pfdate = pdate.strftime(YYYYMMDD_FORMAT)
3196931970
kwargs = {'date_day': pdate.day, 'date_month': pdate.month, 'date_year': pdate.year}
3197031971
counts = {}
31971-
titles = []
31972+
titles = ['date']
3197231973
try:
3197331974
for function in functionList:
3197431975
result = callGAPI(cm.customers().reports(), function,
@@ -31984,16 +31985,17 @@ def doPrintShowChromeDeviceCounts():
3198431985
counts[k] = int(v)
3198531986
if not csvPF:
3198631987
if not FJQC.formatJSON:
31987-
showJSON(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode], counts, sortDictKeys=False)
31988+
showJSON(f'{CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode]} - {pfdate}', counts, sortDictKeys=False)
3198831989
else:
3198931990
printLine(json.dumps(counts, ensure_ascii=False, sort_keys=False))
3199031991
else:
3199131992
csvPF.SetTitles(titles)
31992-
row = flattenJSON(counts)
31993+
row = {'date': pfdate}
31994+
flattenJSON(counts, flattened=row)
3199331995
if not FJQC.formatJSON:
3199431996
csvPF.WriteRow(row)
3199531997
elif csvPF.CheckRowTitles(row):
31996-
csvPF.WriteRowNoFilter({'JSON': json.dumps(counts, ensure_ascii=False, sort_keys=False)})
31998+
csvPF.WriteRowNoFilter({'date': pfdate, 'JSON': json.dumps(counts, ensure_ascii=False, sort_keys=False)})
3199731999
csvPF.writeCSVfile(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode])
3199832000

3199932001
CHROME_VERSIONS_TITLES = ['channel', 'system', 'deviceOsVersion']

0 commit comments

Comments
 (0)