mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 06:33:34 +00:00
Handle newlines in CrOS notes field; fix print tokens to show clientId (#308)
* Handle newlines in CrOS notes field * Fix gam print tokens to show clientId * Generalize print.show tokens
This commit is contained in:
18
src/gam.py
18
src/gam.py
@ -7198,7 +7198,7 @@ def doUpdateCros():
|
|||||||
body[u'annotatedLocation'] = sys.argv[i + 1]
|
body[u'annotatedLocation'] = sys.argv[i + 1]
|
||||||
i += 2
|
i += 2
|
||||||
elif sys.argv[i].lower() == u'notes':
|
elif sys.argv[i].lower() == u'notes':
|
||||||
body[u'notes'] = sys.argv[i + 1]
|
body[u'notes'] = sys.argv[i + 1].replace(u'\\n', u'\n')
|
||||||
i += 2
|
i += 2
|
||||||
elif sys.argv[i].lower() == u'action':
|
elif sys.argv[i].lower() == u'action':
|
||||||
update_device = False
|
update_device = False
|
||||||
@ -7827,6 +7827,8 @@ def doGetCrosInfo():
|
|||||||
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}'.format(deviceId)
|
print u'CrOS Device: {0}'.format(deviceId)
|
||||||
|
if u'notes' in cros:
|
||||||
|
cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n')
|
||||||
for up in CROS_SCALAR_PROPERTY_PRINT_ORDER:
|
for up in CROS_SCALAR_PROPERTY_PRINT_ORDER:
|
||||||
if up in cros:
|
if up in cros:
|
||||||
print u' {0}: {1}'.format(up, cros[up])
|
print u' {0}: {1}'.format(up, cros[up])
|
||||||
@ -8195,8 +8197,9 @@ def doDelTokens(users):
|
|||||||
def printShowTokens(i, entityType, users, csvFormat):
|
def printShowTokens(i, entityType, users, csvFormat):
|
||||||
def _showToken(token):
|
def _showToken(token):
|
||||||
print u' Client ID: %s' % token[u'clientId']
|
print u' Client ID: %s' % token[u'clientId']
|
||||||
for item in [u'displayText', u'anonymous', u'nativeApp', u'userKey']:
|
for item in token:
|
||||||
print convertUTF8(u' %s: %s' % (item, token.get(item, u'')))
|
if item not in [u'clientId', u'scopes']:
|
||||||
|
print convertUTF8(u' %s: %s' % (item, token.get(item, u'')))
|
||||||
item = u'scopes'
|
item = u'scopes'
|
||||||
print u' %s:' % item
|
print u' %s:' % item
|
||||||
for it in token.get(item, []):
|
for it in token.get(item, []):
|
||||||
@ -8253,8 +8256,9 @@ def printShowTokens(i, entityType, users, csvFormat):
|
|||||||
continue
|
continue
|
||||||
for token in results:
|
for token in results:
|
||||||
row = {u'user': user, u'scopes': u' '.join(token.get(u'scopes', []))}
|
row = {u'user': user, u'scopes': u' '.join(token.get(u'scopes', []))}
|
||||||
for item in [u'displayText', u'anonymous', u'nativeApp', u'userKey']:
|
for item in token:
|
||||||
row[item] = token.get(item, u'')
|
if item not in [u'scopes']:
|
||||||
|
row[item] = token.get(item, u'')
|
||||||
csvRows.append(row)
|
csvRows.append(row)
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
pass
|
pass
|
||||||
@ -9273,6 +9277,8 @@ def doPrintCrosDevices():
|
|||||||
if all_cros:
|
if all_cros:
|
||||||
if (not noLists) and (not selectActiveTimeRanges) and (not selectRecentUsers):
|
if (not noLists) and (not selectActiveTimeRanges) and (not selectRecentUsers):
|
||||||
for cros in all_cros:
|
for cros in all_cros:
|
||||||
|
if u'notes' in cros:
|
||||||
|
cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n')
|
||||||
addRowTitlesToCSVfile(flatten_json(cros, listLimit=listLimit), csvRows, titles)
|
addRowTitlesToCSVfile(flatten_json(cros, listLimit=listLimit), csvRows, titles)
|
||||||
else:
|
else:
|
||||||
if not noLists:
|
if not noLists:
|
||||||
@ -9283,6 +9289,8 @@ def doPrintCrosDevices():
|
|||||||
for attrib in [u'recentUsers.email', u'recentUsers.type']:
|
for attrib in [u'recentUsers.email', u'recentUsers.type']:
|
||||||
titles.append(attrib)
|
titles.append(attrib)
|
||||||
for cros in all_cros:
|
for cros in all_cros:
|
||||||
|
if u'notes' in cros:
|
||||||
|
cros[u'notes'] = cros[u'notes'].replace(u'\n', u'\\n')
|
||||||
row = {}
|
row = {}
|
||||||
for attrib in cros:
|
for attrib in cros:
|
||||||
if attrib in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']:
|
if attrib in [u'kind', u'etag', u'recentUsers', u'activeTimeRanges']:
|
||||||
|
Reference in New Issue
Block a user