5 |
5 |
6 """ |
6 """ |
7 Module implementing some helpers for Google mail. |
7 Module implementing some helpers for Google mail. |
8 """ |
8 """ |
9 |
9 |
|
10 import contextlib |
10 import os |
11 import os |
11 |
|
12 from eric7 import EricUtilities |
|
13 from eric7.EricWidgets.EricApplication import ericApp |
|
14 from eric7.SystemUtilities import PythonUtilities |
|
15 |
12 |
16 SCOPES = ["https://www.googleapis.com/auth/gmail.send"] |
13 SCOPES = ["https://www.googleapis.com/auth/gmail.send"] |
17 CLIENT_SECRET_FILE = "eric_client_secret.json" # secok |
14 CLIENT_SECRET_FILE = "eric_client_secret.json" # secok |
18 TOKEN_FILE = "eric_python_email_send_token.json" # secok |
15 TOKEN_FILE = "eric_python_email_send_token.json" # secok |
19 APPLICATION_NAME = "Eric Python Send Email" |
16 APPLICATION_NAME = "Eric Python Send Email" |
30 Module function to check, if the client secret file has been installed. |
27 Module function to check, if the client secret file has been installed. |
31 |
28 |
32 @return flag indicating, that the credentials file is there |
29 @return flag indicating, that the credentials file is there |
33 @rtype bool |
30 @rtype bool |
34 """ |
31 """ |
|
32 from eric7 import EricUtilities |
|
33 |
35 return os.path.exists( |
34 return os.path.exists( |
36 os.path.join(EricUtilities.getConfigDir(), CLIENT_SECRET_FILE) |
35 os.path.join(EricUtilities.getConfigDir(), CLIENT_SECRET_FILE) |
37 ) |
36 ) |
38 |
37 |
39 |
38 |
40 def installGoogleAPIPackages(): |
39 def installGoogleAPIPackages(): |
41 """ |
40 """ |
42 Module function to install the required packages to support Google mail. |
41 Module function to install the required packages to support Google mail. |
43 """ |
42 """ |
44 pip = ericApp().getObject("Pip") |
43 with contextlib.suppress(ImportError, KeyError): |
45 pip.installPackages( |
44 from eric7.EricWidgets.EricApplication import ericApp # noqa: I101 |
46 RequiredPackages, interpreter=PythonUtilities.getPythonExecutable() |
45 from eric7.SystemUtilities import PythonUtilities # noqa: I101 |
47 ) |
46 |
|
47 pip = ericApp().getObject("Pip") |
|
48 pip.installPackages( |
|
49 RequiredPackages, interpreter=PythonUtilities.getPythonExecutable() |
|
50 ) |
48 |
51 |
49 |
52 |
50 # |
53 # |
51 # eflag: noqa = U200 |
54 # eflag: noqa = U200 |