|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing some helpers for Google mail. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import os |
|
13 |
|
14 import Globals |
|
15 |
|
16 SCOPES = 'https://www.googleapis.com/auth/gmail.send' |
|
17 CLIENT_SECRET_FILE = 'eric_client_secret.json' |
|
18 TOKEN_FILE = 'eric_python_email_send_token.json' |
|
19 APPLICATION_NAME = 'Eric Python Send Email' |
|
20 |
|
21 RequiredPackages = ( |
|
22 "google-api-python-client", |
|
23 "requests-oauthlib", |
|
24 ) |
|
25 |
|
26 |
|
27 def isClientSecretFileAvailable(): |
|
28 """ |
|
29 Module function to check, if the client secret file has been installed. |
|
30 |
|
31 @return flag indicating, that the credentials file is there |
|
32 @rtype bool |
|
33 """ |
|
34 return os.path.exists( |
|
35 os.path.join(Globals.getConfigDir(), CLIENT_SECRET_FILE)) |
|
36 |
|
37 |
|
38 def getInstallCommand(): |
|
39 """ |
|
40 Module function to get the install command to get the Google mail support |
|
41 activated. |
|
42 |
|
43 @return install command |
|
44 @rtype str |
|
45 """ |
|
46 pipCommand = "pip install --upgrade {0}".format( |
|
47 " ".join(RequiredPackages)) |
|
48 |
|
49 return pipCommand |