Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
replace get_password
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jan 16, 2021
1 parent 7e9072c commit 4107bd6
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 43 deletions.
7 changes: 2 additions & 5 deletions _unittests/ut_mokadi/test_LONG_rest_api_speech.py
Expand Up @@ -5,7 +5,7 @@
import os
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import is_travis_or_appveyor, add_missing_development_version


Expand All @@ -23,10 +23,7 @@ def test_api_speech_reco(self):
OutputPrint=__name__ == "__main__")

from botadi.mokadi.cognitive_services_helper import call_api_speech_reco
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
subkey = keyring.get_password("cogser", "botadi,voicereco")
subkey = get_password("cogser", "botadi,voicereco")
if not subkey:
warnings.warn("no key")
return
Expand Down
11 changes: 4 additions & 7 deletions _unittests/ut_mokadi/test_engine_ex.py
Expand Up @@ -5,7 +5,7 @@
import os
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import get_temp_folder, is_travis_or_appveyor, ExtTestCase
from botadi.mokadi import MokadiEngine, MokadiMessage
from botadi.mokadi.mokadi_action_slides import MokadiActionSlides
Expand Down Expand Up @@ -45,13 +45,10 @@ def test_engine_ex(self):
# Adding test which requires credentials.
if not is_travis_or_appveyor():
fLOG("Adding actions with credentials.")
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
user = keyring.get_password("gmail", "botadi,user")
pwd = keyring.get_password("gmail", "botadi,pwd")
user = get_password("gmail", "botadi,user")
pwd = get_password("gmail", "botadi,pwd")
server = "imap.gmail.com"
subkey_news = keyring.get_password("cogser", "botadi,news")
subkey_news = get_password("cogser", "botadi,news")
if subkey_news is None:
warnings.warn("No key")
return
Expand Down
7 changes: 2 additions & 5 deletions _unittests/ut_mokadi/test_engine_ex_2.py
Expand Up @@ -4,7 +4,7 @@
"""
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import get_temp_folder, is_travis_or_appveyor
from botadi.mokadi import MokadiEngine, MokadiMessage
from botadi.mokadi.mokadi_action_emotion import MokadiActionEmotion
Expand Down Expand Up @@ -33,10 +33,7 @@ def test_engine_ex_2(self):

# Adding test which requires credentials.
fLOG("Adding actions with credentials.")
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
subkey_emo = keyring.get_password("cogser", "botadi,emotions")
subkey_emo = get_password("cogser", "botadi,emotions")
messages.append("MOKADI humeur")
actions.insert(0, MokadiActionEmotion(subkey_emo, temp, fLOG=fLOG))

Expand Down
7 changes: 2 additions & 5 deletions _unittests/ut_mokadi/test_mail.py
Expand Up @@ -18,11 +18,8 @@ def test_mail(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")

with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
user = keyring.get_password("gmail", "botadi,user")
pwd = keyring.get_password("gmail", "botadi,pwd")
user = get_password("gmail", "botadi,user")
pwd = get_password("gmail", "botadi,pwd")
if user is None:
raise ValueError("user is not specified.")
if pwd is None:
Expand Down
7 changes: 2 additions & 5 deletions _unittests/ut_mokadi/test_rest_api_emotions.py
Expand Up @@ -5,7 +5,7 @@
import os
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import is_travis_or_appveyor
from botadi.mokadi.cognitive_services_helper import call_api_emotions

Expand All @@ -23,10 +23,7 @@ def test_api_emotions(self):
imgs = [os.path.join(path, "84-cate-blanchett-jude-quinn-i-m-not-there-2007--630-75.jpg"),
os.path.join(path, "Cate_Blanchett_Deauville_2013_2.jpg")]

with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
subkey = keyring.get_password("cogser", "botadi,emotions")
subkey = get_password("cogser", "botadi,emotions")
if not subkey:
warnings.warn("No key")
return
Expand Down
4 changes: 2 additions & 2 deletions _unittests/ut_mokadi/test_rest_api_images.py
Expand Up @@ -4,7 +4,7 @@
"""
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import is_travis_or_appveyor
from botadi.mokadi.cognitive_services_helper import call_api_images

Expand All @@ -21,7 +21,7 @@ def test_api_news(self):
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
subkey = keyring.get_password("cogser", "botadi,news")
subkey = get_password("cogser", "botadi,news")
if not subkey:
warnings.warn("No key")
return
Expand Down
7 changes: 2 additions & 5 deletions _unittests/ut_mokadi/test_rest_api_news.py
Expand Up @@ -4,7 +4,7 @@
"""
import unittest
import warnings
from pyquickhelper.loghelper import fLOG
from pyquickhelper.loghelper import fLOG, get_password
from pyquickhelper.pycode import is_travis_or_appveyor
from botadi.mokadi.cognitive_services_helper import call_api_news

Expand All @@ -18,10 +18,7 @@ def test_api_news(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")

with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
subkey = keyring.get_password("cogser", "botadi,news")
subkey = get_password("cogser", "botadi,news")
if not subkey:
warnings.warn("No key")
return
Expand Down
15 changes: 6 additions & 9 deletions src/botadi/mokadi/gui_mokadi.py
Expand Up @@ -11,7 +11,7 @@
import warnings
from queue import Queue
from PIL import Image, ImageTk
from pyquickhelper.loghelper import CustomLog, fLOG
from pyquickhelper.loghelper import CustomLog, fLOG, get_password, get_password
from .grammars import MokadiGrammar_frParser, MokadiGrammar_frLexer, MokadiGrammar_frListener
from .mokadi_message import MokadiMessage
from .mokadi_engine import MokadiEngine
Expand Down Expand Up @@ -312,17 +312,14 @@ def gui_mokadi(fLOG=None, folder_slides=None):
runs first. We need to take a picture first.
"""
take_picture()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import keyring
user = keyring.get_password("gmail", os.environ["COMPUTERNAME"] + "user")
pwd = keyring.get_password("gmail", os.environ["COMPUTERNAME"] + "pwd")
user = get_password("gmail", os.environ["COMPUTERNAME"] + "user")
pwd = get_password("gmail", os.environ["COMPUTERNAME"] + "pwd")
server = "imap.gmail.com"
subkey_news = keyring.get_password(
subkey_news = get_password(
"cogser", os.environ["COMPUTERNAME"] + "news")
subkey_emo = keyring.get_password(
subkey_emo = get_password(
"cogser", os.environ["COMPUTERNAME"] + "emotions")
subkey_speech = keyring.get_password(
subkey_speech = get_password(
"cogser", os.environ["COMPUTERNAME"] + "voicereco")

if folder_slides is None:
Expand Down

0 comments on commit 4107bd6

Please sign in to comment.