Keep the pylint wolf at bay (#430)

* Fix bug, update ducumantation

* Clean up error messages

* Exit on error, fix bug

* One more bug fix

* Update documentation, fix code

l_sku can never match a_sku.lower() because it has -'s stripped and
a_sku doesn't

* Keep the pylint wolf at bay

* Clean up code, avoid try/except
This commit is contained in:
Ross Scroggs
2017-02-11 05:31:34 -08:00
committed by Jay Lee
parent 3d7a7bd609
commit aa6dca4b4c
3 changed files with 43 additions and 38 deletions

View File

@@ -22,9 +22,6 @@ With GAM you can programatically create users, turn on/off services for users li
For more information, see http://git.io/gam For more information, see http://git.io/gam
""" """
from var import *
import utils
import sys import sys
import os import os
import string import string
@@ -51,6 +48,9 @@ import oauth2client.service_account
import oauth2client.file import oauth2client.file
import oauth2client.tools import oauth2client.tools
import utils
from var import *
# Override some oauth2client.tools strings saving us a few GAM-specific mods to oauth2client # Override some oauth2client.tools strings saving us a few GAM-specific mods to oauth2client
oauth2client.tools._FAILED_START_MESSAGE = """ oauth2client.tools._FAILED_START_MESSAGE = """
Failed to start a local webserver listening on either port 8080 Failed to start a local webserver listening on either port 8080
@@ -7710,10 +7710,7 @@ def doGetUserInfo(user_email=None):
print ' %s' % _skuIdToDisplayName(user_license) print ' %s' % _skuIdToDisplayName(user_license)
def _skuIdToDisplayName(skuId): def _skuIdToDisplayName(skuId):
try: return SKUS[skuId][u'displayName'] if skuId in SKUS else skuId
return SKUS[skuId][u'displayName']
except KeyError:
return skuId
def doGetGroupInfo(group_name=None): def doGetGroupInfo(group_name=None):
cd = buildGAPIObject(u'directory') cd = buildGAPIObject(u'directory')

View File

@@ -1,9 +1,9 @@
from var import GM_Globals, GM_WINDOWS, GM_SYS_ENCODING
import collections import collections
import re import re
import sys import sys
from htmlentitydefs import name2codepoint from htmlentitydefs import name2codepoint
from HTMLParser import HTMLParser from HTMLParser import HTMLParser
from var import GM_Globals, GM_WINDOWS, GM_SYS_ENCODING
def convertUTF8(data): def convertUTF8(data):
if isinstance(data, str): if isinstance(data, str):

View File

@@ -9,7 +9,9 @@ gam_license = u'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
GAM_URL = u'http://git.io/gam' GAM_URL = u'http://git.io/gam'
GAM_INFO = u'GAM {0} - {1} / {2} / Python {3}.{4}.{5} {6} / {7} {8} /'.format(gam_version, GAM_URL, GAM_INFO = u'GAM {0} - {1} / {2} / Python {3}.{4}.{5} {6} / {7} {8} /'.format(gam_version, GAM_URL,
gam_author, sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.version_info[3], gam_author,
sys.version_info[0], sys.version_info[1],
sys.version_info[2], sys.version_info[3],
platform.platform(), platform.machine()) platform.platform(), platform.machine())
GAM_RELEASES = u'https://github.com/jay0lee/GAM/releases' GAM_RELEASES = u'https://github.com/jay0lee/GAM/releases'
@@ -111,9 +113,11 @@ API_SCOPE_MAPPING = {
u'plus': [u'https://www.googleapis.com/auth/plus.me',], u'plus': [u'https://www.googleapis.com/auth/plus.me',],
} }
ADDRESS_FIELDS_PRINT_ORDER = [u'contactName', u'organizationName', ADDRESS_FIELDS_PRINT_ORDER = [
u'addressLine1', u'addressLine2', u'addressLine3', u'locality', u'contactName', u'organizationName',
u'region', u'postalCode', u'countryCode'] u'addressLine1', u'addressLine2', u'addressLine3',
u'locality', u'region', u'postalCode', u'countryCode',
]
ADDRESS_FIELDS_ARGUMENT_MAP = { ADDRESS_FIELDS_ARGUMENT_MAP = {
u'contact': u'contactName', u'contactname': u'contactName', u'contact': u'contactName', u'contactname': u'contactName',
@@ -252,8 +256,11 @@ DRIVEFILE_ORDERBY_CHOICES_MAP = {
u'viewedbymedate': u'lastViewedByMeDate', u'viewedbymedate': u'lastViewedByMeDate',
} }
DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP = {u'delete': u'purging', DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP = {
u'trash': u'trashing', u'untrash': u'untrashing',} u'delete': u'purging',
u'trash': u'trashing',
u'untrash': u'untrashing',
}
DRIVEFILE_LABEL_CHOICES_MAP = { DRIVEFILE_LABEL_CHOICES_MAP = {
u'restricted': u'restricted', u'restricted': u'restricted',
@@ -398,8 +405,10 @@ FILTER_CRITERIA_CHOICES_MAP = {
u'subject': u'subject', u'subject': u'subject',
u'to': u'to', u'to': u'to',
} }
FILTER_ACTION_CHOICES = [u'archive', u'forward', u'important', u'label', FILTER_ACTION_CHOICES = [
u'markread', u'neverspam', u'notimportant', u'star', u'trash',] u'archive', u'forward', u'important', u'label',
u'markread', u'neverspam', u'notimportant', u'star', u'trash',
]
CROS_ARGUMENT_TO_PROPERTY_MAP = { CROS_ARGUMENT_TO_PROPERTY_MAP = {
u'activetimeranges': [u'activeTimeRanges.activeTime', u'activeTimeRanges.date'], u'activetimeranges': [u'activeTimeRanges.activeTime', u'activeTimeRanges.date'],
@@ -689,4 +698,3 @@ GAPI_USER_RATE_LIMIT_EXCEEDED = u'userRateLimitExceeded'
GAPI_DEFAULT_RETRY_REASONS = [GAPI_QUOTA_EXCEEDED, GAPI_RATE_LIMIT_EXCEEDED, GAPI_USER_RATE_LIMIT_EXCEEDED, GAPI_BACKEND_ERROR, GAPI_INTERNAL_ERROR] GAPI_DEFAULT_RETRY_REASONS = [GAPI_QUOTA_EXCEEDED, GAPI_RATE_LIMIT_EXCEEDED, GAPI_USER_RATE_LIMIT_EXCEEDED, GAPI_BACKEND_ERROR, GAPI_INTERNAL_ERROR]
GAPI_GMAIL_THROW_REASONS = [GAPI_SERVICE_NOT_AVAILABLE] GAPI_GMAIL_THROW_REASONS = [GAPI_SERVICE_NOT_AVAILABLE]
GAPI_GPLUS_THROW_REASONS = [GAPI_SERVICE_NOT_AVAILABLE] GAPI_GPLUS_THROW_REASONS = [GAPI_SERVICE_NOT_AVAILABLE]