diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-07-04 12:53:02 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-07-04 12:53:02 +0200 |
commit | 046a8650cdcd51e5e7d78b3673ed012cdfc1a1d0 (patch) | |
tree | 1bb84d1753c8f19b5fc14a55f18e16da405431ce /plugins | |
parent | d41bfa1c5761e7d23351b8892d448c0e242bbeb2 (diff) | |
download | poezio-046a8650cdcd51e5e7d78b3673ed012cdfc1a1d0.tar.gz poezio-046a8650cdcd51e5e7d78b3673ed012cdfc1a1d0.tar.bz2 poezio-046a8650cdcd51e5e7d78b3673ed012cdfc1a1d0.tar.xz poezio-046a8650cdcd51e5e7d78b3673ed012cdfc1a1d0.zip |
OTR plugin: Use the new poezio.xdg module.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/otr.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/plugins/otr.py b/plugins/otr.py index 2a909293..1d7d2719 100644 --- a/plugins/otr.py +++ b/plugins/otr.py @@ -188,6 +188,7 @@ from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, N from poezio import common from poezio import xhtml +from poezio import xdg from poezio.common import safeJID from poezio.config import config from poezio.plugin import BasePlugin @@ -196,9 +197,6 @@ from poezio.theming import get_theme, dump_tuple from poezio.decorators import command_args_parser from poezio.core.structs import Completion -OTR_DIR = os.path.join(os.getenv('XDG_DATA_HOME') or - '~/.local/share', 'poezio', 'otr') - POLICY_FLAGS = { 'ALLOW_V1':False, 'ALLOW_V2':True, @@ -471,15 +469,14 @@ class Plugin(BasePlugin): def init(self): # set the default values from the config - global OTR_DIR - OTR_DIR = os.path.expanduser(self.config.get('keys_dir', '') or OTR_DIR) + keys_dir = self.config.get('keys_dir', '') + otr_dir = Path(keys_dir).expanduser() if keys_dir else xdg.DATA_HOME / 'otr' try: - os.makedirs(OTR_DIR) + otr_dir.mkdir(parents=True, exists_ok=True) except OSError as e: - if e.errno != 17: - self.api.information('The OTR-specific folder could not ' - 'be created. Poezio will be unable ' - 'to save keys and trusts', 'OTR') + self.api.information('The OTR-specific folder could not ' + 'be created: %s. Poezio will be unable ' + 'to save keys and trusts' % e, 'OTR') except: self.api.information('The OTR-specific folder could not ' @@ -496,7 +493,7 @@ class Plugin(BasePlugin): self.core.xmpp.plugin['xep_0030'].add_feature('urn:xmpp:otr:0') - self.account = PoezioAccount(self.core.xmpp.boundjid.bare, OTR_DIR) + self.account = PoezioAccount(self.core.xmpp.boundjid.bare, otr_dir) self.account.load_trusts() self.contexts = {} usage = '<start|refresh|end|fpr|ourfpr|drop|trust|untrust>' |