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]
|
||||
i += 2
|
||||
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
|
||||
elif sys.argv[i].lower() == u'action':
|
||||
update_device = False
|
||||
@ -7827,6 +7827,8 @@ def doGetCrosInfo():
|
||||
cros = callGAPI(cd.chromeosdevices(), u'get', customerId=GC_Values[GC_CUSTOMER_ID],
|
||||
deviceId=deviceId, projection=projection, fields=fields)
|
||||
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:
|
||||
if up in cros:
|
||||
print u' {0}: {1}'.format(up, cros[up])
|
||||
@ -8195,8 +8197,9 @@ def doDelTokens(users):
|
||||
def printShowTokens(i, entityType, users, csvFormat):
|
||||
def _showToken(token):
|
||||
print u' Client ID: %s' % token[u'clientId']
|
||||
for item in [u'displayText', u'anonymous', u'nativeApp', u'userKey']:
|
||||
print convertUTF8(u' %s: %s' % (item, token.get(item, u'')))
|
||||
for item in token:
|
||||
if item not in [u'clientId', u'scopes']:
|
||||
print convertUTF8(u' %s: %s' % (item, token.get(item, u'')))
|
||||
item = u'scopes'
|
||||
print u' %s:' % item
|
||||
for it in token.get(item, []):
|
||||
@ -8253,8 +8256,9 @@ def printShowTokens(i, entityType, users, csvFormat):
|
||||
continue
|
||||
for token in results:
|
||||
row = {u'user': user, u'scopes': u' '.join(token.get(u'scopes', []))}
|
||||
for item in [u'displayText', u'anonymous', u'nativeApp', u'userKey']:
|
||||
row[item] = token.get(item, u'')
|
||||
for item in token:
|
||||
if item not in [u'scopes']:
|
||||
row[item] = token.get(item, u'')
|
||||
csvRows.append(row)
|
||||
except googleapiclient.errors.HttpError:
|
||||
pass
|
||||
@ -9273,6 +9277,8 @@ def doPrintCrosDevices():
|
||||
if all_cros:
|
||||
if (not noLists) and (not selectActiveTimeRanges) and (not selectRecentUsers):
|
||||
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)
|
||||
else:
|
||||
if not noLists:
|
||||
@ -9283,6 +9289,8 @@ def doPrintCrosDevices():
|
||||
for attrib in [u'recentUsers.email', u'recentUsers.type']:
|
||||
titles.append(attrib)
|
||||
for cros in all_cros:
|
||||
if u'notes' in cros:
|
||||
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']:
|
||||
|
Reference in New Issue
Block a user