Revert "Standardize info cros/print cros/print crosactivity (#468)" (#469)

This reverts commit d50231b888.
This commit is contained in:
Jay Lee
2017-04-01 10:30:29 -04:00
committed by GitHub
parent d50231b888
commit 831272a137
3 changed files with 107 additions and 151 deletions

View File

@@ -614,11 +614,11 @@ gam calendar <CalendarItem> deleteevent (id|eventid <EventID>)* (query|eventquer
gam calendar <CalendarItem> wipe gam calendar <CalendarItem> wipe
gam update cros <CrOSItem> (<CrOSAttributes>+)|(action deprovision_same_model_replace|deprovision_different_model_replace|deprovision_retiring_device|disable|reenable [acknowledge_device_touch_requirement]) gam update cros <CrOSItem> (<CrOSAttributes>+)|(action deprovision_same_model_replace|deprovision_different_model_replace|deprovision_retiring_device|disable|reenable [acknowledge_device_touch_requirement])
gam info cros <CrOSItem> [nolists] [listlimit <Number>] [start <Date>] [end <Date>] gam info cros <CrOSItem> [nolists] [listlimit <Number>]
[basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>] [basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>]
gam print cros [todrive] [query <QueryCrOS>] gam print cros [todrive] [query <QueryCrOS>]
[orderby <CrOSOrderByFieldName> [ascending|descending]] [nolists] [listlimit <Number>] [start <Date>] [end <Date>] [orderby <CrOSOrderByFieldName> [ascending|descending]] [nolists] [listlimit <Number>]
[basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>] [basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>]
gam <CrOSTypeEntity> print gam <CrOSTypeEntity> print
@@ -635,22 +635,9 @@ The full argument yields all column headers including two headers, recentUsers a
that repeat with two subvalues each, yielding a large number of columns that make the output hard to process. that repeat with two subvalues each, yielding a large number of columns that make the output hard to process.
The nolists argument suppresses these two headers; if you want these headers in a more manageable form use the following arguments. The nolists argument suppresses these two headers; if you want these headers in a more manageable form use the following arguments.
The listlimit <Number> argument limits the number of repetitions to <Number>. If <Number> equals zero, there is no limit. The listlimit <Number> argument limits the number of repetitions to <Number>. If <Number> equals zero, there is no limit.
The start <Date> and end <Date> arguments filter the time ranges.
If recentusers is specified as a field, each pair of values for recentUsers is put on a separate row with all of the other headers. If recentusers is specified as a field, each pair of values for recentUsers is put on a separate row with all of the other headers.
If timeranges is specified as a field, each pair of values for activeTimeRanges is put on a separate row with all of the other headers. If timeranges is specified as a field, each pair of values for activeTimeRanges is put on a separate row with all of the other headers.
gam print crosactivity [todrive] [query <QueryCrOS>]
[recentusers] [timeranges] [both] [listlimit <Number>] [start <Date>] [end <Date>] [delimiter <String>]
The basic column headers are: deviceId,annotatedAssetId,annotatedLocation,serialNumber,orgUnitPath.
If recentusers is specified, all of the recent users email addresses, separated by the delimiter <String>,
are put on a separate row, with header recentUsers.email, in addition to the basic headers.
If timeranges is specified, each pair of time range values, activeTimeRanges.date and activeTimeRanges.duration,
are put on a separate row with the basic headers.
The default is to include both recentusers and timeranges.
The listlimit <Number> argument limits the number of recent users and time ranges to <Number>. If <Number> equals zero, there is no limit.
The start <Date> and end <Date> arguments filter the time ranges.
gam update mobile <MobileItem> <MobileAttributes>+ gam update mobile <MobileItem> <MobileAttributes>+
gam delete mobile <MobileItem> gam delete mobile <MobileItem>
gam info mobile <MobileItem> gam info mobile <MobileItem>

View File

@@ -4909,7 +4909,7 @@ def addSmime(users):
myarg = sys.argv[i].lower() myarg = sys.argv[i].lower()
if myarg == u'file': if myarg == u'file':
smimefile = sys.argv[i+1] smimefile = sys.argv[i+1]
body[u'pkcs12'] = base64.urlsafe_b64encode(readFile(smimefile, mode=u'rb')) body[u'pkcs12'] = base64.urlsafe_b64encode(readFile(smimefile, mode =u'rb'))
i += 2 i += 2
elif myarg == u'password': elif myarg == u'password':
body[u'encryptedKeyPassword'] = sys.argv[i+1] body[u'encryptedKeyPassword'] = sys.argv[i+1]
@@ -8002,16 +8002,6 @@ def doGetResourceCalendarInfo():
continue continue
print u'%s: %s' % (key, value) print u'%s: %s' % (key, value)
def _filterTimeRanges(activeTimeRanges, startDate, endDate):
if startDate is None and endDate is None:
return activeTimeRanges
filteredTimeRanges = []
for timeRange in activeTimeRanges:
activityDate = datetime.datetime.strptime(timeRange[u'date'], YYYYMMDD_FORMAT)
if ((startDate is None) or (activityDate >= startDate)) and ((endDate is None) or (activityDate <= endDate)):
filteredTimeRanges.append(timeRange)
return filteredTimeRanges
def doGetCrosInfo(): def doGetCrosInfo():
cd = buildGAPIObject(u'directory') cd = buildGAPIObject(u'directory')
deviceId = sys.argv[3] deviceId = sys.argv[3]
@@ -8027,7 +8017,6 @@ def doGetCrosInfo():
projection = None projection = None
fieldsList = [] fieldsList = []
noLists = False noLists = False
startDate = endDate = None
listLimit = 0 listLimit = 0
i = 4 i = 4
while i < len(sys.argv): while i < len(sys.argv):
@@ -8035,12 +8024,6 @@ def doGetCrosInfo():
if myarg == u'nolists': if myarg == u'nolists':
noLists = True noLists = True
i += 1 i += 1
elif myarg in CROS_START_ARGUMENTS:
startDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg in CROS_END_ARGUMENTS:
endDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg == u'listlimit': elif myarg == u'listlimit':
listLimit = int(sys.argv[i+1]) listLimit = int(sys.argv[i+1])
i += 2 i += 2
@@ -8067,7 +8050,7 @@ def doGetCrosInfo():
for field in fieldNameList.lower().replace(u',', u' ').split(): for field in fieldNameList.lower().replace(u',', u' ').split():
if field in CROS_ARGUMENT_TO_PROPERTY_MAP: if field in CROS_ARGUMENT_TO_PROPERTY_MAP:
fieldsList.extend(CROS_ARGUMENT_TO_PROPERTY_MAP[field]) fieldsList.extend(CROS_ARGUMENT_TO_PROPERTY_MAP[field])
if field in CROS_ACTIVE_TIME_RANGES_ARGUMENTS+CROS_RECENT_USERS_ARGUMENTS: if field in [u'recentusers', u'timeranges', u'activetimeranges']:
projection = u'FULL' projection = u'FULL'
noLists = False noLists = False
else: else:
@@ -8081,10 +8064,9 @@ def doGetCrosInfo():
fields = u','.join(set(fieldsList)).replace(u'.', u'/') fields = u','.join(set(fieldsList)).replace(u'.', u'/')
else: else:
fields = None fields = None
i = 0 i = 1
device_count = len(devices) device_count = len(devices)
for deviceId in devices: for deviceId in devices:
i += 1
cros = callGAPI(cd.chromeosdevices(), u'get', customerId=GC_Values[GC_CUSTOMER_ID], cros = callGAPI(cd.chromeosdevices(), u'get', customerId=GC_Values[GC_CUSTOMER_ID],
deviceId=deviceId, projection=projection, fields=fields) deviceId=deviceId, projection=projection, fields=fields)
print u'CrOS Device: {0} ({1} of {2})'.format(deviceId, i, device_count) print u'CrOS Device: {0} ({1} of {2})'.format(deviceId, i, device_count)
@@ -8094,21 +8076,22 @@ def doGetCrosInfo():
if up in cros: if up in cros:
print u' {0}: {1}'.format(up, cros[up]) print u' {0}: {1}'.format(up, cros[up])
if not noLists: if not noLists:
activeTimeRanges = _filterTimeRanges(cros.get(u'activeTimeRanges', []), startDate, endDate) activeTimeRanges = cros.get(u'activeTimeRanges', [])
lenATR = len(activeTimeRanges) lenATR = len(activeTimeRanges)
if lenATR: if lenATR:
print u' activeTimeRanges' print u' activeTimeRanges'
for activeTimeRange in activeTimeRanges[:min(lenATR, listLimit or lenATR)]: for i in xrange(min(listLimit, lenATR) if listLimit else lenATR):
print u' date: {0}'.format(activeTimeRange[u'date']) print u' date: {0}'.format(activeTimeRanges[i][u'date'])
print u' activeTime: {0}'.format(str(activeTimeRange[u'activeTime'])) print u' activeTime: {0}'.format(str(activeTimeRanges[i][u'activeTime']))
print u' duration: {0}'.format(utils.formatMilliSeconds(activeTimeRange[u'activeTime'])) print u' duration: {0}'.format(utils.formatMilliSeconds(activeTimeRanges[i][u'activeTime']))
recentUsers = cros.get(u'recentUsers', []) recentUsers = cros.get(u'recentUsers', [])
lenRU = len(recentUsers) lenRU = len(recentUsers)
if lenRU: if lenRU:
print u' recentUsers' print u' recentUsers'
for recentUser in recentUsers[:min(lenRU, listLimit or lenRU)]: for i in xrange(min(listLimit, lenRU) if listLimit else lenRU):
print u' type: {0}'.format(recentUser[u'type']) print u' type: {0}'.format(recentUsers[i][u'type'])
print u' email: {0}'.format(recentUser.get(u'email', [u'Unknown', u'UnmanagedUser'][recentUser[u'type'] == u'USER_TYPE_UNMANAGED'])) print u' email: {0}'.format(recentUsers[i].get(u'email', u''))
i += 1
def doGetMobileInfo(): def doGetMobileInfo():
cd = buildGAPIObject(u'directory') cd = buildGAPIObject(u'directory')
@@ -9489,12 +9472,10 @@ def doPrintMobileDevices():
def doPrintCrosActivity(): def doPrintCrosActivity():
cd = buildGAPIObject(u'directory') cd = buildGAPIObject(u'directory')
todrive = False todrive = False
titles = [u'deviceId', u'annotatedAssetId', u'annotatedLocation', u'serialNumber', u'orgUnitPath'] titles = [u'deviceId', u'annotatedAssetId', u'serialNumber', u'orgUnitPath']
csvRows = [] csvRows = []
device_fields = [u'deviceId', u'annotatedAssetId', u'annotatedLocation', u'serialNumber', u'orgUnitPath'] device_fields = [u'annotatedAssetId', u'deviceId', u'orgUnitPath', u'serialNumber']
startDate = endDate = None oldest_date = None
listLimit = 0
delimiter = u','
query = None query = None
i = 3 i = 3
while i < len(sys.argv): while i < len(sys.argv):
@@ -9505,67 +9486,66 @@ def doPrintCrosActivity():
elif myarg == u'todrive': elif myarg == u'todrive':
todrive = True todrive = True
i += 1 i += 1
elif myarg in CROS_ACTIVE_TIME_RANGES_ARGUMENTS: elif myarg == u'times':
device_fields.append(u'activeTimeRanges') device_fields.append(u'activeTimeRanges')
i += 1 i += 1
elif myarg in CROS_RECENT_USERS_ARGUMENTS: elif myarg == u'users':
device_fields.append(u'recentUsers') device_fields.append(u'recentUsers')
i += 1 i += 1
elif myarg == u'both': elif myarg == u'both':
device_fields.extend([u'recentUsers', u'activeTimeRanges']) device_fields.append(u'recentUsers')
device_fields.append(u'activeTimeRanges')
i += 1 i += 1
elif myarg in CROS_START_ARGUMENTS: elif myarg == u'oldestdate':
startDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d') oldest_date = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg in CROS_END_ARGUMENTS:
endDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg == u'listlimit':
listLimit = int(sys.argv[i+1])
i += 2
elif myarg == u'delimiter':
delimiter = sys.argv[i+1]
i += 2 i += 2
else: else:
print u'ERROR: %s is not a valid argument for "gam print crosactivity"' % sys.argv[i] print u'ERROR: %s is not a valid argument for "gam print crosactivity"' % sys.argv[i]
sys.exit(2) sys.exit(2)
if u'recentUsers' not in device_fields and u'activeTimeRanges' not in device_fields: if u'recentUsers' not in device_fields and u'activeTimeRanges' not in device_fields:
device_fields.extend([u'recentUsers', u'activeTimeRanges']) device_fields.append(u'recentUsers')
device_fields.append(u'activeTimeRanges')
if u'recentUsers' in device_fields: if u'recentUsers' in device_fields:
titles.append(u'recentUsers.email') titles.append(u'recent_users')
if u'activeTimeRanges' in device_fields: if u'activeTimeRanges' in device_fields:
titles.extend([u'activeTimeRanges.date', u'activeTimeRanges.duration']) titles.append(u'activity_date')
titles.append(u'active_minutes')
fields = u'chromeosdevices(%s),nextPageToken' % u','.join(device_fields) fields = u'chromeosdevices(%s),nextPageToken' % u','.join(device_fields)
sys.stderr.write(u'Retrieving All Chrome OS Devices for organization (may take some time for large accounts)...\n') sys.stderr.write(u'Retrieving All Chrome OS Devices for organization (may take some time for large accounts)...\n')
page_message = u'Got %%num_items%% Chrome devices...\n' page_message = u'Got %%num_items%% Chrome devices...\n'
all_cros = callGAPIpages(cd.chromeosdevices(), u'list', u'chromeosdevices', page_message=page_message, all_cros = callGAPIpages(cd.chromeosdevices(), u'list', u'chromeosdevices', page_message=page_message,
query=query, customerId=GC_Values[GC_CUSTOMER_ID], projection=u'FULL', query=query, customerId=GC_Values[GC_CUSTOMER_ID], projection=u'FULL',
fields=fields, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS]) fields=fields, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS])
for cros in all_cros: if all_cros:
row = {} for cros in all_cros:
for attrib in cros: if u'activeTimeRanges' in cros:
if attrib not in [u'recentUsers', u'activeTimeRanges']: for time_range in cros[u'activeTimeRanges']:
row[attrib] = cros[attrib] row_date = time_range[u'date']
if u'activeTimeRanges' in cros: if oldest_date:
activeTimeRanges = _filterTimeRanges(cros[u'activeTimeRanges'], startDate, endDate) row_time = datetime.datetime.strptime(row_date, u'%Y-%m-%d')
lenATR = len(activeTimeRanges) if row_time < oldest_date:
for activeTimeRange in activeTimeRanges[:min(lenATR, listLimit or lenATR)]: continue
new_row = row.copy() row = {u'activity_date': row_date, u'active_minutes': time_range[u'activeTime']/1000/60}
new_row[u'activeTimeRanges.date'] = activeTimeRange[u'date'] for attrib in cros:
new_row[u'activeTimeRanges.duration'] = utils.formatMilliSeconds(activeTimeRange[u'activeTime']) if attrib in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']:
csvRows.append(new_row) continue
if u'recentUsers' in cros: row[attrib] = cros[attrib]
recentUsers = [] csvRows.append(row)
for recentUser in cros[u'recentUsers']: if u'recentUsers' in cros:
if u'email' in recentUser: recentusers = []
recentUsers.append(recentUser[u'email']) for recentuser in cros[u'recentUsers']:
elif recentUser[u'type'] == u'USER_TYPE_UNMANAGED': if u'email' in recentuser:
recentUsers.append(u'UnmanagedUser') recentusers.append(recentuser[u'email'])
else: elif recentuser[u'type'] == u'USER_TYPE_UNMANAGED':
recentUsers.append(u'Unknown') recentusers.append(u'UnmanagedUser')
lenRU = len(recentUsers) else:
row[u'recentUsers.email'] = delimiter.join(recentUsers[:min(lenRU, listLimit or lenRU)]) recentusers.append(u'Unknown')
csvRows.append(row) row = {u'recent_users': u','.join(recentusers)}
for attrib in cros:
if attrib in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']:
continue
row[attrib] = cros[attrib]
csvRows.append(row)
writeCSVfile(csvRows, titles, u'CrOS Activity', todrive) writeCSVfile(csvRows, titles, u'CrOS Activity', todrive)
def doPrintCrosDevices(): def doPrintCrosDevices():
@@ -9579,9 +9559,8 @@ def doPrintCrosDevices():
sortHeaders = False sortHeaders = False
query = projection = orderBy = sortOrder = None query = projection = orderBy = sortOrder = None
noLists = False noLists = False
selectActiveTimeRanges = selectRecentUsers = False
startDate = endDate = None
listLimit = 0 listLimit = 0
selectActiveTimeRanges = selectRecentUsers = None
i = 3 i = 3
while i < len(sys.argv): while i < len(sys.argv):
myarg = sys.argv[i].lower().replace(u'_', u'') myarg = sys.argv[i].lower().replace(u'_', u'')
@@ -9593,28 +9572,22 @@ def doPrintCrosDevices():
i += 1 i += 1
elif myarg == u'nolists': elif myarg == u'nolists':
noLists = True noLists = True
selectActiveTimeRanges = selectRecentUsers = False selectActiveTimeRanges = selectRecentUsers = None
i += 1 i += 1
elif myarg in CROS_ACTIVE_TIME_RANGES_ARGUMENTS: elif myarg == u'recentusers':
projection = u'FULL' projection = u'FULL'
selectActiveTimeRanges = True selectRecentUsers = u'recentUsers'
noLists = False noLists = False
if fieldsList: if fieldsList:
fieldsList.append(u'activeTimeRanges') fieldsList.append(selectRecentUsers)
i += 1 i += 1
elif myarg in CROS_RECENT_USERS_ARGUMENTS: elif myarg in [u'timeranges', u'activetimeranges']:
projection = u'FULL' projection = u'FULL'
selectRecentUsers = True selectActiveTimeRanges = u'activeTimeRanges'
noLists = False noLists = False
if fieldsList: if fieldsList:
fieldsList.append(u'recentUsers') fieldsList.append(selectActiveTimeRanges)
i += 1 i += 1
elif myarg in CROS_START_ARGUMENTS:
startDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg in CROS_END_ARGUMENTS:
endDate = datetime.datetime.strptime(sys.argv[i+1], u'%Y-%m-%d')
i += 2
elif myarg == u'listlimit': elif myarg == u'listlimit':
listLimit = int(sys.argv[i+1]) listLimit = int(sys.argv[i+1])
i += 2 i += 2
@@ -9663,13 +9636,13 @@ def doPrintCrosDevices():
for field in fieldNameList.lower().replace(u',', u' ').split(): for field in fieldNameList.lower().replace(u',', u' ').split():
if field in CROS_ARGUMENT_TO_PROPERTY_MAP: if field in CROS_ARGUMENT_TO_PROPERTY_MAP:
addFieldToCSVfile(field, CROS_ARGUMENT_TO_PROPERTY_MAP, fieldsList, fieldsTitles, titles) addFieldToCSVfile(field, CROS_ARGUMENT_TO_PROPERTY_MAP, fieldsList, fieldsTitles, titles)
if field in CROS_RECENT_USERS_ARGUMENTS: if field == u'recentusers':
projection = u'FULL' projection = u'FULL'
selectRecentUsers = True selectRecentUsers = u'recentUsers'
noLists = False noLists = False
elif field in CROS_ACTIVE_TIME_RANGES_ARGUMENTS: elif field in [u'timeranges', u'activetimeranges']:
projection = u'FULL' projection = u'FULL'
selectActiveTimeRanges = True selectActiveTimeRanges = u'activeTimeRanges'
noLists = False noLists = False
else: else:
print u'ERROR: %s is not a valid argument for "gam print cros fields"' % field print u'ERROR: %s is not a valid argument for "gam print cros fields"' % field
@@ -9687,43 +9660,46 @@ def doPrintCrosDevices():
all_cros = callGAPIpages(cd.chromeosdevices(), u'list', u'chromeosdevices', page_message=page_message, all_cros = callGAPIpages(cd.chromeosdevices(), u'list', u'chromeosdevices', page_message=page_message,
query=query, customerId=GC_Values[GC_CUSTOMER_ID], projection=projection, query=query, customerId=GC_Values[GC_CUSTOMER_ID], projection=projection,
orderBy=orderBy, sortOrder=sortOrder, fields=fields, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS]) orderBy=orderBy, sortOrder=sortOrder, fields=fields, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS])
if (not noLists) and (not selectActiveTimeRanges) and (not selectRecentUsers): if all_cros:
for cros in all_cros: if (not noLists) and (not selectActiveTimeRanges) and (not selectRecentUsers):
if u'notes' in cros: for cros in all_cros:
cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n') if u'notes' in cros:
addRowTitlesToCSVfile(flatten_json(cros, listLimit=listLimit), csvRows, titles) cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n')
else: addRowTitlesToCSVfile(flatten_json(cros, listLimit=listLimit), csvRows, titles)
if not noLists: else:
if selectActiveTimeRanges: if not noLists:
titles.extend([u'activeTimeRanges.date', u'activeTimeRanges.activeTime', u'activeTimeRanges.duration']) if selectActiveTimeRanges:
if selectRecentUsers: for attrib in [u'activeTimeRanges.activeTime', u'activeTimeRanges.date']:
titles.extend([u'recentUsers.email', u'recentUsers.type']) titles.append(attrib)
for cros in all_cros: if selectRecentUsers:
if u'notes' in cros: for attrib in [u'recentUsers.email', u'recentUsers.type']:
cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n') titles.append(attrib)
row = {} for cros in all_cros:
for attrib in cros: if u'notes' in cros:
if attrib not in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']: cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n')
row = {}
for attrib in cros:
if attrib in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']:
continue
if attrib not in titles: if attrib not in titles:
titles.append(attrib) titles.append(attrib)
row[attrib] = cros[attrib] row[attrib] = cros[attrib]
activeTimeRanges = _filterTimeRanges(cros.get(u'activeTimeRanges', []), startDate, endDate) if selectActiveTimeRanges else [] activeTimeRanges = cros.get(selectActiveTimeRanges, []) if selectActiveTimeRanges else []
recentUsers = cros.get(u'recentUsers', []) if selectRecentUsers else [] recentUsers = cros.get(selectRecentUsers, []) if selectRecentUsers else []
if noLists or (not activeTimeRanges and not recentUsers): if noLists or (not activeTimeRanges and not recentUsers):
csvRows.append(row) csvRows.append(row)
else: else:
lenATR = len(activeTimeRanges) lenATR = len(activeTimeRanges)
lenRU = len(recentUsers) lenRU = len(recentUsers)
for i in xrange(min(listLimit, max(lenATR, lenRU)) if listLimit else max(lenATR, lenRU)): for i in xrange(min(listLimit, max(lenATR, lenRU)) if listLimit else max(lenATR, lenRU)):
new_row = row.copy() new_row = row.copy()
if i < lenATR: if i < lenATR:
new_row[u'activeTimeRanges.date'] = activeTimeRanges[i][u'date'] new_row[u'activeTimeRanges.activeTime'] = str(activeTimeRanges[i][u'activeTime'])
new_row[u'activeTimeRanges.activeTime'] = str(activeTimeRanges[i][u'activeTime']) new_row[u'activeTimeRanges.date'] = activeTimeRanges[i][u'date']
new_row[u'activeTimeRanges.duration'] = utils.formatMilliSeconds(activeTimeRanges[i][u'activeTime']) if i < lenRU:
if i < lenRU: new_row[u'recentUsers.email'] = recentUsers[i].get(u'email', u'')
new_row[u'recentUsers.email'] = recentUsers[i].get(u'email', [u'Unknown', u'UnmanagedUser'][recentUsers[i][u'type'] == u'USER_TYPE_UNMANAGED']) new_row[u'recentUsers.type'] = recentUsers[i][u'type']
new_row[u'recentUsers.type'] = recentUsers[i][u'type'] csvRows.append(new_row)
csvRows.append(new_row)
if sortHeaders: if sortHeaders:
sortCSVTitles([u'deviceId',], titles) sortCSVTitles([u'deviceId',], titles)
writeCSVfile(csvRows, titles, u'CrOS', todrive) writeCSVfile(csvRows, titles, u'CrOS', todrive)

