mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Update print mobile (#524)
This commit is contained in:
@@ -305,6 +305,48 @@ Named items
|
|||||||
role|
|
role|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
<MobileFieldName> ::=
|
||||||
|
adbstatus|
|
||||||
|
applications|
|
||||||
|
basebandversion|
|
||||||
|
bootloaderversion|
|
||||||
|
brand|
|
||||||
|
buildnumber|
|
||||||
|
defaultlanguage|
|
||||||
|
developeroptionsstatus|
|
||||||
|
devicecompromisedstatus|
|
||||||
|
deviceid|
|
||||||
|
devicepasswordstatus|
|
||||||
|
email|
|
||||||
|
encryptionstatus|
|
||||||
|
firstsync|
|
||||||
|
hardware|
|
||||||
|
hardwareid|
|
||||||
|
imei|
|
||||||
|
kernelversion|
|
||||||
|
lastsync|
|
||||||
|
managedaccountisonownerprofile|
|
||||||
|
manufacturer|
|
||||||
|
meid|
|
||||||
|
model|
|
||||||
|
name|
|
||||||
|
networkoperator|
|
||||||
|
os|
|
||||||
|
otheraccountsinfo|
|
||||||
|
privilege|
|
||||||
|
releaseversion|
|
||||||
|
resourceid|
|
||||||
|
securitypatchlevel|
|
||||||
|
serialnumber|
|
||||||
|
status|
|
||||||
|
supportsworkprofile|
|
||||||
|
type|
|
||||||
|
unknownsourcesstatus|
|
||||||
|
useragent|
|
||||||
|
wifimacaddress
|
||||||
|
|
||||||
|
<MobileFieldNameList> ::= "<MobileFieldName>(,<MobileFieldName>)*"
|
||||||
|
|
||||||
<MobileOrderByFieldName> ::=
|
<MobileOrderByFieldName> ::=
|
||||||
deviceid|email|lastsync|model|name|os|status|type
|
deviceid|email|lastsync|model|name|os|status|type
|
||||||
|
|
||||||
@@ -659,6 +701,7 @@ gam update mobile <MobileItem> action <MobileAction>
|
|||||||
gam delete mobile <MobileItem>
|
gam delete mobile <MobileItem>
|
||||||
gam info mobile <MobileItem>
|
gam info mobile <MobileItem>
|
||||||
gam print mobile [todrive] [query <QueryMobile>] [basic|full] [orderby <MobileOrderByFieldName> [ascending|descending]]
|
gam print mobile [todrive] [query <QueryMobile>] [basic|full] [orderby <MobileOrderByFieldName> [ascending|descending]]
|
||||||
|
fields <MobileFieldNameList>] [delimiter <String>] [appslimit <Number>] [listlimit <Number>]
|
||||||
|
|
||||||
gam create group <EmailAddress> <GroupAttributes>*
|
gam create group <EmailAddress> <GroupAttributes>*
|
||||||
gam update group <GroupItem> [admincreated <Boolean>] [email <EmailAddress>] <GroupAttributes>*
|
gam update group <GroupItem> [admincreated <Boolean>] [email <EmailAddress>] <GroupAttributes>*
|
||||||
|
|||||||
74
src/gam.py
74
src/gam.py
@@ -9660,20 +9660,28 @@ def doPrintMobileDevices():
|
|||||||
titles = []
|
titles = []
|
||||||
csvRows = []
|
csvRows = []
|
||||||
fields = None
|
fields = None
|
||||||
include_apps = True
|
|
||||||
query = projection = orderBy = sortOrder = None
|
query = projection = orderBy = sortOrder = None
|
||||||
|
delimiter = u' '
|
||||||
|
listLimit = 1
|
||||||
|
appsLimit = -1
|
||||||
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'')
|
||||||
if myarg == u'query':
|
if myarg == u'todrive':
|
||||||
query = sys.argv[i+1]
|
|
||||||
i += 2
|
|
||||||
elif myarg == u'noapps':
|
|
||||||
include_apps = False
|
|
||||||
i += 1
|
|
||||||
elif myarg == u'todrive':
|
|
||||||
todrive = True
|
todrive = True
|
||||||
i += 1
|
i += 1
|
||||||
|
elif myarg == u'query':
|
||||||
|
query = sys.argv[i+1]
|
||||||
|
i += 2
|
||||||
|
elif myarg == u'delimiter':
|
||||||
|
delimiter = sys.argv[i+1]
|
||||||
|
i += 2
|
||||||
|
elif myarg == u'listlimit':
|
||||||
|
listLimit = int(sys.argv[i+1])
|
||||||
|
i += 2
|
||||||
|
elif myarg == u'appslimit':
|
||||||
|
appsLimit = int(sys.argv[i+1])
|
||||||
|
i += 2
|
||||||
elif myarg == u'fields':
|
elif myarg == u'fields':
|
||||||
fields = u'nextPageToken,mobiledevices(%s)' % sys.argv[i+1]
|
fields = u'nextPageToken,mobiledevices(%s)' % sys.argv[i+1]
|
||||||
i += 2
|
i += 2
|
||||||
@@ -9703,30 +9711,44 @@ def doPrintMobileDevices():
|
|||||||
customerId=GC_Values[GC_CUSTOMER_ID], query=query, projection=projection, fields=fields,
|
customerId=GC_Values[GC_CUSTOMER_ID], query=query, projection=projection, fields=fields,
|
||||||
orderBy=orderBy, sortOrder=sortOrder, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS])
|
orderBy=orderBy, sortOrder=sortOrder, maxResults=GC_Values[GC_DEVICE_MAX_RESULTS])
|
||||||
for mobile in all_mobile:
|
for mobile in all_mobile:
|
||||||
mobiledevice = {}
|
row = {}
|
||||||
for attrib in mobile:
|
for attrib in mobile:
|
||||||
if attrib in [u'kind', u'etag']:
|
if attrib in [u'kind', u'etag']:
|
||||||
continue
|
continue
|
||||||
|
if attrib in [u'name', u'email', u'otherAccountsInfo']:
|
||||||
if attrib not in titles:
|
if attrib not in titles:
|
||||||
titles.append(attrib)
|
titles.append(attrib)
|
||||||
if attrib in [u'name', u'email']:
|
if listLimit:
|
||||||
if mobile[attrib]:
|
row[attrib] = delimiter.join(mobile[attrib][0:listLimit])
|
||||||
mobiledevice[attrib] = mobile[attrib][0]
|
|
||||||
elif attrib == u'applications':
|
|
||||||
if not include_apps:
|
|
||||||
continue
|
|
||||||
applications = []
|
|
||||||
for app in mobile[u'applications']:
|
|
||||||
app_details = []
|
|
||||||
app_details.append(app.get(u'displayName', u'<missing>'))
|
|
||||||
app_details.append(app.get(u'packageName', u'<missing>'))
|
|
||||||
app_details.append(app.get(u'versionName', u'<missing>'))
|
|
||||||
app_details.append(unicode(app.get(u'versionCode', u'<missing>')))
|
|
||||||
applications.append(u' - '.join(app_details))
|
|
||||||
mobiledevice[u'applications'] = u'\n'.join(applications)
|
|
||||||
else:
|
else:
|
||||||
mobiledevice[attrib] = mobile[attrib]
|
row[attrib] = delimiter.join(mobile[attrib])
|
||||||
csvRows.append(mobiledevice)
|
elif attrib == u'applications':
|
||||||
|
if appsLimit >= 0:
|
||||||
|
if attrib not in titles:
|
||||||
|
titles.append(attrib)
|
||||||
|
applications = []
|
||||||
|
j = 0
|
||||||
|
for app in mobile[attrib]:
|
||||||
|
j += 1
|
||||||
|
if appsLimit and (j > appsLimit):
|
||||||
|
break
|
||||||
|
appDetails = []
|
||||||
|
for field in [u'displayName', u'packageName', u'versionName']:
|
||||||
|
appDetails.append(app.get(field, u'<None>'))
|
||||||
|
appDetails.append(unicode(app.get(u'versionCode', u'<None>')))
|
||||||
|
permissions = app.get(u'permission', [])
|
||||||
|
if permissions:
|
||||||
|
appDetails.append(u'/'.join(permissions))
|
||||||
|
else:
|
||||||
|
appDetails.append(u'<None>')
|
||||||
|
applications.append(u'-'.join(appDetails))
|
||||||
|
row[attrib] = delimiter.join(applications)
|
||||||
|
else:
|
||||||
|
if attrib not in titles:
|
||||||
|
titles.append(attrib)
|
||||||
|
row[attrib] = mobile[attrib]
|
||||||
|
csvRows.append(row)
|
||||||
|
sortCSVTitles([u'resourceId', u'deviceId', u'serialNumber', u'name', u'email', u'status'], titles)
|
||||||
writeCSVfile(csvRows, titles, u'Mobile', todrive)
|
writeCSVfile(csvRows, titles, u'Mobile', todrive)
|
||||||
|
|
||||||
def doPrintCrosActivity():
|
def doPrintCrosActivity():
|
||||||
|
|||||||
Reference in New Issue
Block a user