|
|
|
|
@@ -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])
|
|
|
|
|
|