mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Added addcsvdata to CrOS commands
This commit is contained in:
@@ -2472,13 +2472,17 @@ gam <CrOSTypeEntity> update action <CrOSAction> [acknowledge_device_touch_requir
|
|||||||
take_a_screenshot
|
take_a_screenshot
|
||||||
|
|
||||||
gam issuecommand cros <CrOSEntity> command <CrOSCommand>
|
gam issuecommand cros <CrOSEntity> command <CrOSCommand>
|
||||||
[times_to_check_status <Integer>] [csv] [doit]
|
[times_to_check_status <Integer>] [doit]
|
||||||
|
[csv (addcsvdata <FieldName> <String>)*]
|
||||||
gam <CrOSTypeEntity> issuecommand command <CrOSCommand>
|
gam <CrOSTypeEntity> issuecommand command <CrOSCommand>
|
||||||
[times_to_check_status <Integer>] [csv] [doit]
|
[times_to_check_status <Integer>] [doit]
|
||||||
|
[csv (addcsvdata <FieldName> <String>)*]
|
||||||
gam getcommand cros <CrOSEntity> commandid <CommandID>
|
gam getcommand cros <CrOSEntity> commandid <CommandID>
|
||||||
[times_to_check_status <Integer>] [csv]
|
[times_to_check_status <Integer>]
|
||||||
|
[csv (addcsvdata <FieldName> <String>)*]
|
||||||
gam <CrOSTypeEntity> getcommand commandid <CommandID>
|
gam <CrOSTypeEntity> getcommand commandid <CommandID>
|
||||||
[times_to_check_status <Integer>] [csv]
|
[times_to_check_status <Integer>]
|
||||||
|
[csv (addcsvdata <FieldName> <String>)*]
|
||||||
|
|
||||||
<CrOSAttribute> ::=
|
<CrOSAttribute> ::=
|
||||||
(asset|assetid|tag <String>)|
|
(asset|assetid|tag <String>)|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
7.32.01
|
||||||
|
|
||||||
|
Added option `(addcsvdata <FieldName> <String>)*` to `gam <CrOSTypeEntity> issuecommand command <CrOSCommand> csv`
|
||||||
|
and `gam <CrOSTypeEntity> getcommand commandid <CommandID> csv` that adds additional columns of data to the CSV file output.
|
||||||
|
* See: https://github.com/GAM-team/GAM/wiki/ChromeOS-Devices#bulk-action-example
|
||||||
|
|
||||||
7.32.00
|
7.32.00
|
||||||
|
|
||||||
Added option `verifyallowexternal` to `gam print cigroup-members|group-members` that causes
|
Added option `verifyallowexternal` to `gam print cigroup-members|group-members` that causes
|
||||||
@@ -33,7 +39,7 @@ Fixed bug in `gam sendemail ... replyto <EmailAddress>` that caused a message de
|
|||||||
|
|
||||||
Added support for users's chat sections.
|
Added support for users's chat sections.
|
||||||
* See: https://github.com/GAM-team/GAM/wiki/Users-Chat#manage-chat-users-sections
|
* See: https://github.com/GAM-team/GAM/wiki/Users-Chat#manage-chat-users-sections
|
||||||
* This is in Deveoper Preview.
|
* This is in Deveoper Preview; you must have a `developer_preview_api_key` in `gam.cfg` to use these commands.
|
||||||
|
|
||||||
7.31.06
|
7.31.06
|
||||||
|
|
||||||
|
|||||||
@@ -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.32.00'
|
__version__ = '7.32.01'
|
||||||
__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
|
||||||
@@ -24022,7 +24022,7 @@ CROS_KIOSK_COMMANDS = {'REBOOT', 'SET_VOLUME', 'TAKE_A_SCREENSHOT'}
|
|||||||
CROS_COMMAND_FINAL_STATES = {'EXPIRED', 'CANCELLED', 'EXECUTED_BY_CLIENT'}
|
CROS_COMMAND_FINAL_STATES = {'EXPIRED', 'CANCELLED', 'EXECUTED_BY_CLIENT'}
|
||||||
CROS_COMMAND_TIME_OBJECTS = {'executeTime', 'issueTime', 'commandExpireTime'}
|
CROS_COMMAND_TIME_OBJECTS = {'executeTime', 'issueTime', 'commandExpireTime'}
|
||||||
|
|
||||||
def displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF=None):
|
def displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF, addCSVData):
|
||||||
Ind.Increment()
|
Ind.Increment()
|
||||||
try:
|
try:
|
||||||
for _ in range(0, checkResultRetries):
|
for _ in range(0, checkResultRetries):
|
||||||
@@ -24032,6 +24032,8 @@ def displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, cou
|
|||||||
customerId=GC.Values[GC.CUSTOMER_ID], deviceId=deviceId, commandId=commandId)
|
customerId=GC.Values[GC.CUSTOMER_ID], deviceId=deviceId, commandId=commandId)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
result['deviceId'] = deviceId
|
result['deviceId'] = deviceId
|
||||||
|
if addCSVData:
|
||||||
|
result.update(addCSVData)
|
||||||
csvPF.WriteRowTitles(flattenJSON(result, timeObjects=CROS_COMMAND_TIME_OBJECTS))
|
csvPF.WriteRowTitles(flattenJSON(result, timeObjects=CROS_COMMAND_TIME_OBJECTS))
|
||||||
return
|
return
|
||||||
showJSON(None, result, timeObjects=CROS_COMMAND_TIME_OBJECTS)
|
showJSON(None, result, timeObjects=CROS_COMMAND_TIME_OBJECTS)
|
||||||
@@ -24042,11 +24044,21 @@ def displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, cou
|
|||||||
entityActionFailedWarning([Ent.CROS_DEVICE, deviceId, Ent.COMMAND_ID, commandId], str(e), i, count)
|
entityActionFailedWarning([Ent.CROS_DEVICE, deviceId, Ent.COMMAND_ID, commandId], str(e), i, count)
|
||||||
Ind.Decrement()
|
Ind.Decrement()
|
||||||
|
|
||||||
|
def writeCrOSCommandResults(csvPF, addCSVData):
|
||||||
|
sortTitles = ['deviceId']
|
||||||
|
if addCSVData:
|
||||||
|
sortTitles.extend(sorted(addCSVData.keys()))
|
||||||
|
sortTitles.append('commandId')
|
||||||
|
csvPF.SetSortTitles(sortTitles)
|
||||||
|
csvPF.writeCSVfile('CrOS Commands')
|
||||||
|
|
||||||
# gam <CrOSTypeEntity> issuecommand command <CrOSCommand>
|
# gam <CrOSTypeEntity> issuecommand command <CrOSCommand>
|
||||||
# [times_to_check_status <Integer>] [csv] [doit]
|
# [times_to_check_status <Integer>] [doit]
|
||||||
|
# [csv (addcsvdata <FieldName> <String>)*]
|
||||||
def issueCommandCrOSDevices(entityList):
|
def issueCommandCrOSDevices(entityList):
|
||||||
cd = buildGAPIObject(API.DIRECTORY)
|
cd = buildGAPIObject(API.DIRECTORY)
|
||||||
csvPF = None
|
csvPF = None
|
||||||
|
addCSVData = {}
|
||||||
body = {}
|
body = {}
|
||||||
checkResultRetries = 1
|
checkResultRetries = 1
|
||||||
doit = False
|
doit = False
|
||||||
@@ -24059,7 +24071,9 @@ def issueCommandCrOSDevices(entityList):
|
|||||||
elif myarg == 'timestocheckstatus':
|
elif myarg == 'timestocheckstatus':
|
||||||
checkResultRetries = getInteger(minVal=0)
|
checkResultRetries = getInteger(minVal=0)
|
||||||
elif myarg == 'csv':
|
elif myarg == 'csv':
|
||||||
csvPF = CSVPrintFile(['deviceId'], 'sortall')
|
csvPF = CSVPrintFile(['deviceId'])
|
||||||
|
elif csvPF and myarg == 'addcsvdata':
|
||||||
|
getAddCSVData(addCSVData)
|
||||||
elif myarg == 'doit':
|
elif myarg == 'doit':
|
||||||
doit = True
|
doit = True
|
||||||
else:
|
else:
|
||||||
@@ -24078,7 +24092,7 @@ def issueCommandCrOSDevices(entityList):
|
|||||||
customerId=GC.Values[GC.CUSTOMER_ID], deviceId=deviceId, body=body)
|
customerId=GC.Values[GC.CUSTOMER_ID], deviceId=deviceId, body=body)
|
||||||
commandId = result.get('commandId')
|
commandId = result.get('commandId')
|
||||||
entityActionPerformed([Ent.CROS_DEVICE, deviceId, Ent.ACTION, body['commandType'], Ent.COMMAND_ID, commandId], i, count)
|
entityActionPerformed([Ent.CROS_DEVICE, deviceId, Ent.ACTION, body['commandType'], Ent.COMMAND_ID, commandId], i, count)
|
||||||
displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF)
|
displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF, addCSVData)
|
||||||
except GAPI.invalidArgument as e:
|
except GAPI.invalidArgument as e:
|
||||||
errMsg = str(e)
|
errMsg = str(e)
|
||||||
if body['commandType'] in CROS_KIOSK_COMMANDS:
|
if body['commandType'] in CROS_KIOSK_COMMANDS:
|
||||||
@@ -24087,18 +24101,21 @@ def issueCommandCrOSDevices(entityList):
|
|||||||
except GAPI.notFound as e:
|
except GAPI.notFound as e:
|
||||||
entityActionFailedWarning([Ent.CROS_DEVICE, deviceId], str(e), i, count)
|
entityActionFailedWarning([Ent.CROS_DEVICE, deviceId], str(e), i, count)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('CrOS Commands')
|
writeCrOSCommandResults(csvPF, addCSVData)
|
||||||
|
|
||||||
# gam issuecommand <CrOSEntity> command <CrOSCommand>
|
# gam issuecommand <CrOSEntity> command <CrOSCommand>
|
||||||
# [times_to_check_status <Integer>] [csv] [doit]
|
# [times_to_check_status <Integer>] [doit]
|
||||||
|
# [csv (addcsvdata <FieldName> <String>)*]
|
||||||
def doIssueCommandCrOSDevices():
|
def doIssueCommandCrOSDevices():
|
||||||
issueCommandCrOSDevices(getCrOSDeviceEntity())
|
issueCommandCrOSDevices(getCrOSDeviceEntity())
|
||||||
|
|
||||||
# gam <CrOSTypeEntity> getcommand commandid <CommandID>
|
# gam <CrOSTypeEntity> getcommand commandid <CommandID>
|
||||||
# [times_to_check_status <Integer>] [csv]
|
# [times_to_check_status <Integer>] [csv]
|
||||||
|
# [csv (addcsvdata <FieldName> <String>)*]
|
||||||
def getCommandResultCrOSDevices(entityList):
|
def getCommandResultCrOSDevices(entityList):
|
||||||
cd = buildGAPIObject(API.DIRECTORY)
|
cd = buildGAPIObject(API.DIRECTORY)
|
||||||
csvPF = None
|
csvPF = None
|
||||||
|
addCSVData = {}
|
||||||
commandId = ''
|
commandId = ''
|
||||||
checkResultRetries = 1
|
checkResultRetries = 1
|
||||||
while Cmd.ArgumentsRemaining():
|
while Cmd.ArgumentsRemaining():
|
||||||
@@ -24108,7 +24125,9 @@ def getCommandResultCrOSDevices(entityList):
|
|||||||
elif myarg == 'timestocheckstatus':
|
elif myarg == 'timestocheckstatus':
|
||||||
checkResultRetries = getInteger(minVal=0)
|
checkResultRetries = getInteger(minVal=0)
|
||||||
elif myarg == 'csv':
|
elif myarg == 'csv':
|
||||||
csvPF = CSVPrintFile(['deviceId'], 'sortall')
|
csvPF = CSVPrintFile(['deviceId'])
|
||||||
|
elif csvPF and myarg == 'addcsvdata':
|
||||||
|
getAddCSVData(addCSVData)
|
||||||
else:
|
else:
|
||||||
unknownArgumentExit()
|
unknownArgumentExit()
|
||||||
if not commandId:
|
if not commandId:
|
||||||
@@ -24117,12 +24136,13 @@ def getCommandResultCrOSDevices(entityList):
|
|||||||
for deviceId in entityList:
|
for deviceId in entityList:
|
||||||
i += 1
|
i += 1
|
||||||
printEntity([Ent.CROS_DEVICE, deviceId, Ent.COMMAND_ID, commandId], i, count)
|
printEntity([Ent.CROS_DEVICE, deviceId, Ent.COMMAND_ID, commandId], i, count)
|
||||||
displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF)
|
displayCrOSCommandResult(cd, deviceId, commandId, checkResultRetries, i, count, csvPF, addCSVData)
|
||||||
if csvPF:
|
if csvPF:
|
||||||
csvPF.writeCSVfile('CrOS Commands')
|
writeCrOSCommandResults(csvPF, addCSVData)
|
||||||
|
|
||||||
# gam getcommand <CrOSEntity> commandid <CommandID>
|
# gam getcommand <CrOSEntity> commandid <CommandID>
|
||||||
# [times_to_check_status <Integer>] [csv]
|
# [times_to_check_status <Integer>] [csv]
|
||||||
|
# [csv (addcsvdata <FieldName> <String>)*]
|
||||||
def doGetCommandResultCrOSDevices():
|
def doGetCommandResultCrOSDevices():
|
||||||
getCommandResultCrOSDevices(getCrOSDeviceEntity())
|
getCommandResultCrOSDevices(getCrOSDeviceEntity())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user