Compare commits

...

9 Commits
v4.1 ... v4.11

Author SHA1 Message Date
Jay Lee
056b56ed78 GAM 4.11 part 2 2017-01-25 14:31:20 -05:00
Jay Lee
791581b850 GAM 4.11 2017-01-25 14:29:36 -05:00
Ross Scroggs
08f426ba09 Allow suppression of empty entries in multivalued schema fields (#399) 2017-01-25 14:21:58 -05:00
Jay Lee
54371cffff remove .apps.googleusercontent.com from client id for auth 2017-01-25 11:35:33 -05:00
Jay Lee
c7946c0edf remove access_type=offline to shorten auth URLs as it's default already 2017-01-25 11:22:25 -05:00
Jay Lee
ae578c64a0 rename to simplehttp so we don't affect http 2017-01-25 09:02:11 -05:00
Jay Lee
08bc1898cc fix splitlines 2017-01-25 08:57:23 -05:00
Jay Lee
dc626b1b3e always use httplib2 so we are consistent with TLS verify, debug output, etc 2017-01-25 08:53:33 -05:00
Ross Scroggs
7283e06750 Allow newlines in calendar event descriptions. (#398) 2017-01-24 15:36:12 -05:00
4 changed files with 26 additions and 16 deletions

View File

@@ -40,7 +40,6 @@ import random
import re
import socket
import StringIO
import urllib2
import googleapiclient
import googleapiclient.discovery
@@ -423,11 +422,11 @@ def doGAMCheckForUpdates(forceCheck=False):
return
check_url = GAM_LATEST_RELEASE # latest full release
headers = {u'Accept': u'application/vnd.github.v3.text+json'}
request = urllib2.Request(url=check_url, headers=headers)
simplehttp = httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL])
try:
c = urllib2.urlopen(request)
(_, c) = simplehttp.request(check_url, u'GET', headers=headers)
try:
release_data = json.loads(c.read())
release_data = json.loads(c)
except ValueError:
return
if isinstance(release_data, list):
@@ -453,7 +452,7 @@ def doGAMCheckForUpdates(forceCheck=False):
sys.exit(0)
writeFile(GM_Globals[GM_LAST_UPDATE_CHECK_TXT], str(now_time), continueOnError=True, displayError=forceCheck)
return
except (urllib2.HTTPError, urllib2.URLError):
except (httplib2.HttpLib2Error, httplib2.ServerNotFoundError, httplib2.CertificateValidationUnsupported):
return
def doGAMVersion(checkForArgs=True):
@@ -2956,7 +2955,7 @@ def doCalendarAddEvent():
body[u'anyoneCanAddSelf'] = True
i += 1
elif sys.argv[i].lower() == u'description':
body[u'description'] = sys.argv[i+1]
body[u'description'] = sys.argv[i+1].replace(u'\\n', u'\n')
i += 2
elif sys.argv[i].lower() == u'start':
if sys.argv[i+1].lower() == u'allday':
@@ -3099,10 +3098,11 @@ def doPhoto(users):
filename = filename.replace(u'#username#', user[:user.find(u'@')])
print u"Updating photo for %s with %s (%s/%s)" % (user, filename, i, count)
if re.match(u'^(ht|f)tps?://.*$', filename):
simplehttp = httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL])
try:
f = urllib2.urlopen(filename)
image_data = str(f.read())
except urllib2.HTTPError as e:
(_, f) = simplehttp.request(filename, u'GET')
image_data = str(f)
except (httplib2.HttpLib2Error, httplib2.ServerNotFoundError, httplib2.CertificateValidationUnsupported) as e:
print e
continue
else:
@@ -6169,7 +6169,8 @@ def getUserAttributes(i, cd, updateCmd=False):
body.setdefault(up, {})
body[up].setdefault(schemaName, {})
i += 1
if sys.argv[i].lower() in [u'multivalue', u'multivalued', u'value']:
multivalue = sys.argv[i].lower()
if multivalue in [u'multivalue', u'multivalued', u'value', u'multinonempty']:
i += 1
body[up][schemaName].setdefault(fieldName, [])
schemaValue = {}
@@ -6184,7 +6185,8 @@ def getUserAttributes(i, cd, updateCmd=False):
schemaValue[u'customType'] = sys.argv[i]
i += 1
schemaValue[u'value'] = sys.argv[i]
body[up][schemaName][fieldName].append(schemaValue)
if schemaValue[u'value'] or multivalue != u'multinonempty':
body[up][schemaName][fieldName].append(schemaValue)
else:
body[up][schemaName][fieldName] = sys.argv[i]
i += 1
@@ -6291,8 +6293,9 @@ and accept the Terms of Service (ToS). As soon as you've accepted the ToS popup,
sys.exit(2)
break
apis_url = u'https://raw.githubusercontent.com/jay0lee/GAM/master/src/project-apis.txt'
request = urllib2.Request(url=apis_url)
apis = urllib2.urlopen(request).read().splitlines()
simplehttp = httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL])
_, c = simplehttp.request(apis_url, u'GET')
apis = c.splitlines()
serveman = googleapiclient.discovery.build(u'servicemanagement', u'v1', http=http, cache_discovery=False)
for api in apis:
while True:
@@ -9415,6 +9418,9 @@ gam create project
try:
cs_json = json.loads(cs_data)
client_id = cs_json[u'installed'][u'client_id']
# chop off .apps.googleusercontent.com suffix as it's not needed
# and we need to keep things short for the Auth URL.
client_id = re.sub(u'\.apps\.googleusercontent\.com$', u'', client_id)
client_secret = cs_json[u'installed'][u'client_secret']
except (ValueError, IndexError, KeyError):
print u'ERROR: the format of your client secrets file:\n\n%s\n\n is incorrect. Please recreate the file.'
@@ -9484,7 +9490,7 @@ gam create project
break
flow = oauth2client.client.OAuth2WebServerFlow(client_id=client_id,
client_secret=client_secret, scope=scopes, redirect_uri=oauth2client.client.OOB_CALLBACK_URN,
user_agent=GAM_INFO, access_type=u'offline', response_type=u'code', login_hint=login_hint)
user_agent=GAM_INFO, response_type=u'code', login_hint=login_hint)
storage, credentials = getOauth2TxtStorageCredentials()
if credentials is None or credentials.invalid:
http = httplib2.Http(disable_ssl_certificate_validation=GC_Values[GC_NO_VERIFY_SSL])

View File

@@ -1771,7 +1771,7 @@ class DeviceFlowInfo(collections.namedtuple('DeviceFlowInfo', (
def _oauth2_web_server_flow_params(kwargs):
"""Configures redirect URI parameters for OAuth2WebServerFlow."""
params = {
'access_type': 'offline',
# 'access_type': 'offline',
'response_type': 'code',
}

View File

@@ -4,7 +4,7 @@ import platform
import re
gam_author = u'Jay Lee <jay0lee@gmail.com>'
gam_version = u'4.1'
gam_version = u'4.11'
gam_license = u'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
GAM_URL = u'http://git.io/gam'

View File

@@ -1,3 +1,7 @@
GAM 4.11
- Allow newlines in calendar event descriptions (Ross)
- All HTTP requests should now honor SSL verify setting, debug, etc
GAM 4.1
- Fix "gam create project"
- project create cleanups by Ross