src/eric7/EricNetwork/EricGoogleMailHelpers.py

branch
eric7
changeset 10928
46651e194fbe
parent 10926
9ef616cd220d
child 11090
f5f5f5803935
diff -r ce599998be7d -r 46651e194fbe src/eric7/EricNetwork/EricGoogleMailHelpers.py
--- a/src/eric7/EricNetwork/EricGoogleMailHelpers.py	Thu Sep 26 09:48:49 2024 +0200
+++ b/src/eric7/EricNetwork/EricGoogleMailHelpers.py	Thu Sep 26 15:49:36 2024 +0200
@@ -7,12 +7,9 @@
 Module implementing some helpers for Google mail.
 """
 
+import contextlib
 import os
 
-from eric7 import EricUtilities
-from eric7.EricWidgets.EricApplication import ericApp
-from eric7.SystemUtilities import PythonUtilities
-
 SCOPES = ["https://www.googleapis.com/auth/gmail.send"]
 CLIENT_SECRET_FILE = "eric_client_secret.json"  # secok
 TOKEN_FILE = "eric_python_email_send_token.json"  # secok
@@ -32,6 +29,8 @@
     @return flag indicating, that the credentials file is there
     @rtype bool
     """
+    from eric7 import EricUtilities
+
     return os.path.exists(
         os.path.join(EricUtilities.getConfigDir(), CLIENT_SECRET_FILE)
     )
@@ -41,10 +40,14 @@
     """
     Module function to install the required packages to support Google mail.
     """
-    pip = ericApp().getObject("Pip")
-    pip.installPackages(
-        RequiredPackages, interpreter=PythonUtilities.getPythonExecutable()
-    )
+    with contextlib.suppress(ImportError, KeyError):
+        from eric7.EricWidgets.EricApplication import ericApp  # noqa: I101
+        from eric7.SystemUtilities import PythonUtilities  # noqa: I101
+
+        pip = ericApp().getObject("Pip")
+        pip.installPackages(
+            RequiredPackages, interpreter=PythonUtilities.getPythonExecutable()
+        )
 
 
 #

eric ide

mercurial