* Fix create project to handle Google change

* Handle newlines in app name

Don’t output name/value for
name == u'accounts:authorized_apps’, apps are listed later

* Cleanup

My typos: 614, 813
Pylint: 887, 3618/4184, 8657, 8751
Your typo: 6794
This commit is contained in:
Ross Scroggs
2017-03-22 17:39:44 -07:00
committed by Jay Lee
parent 4bf6b6fb96
commit 81c2e425ef

View File

@ -611,7 +611,7 @@ def callGAPI(service, function,
handleOAuthTokenError(str(e), soft_errors or GAPI_SERVICE_NOT_AVAILABLE in throw_reasons) handleOAuthTokenError(str(e), soft_errors or GAPI_SERVICE_NOT_AVAILABLE in throw_reasons)
if GAPI_SERVICE_NOT_AVAILABLE in throw_reasons: if GAPI_SERVICE_NOT_AVAILABLE in throw_reasons:
raise GAPI_serviceNotAvailable(str(e)) raise GAPI_serviceNotAvailable(str(e))
stderrErrorMsg(u'User {0}: {1)'.format(GM_Globals[GM_CURRENT_API_USER], str(e))) stderrErrorMsg(u'User {0}: {1}'.format(GM_Globals[GM_CURRENT_API_USER], str(e)))
return None return None
except httplib2.CertificateValidationUnsupported: except httplib2.CertificateValidationUnsupported:
noPythonSSLExit() noPythonSSLExit()
@ -810,7 +810,7 @@ def buildGAPIServiceObject(api, act_as, use_scopes=None):
except httplib2.ServerNotFoundError as e: except httplib2.ServerNotFoundError as e:
systemErrorExit(4, e) systemErrorExit(4, e)
except oauth2client.client.AccessTokenRefreshError as e: except oauth2client.client.AccessTokenRefreshError as e:
stderrErrorMsg(u'User {0}: {1)'.format(GM_Globals[GM_CURRENT_API_USER], str(e))) stderrErrorMsg(u'User {0}: {1}'.format(GM_Globals[GM_CURRENT_API_USER], str(e)))
return handleOAuthTokenError(str(e), True) return handleOAuthTokenError(str(e), True)
return service return service
@ -884,7 +884,7 @@ def _adjustDate(errMsg):
match_date = re.match(u'Start date can not be later than (.*)', errMsg) match_date = re.match(u'Start date can not be later than (.*)', errMsg)
if not match_date: if not match_date:
systemErrorExit(4, errMsg) systemErrorExit(4, errMsg)
return (unicode(match_date.group(1))) return unicode(match_date.group(1))
def showReport(): def showReport():
rep = buildGAPIObject(u'reports') rep = buildGAPIObject(u'reports')
@ -3615,9 +3615,9 @@ def addDriveFileACL(users):
if not drive: if not drive:
continue continue
result = callGAPI(drive.permissions(), u'create', fields=u'*', result = callGAPI(drive.permissions(), u'create', fields=u'*',
fileId=fileId, sendNotificationEmail=sendNotificationEmail, fileId=fileId, sendNotificationEmail=sendNotificationEmail,
emailMessage=emailMessage, body=body, supportsTeamDrives=True, emailMessage=emailMessage, body=body, supportsTeamDrives=True,
transferOwnership=transferOwnership) transferOwnership=transferOwnership)
printPermission(result) printPermission(result)
def updateDriveFileACL(users): def updateDriveFileACL(users):
@ -3654,9 +3654,9 @@ def updateDriveFileACL(users):
continue continue
print u'updating permissions for %s to file %s' % (permissionId, fileId) print u'updating permissions for %s to file %s' % (permissionId, fileId)
result = callGAPI(drive.permissions(), u'update', fields=u'*', result = callGAPI(drive.permissions(), u'update', fields=u'*',
fileId=fileId, permissionId=permissionId, fileId=fileId, permissionId=permissionId,
transferOwnership=transferOwnership, body=body, transferOwnership=transferOwnership, body=body,
supportsTeamDrives=True) supportsTeamDrives=True)
printPermission(result) printPermission(result)
def _stripMeInOwners(query): def _stripMeInOwners(query):
@ -4180,8 +4180,8 @@ def downloadDriveFile(users):
for fileId in fileIdSelection[u'fileIds']: for fileId in fileIdSelection[u'fileIds']:
extension = None extension = None
result = callGAPI(drive.files(), u'get', fileId=fileId, result = callGAPI(drive.files(), u'get', fileId=fileId,
fields=u'fileSize,title,mimeType,downloadUrl,exportLinks', fields=u'fileSize,title,mimeType,downloadUrl,exportLinks',
supportsTeamDrives=True) supportsTeamDrives=True)
if result[u'mimeType'] == MIMETYPE_GA_FOLDER: if result[u'mimeType'] == MIMETYPE_GA_FOLDER:
print utils.convertUTF8(u'Skipping download of folder %s' % result[u'title']) print utils.convertUTF8(u'Skipping download of folder %s' % result[u'title'])
continue continue
@ -6791,7 +6791,7 @@ def printShowTeamDrives(users, csvFormat):
if u'id' not in td: if u'id' not in td:
continue continue
if u'name' not in td: if u'name' not in td:
td[u'name'] == u'<Unknown Team Drive>' td[u'name'] = u'<Unknown Team Drive>'
this_td = {u'id': td[u'id'], u'name': td[u'name']} this_td = {u'id': td[u'id'], u'name': td[u'name']}
if this_td in tds: if this_td in tds:
continue continue
@ -8654,7 +8654,7 @@ def doDeleteOrg():
def send_email(msg_subj, msg_txt, msg_rcpt=None): def send_email(msg_subj, msg_txt, msg_rcpt=None):
from email.mime.text import MIMEText from email.mime.text import MIMEText
userId = _getAdminUserFromOAuth() userId = _getAdminUserFromOAuth()
userId, gmail = buildGmailGAPIObject(userId) userId, gmail = buildGmailGAPIObject(userId)
if not msg_rcpt: if not msg_rcpt:
msg_rcpt = userId msg_rcpt = userId
msg = MIMEText(msg_txt) msg = MIMEText(msg_txt)
@ -8748,7 +8748,7 @@ def writeCSVfile(csvRows, titles, list_type, todrive):
result = callGAPI(drive.files(), u'create', fields=u'webViewLink', result = callGAPI(drive.files(), u'create', fields=u'webViewLink',
body=body, body=body,
media_body=googleapiclient.http.MediaInMemoryUpload(string_file.getvalue(), media_body=googleapiclient.http.MediaInMemoryUpload(string_file.getvalue(),
mimetype=u'text/csv')) mimetype=u'text/csv'))
file_url = result[u'webViewLink'] file_url = result[u'webViewLink']
if GC_Values[GC_NO_BROWSER]: if GC_Values[GC_NO_BROWSER]:
msg_txt = u'Drive file uploaded to:\n %s' % file_url msg_txt = u'Drive file uploaded to:\n %s' % file_url