From 2a557fd37cd8a01f8ade43f7cd33c749f4350876 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 21 May 2019 16:15:03 +0200 Subject: [PATCH] Drop "keyring" requirement Ref #418 --- EDMC.py | 2 +- EDMarketConnector.py | 6 +----- README.md | 6 +++--- config.py | 14 +++++++++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/EDMC.py b/EDMC.py index 6fd2e895..a054ac18 100755 --- a/EDMC.py +++ b/EDMC.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # # Command-line interface. Requires prior setup through the GUI. # diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 7d3f1ef5..bc467df1 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # -*- coding: utf-8 -*- import sys @@ -6,7 +6,6 @@ from sys import platform from collections import OrderedDict from functools import partial import json -import keyring from os import chdir, environ from os.path import dirname, expanduser, isdir, join import re @@ -302,9 +301,6 @@ class AppWindow: self.postprefs(False) # Companion login happens in callback from monitor - if keyring.get_keyring().priority < 1: - self.status['text'] = 'Warning: Storing passwords as text' # Shouldn't happen unless no secure storage on Linux - # callback after the Preferences dialog is applied def postprefs(self, dologin=True): self.prefsdialog = None diff --git a/README.md b/README.md index 7619fcca..c99ceb94 100644 --- a/README.md +++ b/README.md @@ -236,17 +236,17 @@ Download and extract the [latest source code](https://github.com/Marginal/EDMark Mac: -* Requires the Python “keyring”, “requests” and “watchdog” modules, plus an up-to-date “py2app” module if you also want to package the app - install these with `easy_install -U keyring requests watchdog py2app` . +* Requires the Python “requests” and “watchdog” modules, plus an up-to-date “py2app” module if you also want to package the app - install these with `easy_install -U requests watchdog py2app` . * Run with `CLIENT_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX python ./EDMarketConnector.py` . Windows: -* Requires Python2.7 and the Python “keyring”, “requests” and “watchdog” modules, plus “py2exe” 0.6 if you also want to package the app. +* Requires Python2.7 and the Python “requests” and “watchdog” modules, plus “py2exe” 0.6 if you also want to package the app. * Run with `set CLIENT_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX && EDMarketConnector.py` . Linux: -* Requires the Python “imaging-tk”, “iniparse”, “keyring” and “requests” modules. On Debian-based systems install these with `sudo apt-get install python-imaging-tk python-iniparse python-keyring python-requests` . +* Requires the Python “imaging-tk”, “iniparse”, and “requests” modules. On Debian-based systems install these with `sudo apt-get install python-imaging-tk python-iniparse python-requests` . * Run with `CLIENT_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ./EDMarketConnector.py` . Command-line diff --git a/config.py b/config.py index 080d19e8..b6b020da 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,3 @@ -import keyring import numbers import sys from os import getenv, makedirs, mkdir, pardir @@ -360,13 +359,22 @@ class Config: # Common def get_password(self, account): - return keyring.get_password(self.identifier, account) + try: + import keyring + return keyring.get_password(self.identifier, account) + except ImportException: + return None def set_password(self, account, password): - keyring.set_password(self.identifier, account, password) + try: + import keyring + keyring.set_password(self.identifier, account, password) + except ImportException: + pass def delete_password(self, account): try: + import keyring keyring.delete_password(self.identifier, account) except: pass # don't care - silently fail