Skip to content

Commit

Permalink
GAM 5.09
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed May 12, 2020
1 parent 8eb72ae commit d46dd46
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ script:
- if [ "$e2e" = true ]; then $gam print cros allfields nolists; fi
- if [ "$e2e" = true ]; then $gam report usageparameters customer; fi
- if [ "$e2e" = true ]; then $gam report usage customer parameters gmail:num_emails_sent,accounts:num_1day_logins; fi
- if [ "$e2e" = true ]; then $gam report customer date -5d todrive; fi
- if [ "$e2e" = true ]; then $gam report users date -5d fields accounts:is_less_secure_apps_access_allowed,gmail:last_imap_time,gmail:last_pop_time filters "accounts:last_login_time>2019-01-01T00:00:00.000Z" todrive; fi
- if [ "$e2e" = true ]; then $gam report customer todrive; fi
- if [ "$e2e" = true ]; then $gam report users fields accounts:is_less_secure_apps_access_allowed,gmail:last_imap_time,gmail:last_pop_time filters "accounts:last_login_time>2019-01-01T00:00:00.000Z" todrive; fi
- if [ "$e2e" = true ]; then $gam report admin start -3d todrive; fi
- if ([ "$e2e" = true ] && [[ "$TRAVIS_JOB_NAME" != *"Testing" ]]); then
for gamfile in gam-$GAMVERSION-*; do
Expand Down
54 changes: 28 additions & 26 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _gamLatestVersionNotAvailable():
controlflow.system_error_exit(
4, 'GAM Latest Version information not available')

current_version = gam_version
current_version = GAM_VERSION
now_time = int(time.time())
if forceCheck:
check_url = GAM_ALL_RELEASES # includes pre-releases
Expand Down Expand Up @@ -709,15 +709,15 @@ def doGAMVersion(checkForArgs=True):
else:
controlflow.invalid_argument_exit(sys.argv[i], 'gam version')
if simple:
sys.stdout.write(gam_version)
sys.stdout.write(GAM_VERSION)
return
pyversion = platform.python_version()
cpu_bits = struct.calcsize('P') * 8
api_client_ver = pkg_resources.get_distribution(
'google-api-python-client').version
print(
(f'GAM {gam_version} - {GAM_URL} - {GM_Globals[GM_GAM_TYPE]}\n'
f'{gam_author}\n'
(f'GAM {GAM_VERSION} - {GAM_URL} - {GM_Globals[GM_GAM_TYPE]}\n'
f'{GAM_AUTHOR}\n'
f'Python {pyversion} {cpu_bits}-bit {sys.version_info.releaselevel}\n'
f'google-api-python-client {api_client_ver}\n'
f'{getOSPlatform()} {platform.machine()}\n'
Expand Down Expand Up @@ -3296,7 +3296,7 @@ def doPrinterRegister():
'uuid':
_getValueFromOAuth('sub'),
'manufacturer':
gam_author,
GAM_AUTHOR,
'model':
'cp1',
'gcp_version':
Expand All @@ -3308,7 +3308,7 @@ def doPrinterRegister():
'update_url':
GAM_RELEASES,
'firmware':
gam_version,
GAM_VERSION,
'semantic_state': {
'version': '1.0',
'printer': {
Expand Down Expand Up @@ -8609,21 +8609,24 @@ def doCreateOrRotateServiceAccountKeys(iam=None,
name, local_key_size)
print(' Uploading new public certificate to Google...')
max_retries = 10
for i in range(1, max_retries+1):
try:
result = gapi.call(iam.projects().serviceAccounts().keys(),
'upload',
throw_reasons=[gapi_errors.ErrorReason.NOT_FOUND],
name=name,
body={'publicKeyData': publicKeyData})
break
except gapi_errors.GapiNotFoundError as e:
if i == max_retries:
raise e
sleep_time = i*5
if i > 3:
print(f'Waiting for Service Account creation to complete. Sleeping {sleep_time} seconds\n')
time.sleep(sleep_time)
for i in range(1, max_retries + 1):
try:
result = gapi.call(
iam.projects().serviceAccounts().keys(),
'upload',
throw_reasons=[gapi_errors.ErrorReason.NOT_FOUND],
name=name,
body={'publicKeyData': publicKeyData})
break
except gapi_errors.GapiNotFoundError as e:
if i == max_retries:
raise e
sleep_time = i * 5
if i > 3:
print(
f'Waiting for Service Account creation to complete. Sleeping {sleep_time} seconds\n'
)
time.sleep(sleep_time)
private_key_id = result['name'].rsplit('/', 1)[-1]
oauth2service_data = _formatOAuth2ServiceData(project_id, client_email,
client_id, private_key,
Expand Down Expand Up @@ -9894,8 +9897,8 @@ def doWhatIs():
],
userKey=email,
fields='id,primaryEmail')
if (user_or_alias['primaryEmail'].lower() == email) or (
user_or_alias['id'] == email):
if (user_or_alias['primaryEmail'].lower()
== email) or (user_or_alias['id'] == email):
sys.stderr.write(f'{email} is a user\n\n')
doGetUserInfo(user_email=email)
return
Expand Down Expand Up @@ -12915,9 +12918,8 @@ def getUsersToModify(entity_type=None,
query=query)
for member in members:
email = member['primaryEmail']
if (checkSuspended is None or
checkSuspended == member['suspended']
) and email not in usersSet:
if (checkSuspended is None or checkSuspended
== member['suspended']) and email not in usersSet:
usersSet.add(email)
users.append(email)
if not silent:
Expand Down
Loading

0 comments on commit d46dd46

Please sign in to comment.