diff -r db48660ca7c0 -r 1265efa7364f E5Network/E5GoogleMail.py --- a/E5Network/E5GoogleMail.py Wed Oct 24 19:59:49 2018 +0200 +++ b/E5Network/E5GoogleMail.py Thu Oct 25 20:06:44 2018 +0200 @@ -24,6 +24,8 @@ from googleapiclient import discovery +from PyQt5.QtCore import QCoreApplication + import Globals @@ -32,6 +34,17 @@ APPLICATION_NAME = 'Eric Python Send Email' +def isCredentialsFileAvailable(): + """ + Module function to check, if the credentials file has been installed. + + @return flag indicating, that the credentials file is there + @rtype bool + """ + return os.path.exists( + os.path.join(Globals.getConfigDir(), CLIENT_SECRET_FILE)) + + def getCredentials(): """ Module function to get the Google credentials. @@ -64,6 +77,14 @@ @return tuple containing a success flag and a result or error message @rtype tuple of (bool, str) """ + # check for secrets file first + if not os.path.exists(os.path.join(Globals.getConfigDir(), + CLIENT_SECRET_FILE)): + return False, QCoreApplication.translate( + "GoogleMailSendMessage", + "The credentials file is not present. Has the Gmail API" + " been enabled?") + try: credentials = getCredentials() http = credentials.authorize(httplib2.Http())