eric6/E5Network/E5GoogleMailHelpers.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7229
53054eb5b15a
child 7628
f904d0eef264
permissions
-rw-r--r--

Updated copyright for 2020.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2019 - 2020 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
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import Globals
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 SCOPES = 'https://www.googleapis.com/auth/gmail.send'
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 CLIENT_SECRET_FILE = 'eric_client_secret.json'
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 TOKEN_FILE = 'eric_python_email_send_token.json'
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 APPLICATION_NAME = 'Eric Python Send Email'
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 RequiredPackages = (
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 "google-api-python-client",
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 "requests-oauthlib",
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
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def isClientSecretFileAvailable():
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @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
31 @rtype bool
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 return os.path.exists(
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 os.path.join(Globals.getConfigDir(), CLIENT_SECRET_FILE))
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
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 def getInstallCommand():
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 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
40 activated.
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @return install command
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @rtype str
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 pipCommand = "pip install --upgrade {0}".format(
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 " ".join(RequiredPackages))
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
3a6133fe99a8 Google Mail: added the forgotten files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 return pipCommand

eric ide

mercurial