mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Improved commands to display Chrome device counts.
This commit is contained in:
@@ -2232,36 +2232,6 @@ gam print browsertokens [todrive <ToDriveAttribute>*]
|
|||||||
[sortheaders]
|
[sortheaders]
|
||||||
[formatjson [quotechar <Character>]]
|
[formatjson [quotechar <Character>]]
|
||||||
|
|
||||||
# Chrome Installed Apps Counts
|
|
||||||
|
|
||||||
gam show chromeapps
|
|
||||||
[(ou <OrgUnitItem>)|(ou_and_children <OrgUnitItem>)|
|
|
||||||
(ous <OrgUnitList>)|(ous_and_children <OrgUnitList>)]
|
|
||||||
[filter <String>]
|
|
||||||
[orderby appname|apptype|installtype|numberofpermissions|totalinstallcount]
|
|
||||||
[formatjson]
|
|
||||||
gam print chromeapps [todrive <ToDriveAttribute>*]
|
|
||||||
[(ou <OrgUnitItem>)|(ou_and_children <OrgUnitItem>)|
|
|
||||||
(ous <OrgUnitList>)|(ous_and_children <OrgUnitList>)]
|
|
||||||
[filter <String>]
|
|
||||||
[orderby appname|apptype|installtype|numberofpermissions|totalinstallcount]
|
|
||||||
[formatjson [quotechar <Character>]] [delimiter <Character>]
|
|
||||||
|
|
||||||
gam show chromeappdevices
|
|
||||||
appid <AppID> apptype extension|app|theme|hostedapp|androidapp
|
|
||||||
[(ou <OrgUnitItem>)|(ou_and_children <OrgUnitItem>)|
|
|
||||||
(ous <OrgUnitList>)|(ous_and_children <OrgUnitList>)]
|
|
||||||
[start <Date>] [end <Date>]
|
|
||||||
[orderby deviceid|machine]
|
|
||||||
[formatjson]
|
|
||||||
gam print chromeappdevices [todrive <ToDriveAttribute>*]
|
|
||||||
appid <AppID> apptype extension|app|theme|hostedapp|androidapp
|
|
||||||
[(ou <OrgUnitItem>)|(ou_and_children <OrgUnitItem>)|
|
|
||||||
(ous <OrgUnitList>)|(ous_and_children <OrgUnitList>)]
|
|
||||||
[start <Date>] [end <Date>]
|
|
||||||
[orderby deviceid|machine]
|
|
||||||
[formatjson [quotechar <Character>]]
|
|
||||||
|
|
||||||
# Chrome Auto Update Expiration Counts
|
# Chrome Auto Update Expiration Counts
|
||||||
|
|
||||||
gam print chromeaues [todrive <ToDriveAttribute>*]
|
gam print chromeaues [todrive <ToDriveAttribute>*]
|
||||||
@@ -2374,10 +2344,10 @@ gam print chromeprofilecommands <ChromeProfileNameEntity> [todrive <ToDriveAttri
|
|||||||
# Chrome Device Counts
|
# Chrome Device Counts
|
||||||
|
|
||||||
gam show chromedevicecounts
|
gam show chromedevicecounts
|
||||||
[mode active|perboottype|perreleasechannel] [date <Date>]
|
(mode all|active|perboottype|perreleasechannel)* [date <Date>]
|
||||||
[formatjson]
|
[formatjson]
|
||||||
gam print chromedevicecounts [todrive <ToDriveAttribute>*]
|
gam print chromedevicecounts [todrive <ToDriveAttribute>*]
|
||||||
[mode active|perboottype|perreleasechannel] [date <Date>]
|
(mode all|active|perboottype|perreleasechannel) [date <Date>]
|
||||||
[formatjson [quotechar <Character>]]
|
[formatjson [quotechar <Character>]]
|
||||||
|
|
||||||
# Chrome Versions Counts
|
# Chrome Versions Counts
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
7.28.03
|
||||||
|
|
||||||
|
Improved commands to display Chrome device counts.
|
||||||
|
|
||||||
|
* See: https://github.com/GAM-team/GAM/wiki/Chrome-Device-Counts
|
||||||
|
|
||||||
7.28.02
|
7.28.02
|
||||||
|
|
||||||
Added commands to display Chrome device counts.
|
Added 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.02'
|
__version__ = '7.28.03'
|
||||||
__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
|
||||||
@@ -31810,10 +31810,12 @@ def doPrintShowChromeAues():
|
|||||||
j = 0
|
j = 0
|
||||||
for aue in sorted(aues, key=lambda k: k.get('model', UNKNOWN)):
|
for aue in sorted(aues, key=lambda k: k.get('model', UNKNOWN)):
|
||||||
j += 1
|
j += 1
|
||||||
|
aue['count'] = int(aue['count'])
|
||||||
_showAue(aue, j, jcount)
|
_showAue(aue, j, jcount)
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
else:
|
else:
|
||||||
for aue in sorted(aues, key=lambda k: k.get('model', UNKNOWN)):
|
for aue in sorted(aues, key=lambda k: k.get('model', UNKNOWN)):
|
||||||
|
aue['count'] = int(aue['count'])
|
||||||
_printAue(aue)
|
_printAue(aue)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('Chrome AUEs')
|
csvPF.writeCSVfile('Chrome AUEs')
|
||||||
@@ -31907,6 +31909,8 @@ def doPrintShowChromeNeedsAttn():
|
|||||||
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
|
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
|
||||||
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
customer=customerId, orgUnitId=orgUnitId, readMask=','.join(CHROME_NEEDSATTN_TITLES))
|
customer=customerId, orgUnitId=orgUnitId, readMask=','.join(CHROME_NEEDSATTN_TITLES))
|
||||||
|
for k, v in result.items():
|
||||||
|
result[k] = int(v)
|
||||||
for field in CHROME_NEEDSATTN_TITLES:
|
for field in CHROME_NEEDSATTN_TITLES:
|
||||||
result.setdefault(field, 0)
|
result.setdefault(field, 0)
|
||||||
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
|
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
|
||||||
@@ -31919,23 +31923,25 @@ def doPrintShowChromeNeedsAttn():
|
|||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('Chrome Devices Needing Attention')
|
csvPF.writeCSVfile('Chrome Devices Needing Attention')
|
||||||
|
|
||||||
CHROME_DEVICE_COUNTS_MODE_CHOICES = ['active', 'perboottype', 'perreleasechannel']
|
CHROME_DEVICE_COUNTS_MODE_CHOICES = ['all', 'active', 'perboottype', 'perreleasechannel']
|
||||||
CHROME_DEVICE_COUNTS_MODE_FUNCTIONS = {
|
CHROME_DEVICE_COUNTS_MODE_FUNCTIONS = {
|
||||||
'active': 'countActiveDevices',
|
'all': ['countActiveDevices', 'countDevicesPerBootType', 'countDevicesPerReleaseChannel'],
|
||||||
'perboottype': 'countDevicesPerBootType',
|
'active': ['countActiveDevices'],
|
||||||
'perreleasechannel': 'countDevicesPerReleaseChannel'
|
'perboottype': ['countDevicesPerBootType'],
|
||||||
|
'perreleasechannel': ['countDevicesPerReleaseChannel']
|
||||||
}
|
}
|
||||||
CHROME_DEVICE_COUNTS_MODE_CSV_TITLE = {
|
CHROME_DEVICE_COUNTS_MODE_CSV_TITLE = {
|
||||||
|
'all': 'Chrome Device Counts',
|
||||||
'active': 'Chrome Active Devices',
|
'active': 'Chrome Active Devices',
|
||||||
'perboottype': 'Chrome Devices per Boot Type',
|
'perboottype': 'Chrome Devices per Boot Type',
|
||||||
'perreleasechannel': 'Chrome Devices per Release Channel'
|
'perreleasechannel': 'Chrome Devices per Release Channel'
|
||||||
}
|
}
|
||||||
|
|
||||||
# gam print chromedevicecounts [todrive <ToDriveAttribute>*]
|
# gam print chromedevicecounts [todrive <ToDriveAttribute>*]
|
||||||
# [mode active|perboottype|perreleasechannel] [date <Date>]
|
# (mode all|active|perboottype|perreleasechannel)* [date <Date>]
|
||||||
# [formatjson [quotechar <Character>]]
|
# [formatjson [quotechar <Character>]]
|
||||||
# gam show chromedevicecounts
|
# gam show chromedevicecounts
|
||||||
# [mode active|perboottype|perreleasechannel] [date <Date>]
|
# (mode all|active|perboottype|perreleasechannel)* [date <Date>]
|
||||||
# [formatjson]
|
# [formatjson]
|
||||||
def doPrintShowChromeDeviceCounts():
|
def doPrintShowChromeDeviceCounts():
|
||||||
cm = buildGAPIObject(API.CHROMEMANAGEMENT)
|
cm = buildGAPIObject(API.CHROMEMANAGEMENT)
|
||||||
@@ -31943,23 +31949,34 @@ def doPrintShowChromeDeviceCounts():
|
|||||||
csvPF = CSVPrintFile() if Act.csvFormat() else None
|
csvPF = CSVPrintFile() if Act.csvFormat() else None
|
||||||
FJQC = FormatJSONQuoteChar(csvPF)
|
FJQC = FormatJSONQuoteChar(csvPF)
|
||||||
pdate = todaysDate()
|
pdate = todaysDate()
|
||||||
mode = 'active'
|
functionList = []
|
||||||
|
titleMode = 'all'
|
||||||
while Cmd.ArgumentsRemaining():
|
while Cmd.ArgumentsRemaining():
|
||||||
myarg = getArgument()
|
myarg = getArgument()
|
||||||
if csvPF and myarg == 'todrive':
|
if csvPF and myarg == 'todrive':
|
||||||
csvPF.GetTodriveParameters()
|
csvPF.GetTodriveParameters()
|
||||||
elif myarg == 'mode':
|
elif myarg == 'mode':
|
||||||
mode = getChoice(CHROME_DEVICE_COUNTS_MODE_CHOICES)
|
mode = getChoice(CHROME_DEVICE_COUNTS_MODE_CHOICES)
|
||||||
|
titleMode = mode if not functionList else 'all'
|
||||||
|
functionList.extend(CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode])
|
||||||
elif myarg == 'date':
|
elif myarg == 'date':
|
||||||
pdate = getYYYYMMDD(returnDateTime=True)
|
pdate = getYYYYMMDD(returnDateTime=True)
|
||||||
else:
|
else:
|
||||||
FJQC.GetFormatJSONQuoteChar(myarg, True)
|
FJQC.GetFormatJSONQuoteChar(myarg, True)
|
||||||
|
if not functionList:
|
||||||
|
mode = titleMode = 'all'
|
||||||
|
functionList = CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode]
|
||||||
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 = {}
|
||||||
|
titles = []
|
||||||
try:
|
try:
|
||||||
counts = callGAPI(cm.customers().reports(), CHROME_DEVICE_COUNTS_MODE_FUNCTIONS[mode],
|
for function in functionList:
|
||||||
|
result = callGAPI(cm.customers().reports(), function,
|
||||||
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
|
throwReasons=[GAPI.INVALID, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED, GAPI.SERVICE_NOT_AVAILABLE],
|
||||||
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
retryReasons=GAPI.SERVICE_NOT_AVAILABLE_RETRY_REASONS,
|
||||||
customer=customerId, **kwargs)
|
customer=customerId, **kwargs)
|
||||||
|
counts.update(result)
|
||||||
|
titles.extend(result.keys())
|
||||||
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
|
except (GAPI.invalid, GAPI.invalidArgument, GAPI.permissionDenied, GAPI.serviceNotAvailable) as e:
|
||||||
entityActionFailedWarning([Ent.CHROME_DEVICE_COUNT, None], str(e))
|
entityActionFailedWarning([Ent.CHROME_DEVICE_COUNT, None], str(e))
|
||||||
return
|
return
|
||||||
@@ -31967,16 +31984,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[mode], counts)
|
showJSON(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode], counts, sortDictKeys=False)
|
||||||
else:
|
else:
|
||||||
printLine(json.dumps(cleanJSON(counts), ensure_ascii=False, sort_keys=True))
|
printLine(json.dumps(counts, ensure_ascii=False, sort_keys=False))
|
||||||
else:
|
else:
|
||||||
|
csvPF.SetTitles(titles)
|
||||||
row = flattenJSON(counts)
|
row = flattenJSON(counts)
|
||||||
if not FJQC.formatJSON:
|
if not FJQC.formatJSON:
|
||||||
csvPF.WriteRowTitles(row)
|
csvPF.WriteRow(row)
|
||||||
elif csvPF.CheckRowTitles(row):
|
elif csvPF.CheckRowTitles(row):
|
||||||
csvPF.WriteRowNoFilter({'JSON': json.dumps(cleanJSON(counts), ensure_ascii=False, sort_keys=True)})
|
csvPF.WriteRowNoFilter({'JSON': json.dumps(counts, ensure_ascii=False, sort_keys=False)})
|
||||||
csvPF.writeCSVfile(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[mode])
|
csvPF.writeCSVfile(CHROME_DEVICE_COUNTS_MODE_CSV_TITLE[titleMode])
|
||||||
|
|
||||||
CHROME_VERSIONS_TITLES = ['channel', 'system', 'deviceOsVersion']
|
CHROME_VERSIONS_TITLES = ['channel', 'system', 'deviceOsVersion']
|
||||||
|
|
||||||
@@ -32104,10 +32122,12 @@ def doPrintShowChromeVersions():
|
|||||||
j = 0
|
j = 0
|
||||||
for version in sorted(versions, key=_getVersionKey, reverse=reverse):
|
for version in sorted(versions, key=_getVersionKey, reverse=reverse):
|
||||||
j += 1
|
j += 1
|
||||||
|
version['count'] = int(version['count'])
|
||||||
_showVersion(version, j, jcount)
|
_showVersion(version, j, jcount)
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
else:
|
else:
|
||||||
for version in sorted(versions, key=_getVersionKey, reverse=reverse):
|
for version in sorted(versions, key=_getVersionKey, reverse=reverse):
|
||||||
|
version['count'] = int(version['count'])
|
||||||
_printVersion(version)
|
_printVersion(version)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('Chrome Versions')
|
csvPF.writeCSVfile('Chrome Versions')
|
||||||
|
|||||||
Reference in New Issue
Block a user