mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 21:01:36 +00:00
Updated commands that display Chrome device counts to display the date in the output
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
7.28.04
|
||||||
|
|
||||||
|
Updated commands that display Chrome device counts to display the date in the output.
|
||||||
|
|
||||||
|
* See: https://github.com/GAM-team/GAM/wiki/Chrome-Device-Counts
|
||||||
|
|
||||||
7.28.03
|
7.28.03
|
||||||
|
|
||||||
Improved commands to display Chrome device counts.
|
Improved commands to display Chrome device counts.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||||
__version__ = '7.28.03'
|
__version__ = '7.28.04'
|
||||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||||
|
|
||||||
#pylint: disable=wrong-import-position
|
#pylint: disable=wrong-import-position
|
||||||
@@ -31946,7 +31946,7 @@ CHROME_DEVICE_COUNTS_MODE_CSV_TITLE = {
|
|||||||
def doPrintShowChromeDeviceCounts():
|
def doPrintShowChromeDeviceCounts():
|
||||||
cm = buildGAPIObject(API.CHROMEMANAGEMENT)
|
cm = buildGAPIObject(API.CHROMEMANAGEMENT)
|
||||||
customerId = _getCustomersCustomerIdWithC()
|
customerId = _getCustomersCustomerIdWithC()
|
||||||
csvPF = CSVPrintFile() if Act.csvFormat() else None
|
csvPF = CSVPrintFile(['date']) if Act.csvFormat() else None
|
||||||
FJQC = FormatJSONQuoteChar(csvPF)
|
FJQC = FormatJSONQuoteChar(csvPF)
|
||||||
pdate = todaysDate()
|
pdate = todaysDate()
|
||||||
functionList = []
|
functionList = []
|
||||||
@@ -31966,9 +31966,10 @@ def doPrintShowChromeDeviceCounts():
|
|||||||
if not functionList:
|
if not functionList:
|
||||||
mode = titleMode = 'all'
|
mode = titleMode = 'all'
|
||||||
functionList = CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode]
|
functionList = CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode]
|
||||||
|
pfdate = pdate.strftime(YYYYMMDD_FORMAT)
|
||||||
kwargs = {'date_day': pdate.day, 'date_month': pdate.month, 'date_year': pdate.year}
|
kwargs = {'date_day': pdate.day, 'date_month': pdate.month, 'date_year': pdate.year}
|
||||||
counts = {}
|
counts = {}
|
||||||
titles = []
|
titles = ['date']
|
||||||
try:
|
try:
|
||||||
for function in functionList:
|
for function in functionList:
|
||||||
result = callGAPI(cm.customers().reports(), function,
|
result = callGAPI(cm.customers().reports(), function,
|
||||||
@@ -31984,16 +31985,17 @@ def doPrintShowChromeDeviceCounts():
|
|||||||
counts[k] = int(v)
|
counts[k] = int(v)
|
||||||
if not csvPF:
|
if not csvPF:
|
||||||
if not FJQC.formatJSON:
|
if not FJQC.formatJSON:
|
||||||
showJSON(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode], counts, sortDictKeys=False)
|
showJSON(f'{CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode]} - {pfdate}', counts, sortDictKeys=False)
|
||||||
else:
|
else:
|
||||||
printLine(json.dumps(counts, ensure_ascii=False, sort_keys=False))
|
printLine(json.dumps(counts, ensure_ascii=False, sort_keys=False))
|
||||||
else:
|
else:
|
||||||
csvPF.SetTitles(titles)
|
csvPF.SetTitles(titles)
|
||||||
row = flattenJSON(counts)
|
row = {'date': pfdate}
|
||||||
|
flattenJSON(counts, flattened=row)
|
||||||
if not FJQC.formatJSON:
|
if not FJQC.formatJSON:
|
||||||
csvPF.WriteRow(row)
|
csvPF.WriteRow(row)
|
||||||
elif csvPF.CheckRowTitles(row):
|
elif csvPF.CheckRowTitles(row):
|
||||||
csvPF.WriteRowNoFilter({'JSON': json.dumps(counts, ensure_ascii=False, sort_keys=False)})
|
csvPF.WriteRowNoFilter({'date': pfdate, 'JSON': json.dumps(counts, ensure_ascii=False, sort_keys=False)})
|
||||||
csvPF.writeCSVfile(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode])
|
csvPF.writeCSVfile(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode])
|
||||||
|
|
||||||
CHROME_VERSIONS_TITLES = ['channel', 'system', 'deviceOsVersion']
|
CHROME_VERSIONS_TITLES = ['channel', 'system', 'deviceOsVersion']
|
||||||
|
|||||||
Reference in New Issue
Block a user