eric6/E5Network/E5GoogleMailHelpers.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
permissions
-rw-r--r--

Updated copyright for 2021.

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

eric ide

mercurial