View File

@@ -442,9 +442,7 @@ CROS_ARGUMENT_TO_PROPERTY_MAP = {
u'supportenddate': [u'supportEndDate',], u'supportenddate': [u'supportEndDate',],
u'tag': [u'annotatedAssetId',], u'tag': [u'annotatedAssetId',],
u'timeranges': [u'activeTimeRanges.activeTime', u'activeTimeRanges.date'], u'timeranges': [u'activeTimeRanges.activeTime', u'activeTimeRanges.date'],
u'times': [u'activeTimeRanges.activeTime', u'activeTimeRanges.date'],
u'user': [u'annotatedUser',], u'user': [u'annotatedUser',],
u'users': [u'recentUsers.email', u'recentUsers.type'],
u'willautorenew': [u'willAutoRenew',], u'willautorenew': [u'willAutoRenew',],
} }
@@ -473,11 +471,6 @@ CROS_SCALAR_PROPERTY_PRINT_ORDER = [
u'willAutoRenew', u'willAutoRenew',
] ]
CROS_RECENT_USERS_ARGUMENTS = [u'recentusers', u'users']
CROS_ACTIVE_TIME_RANGES_ARGUMENTS = [u'timeranges', u'activetimeranges', u'times']
CROS_START_ARGUMENTS = [u'start', u'startdate', u'oldestdate']
CROS_END_ARGUMENTS = [u'end', u'enddate']
# #
# Global variables # Global variables
# #