From 798a7f9c8e5f0ca0fb6a433b9d0f2dead242949f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:35:10 +0100 Subject: [PATCH 01/19] GitHub Action: There is no requirements.txt --- .github/workflows/Python_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index a9ad8f8..1a6e422 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest -r requirements.txt + pip install flake8 pytest # -r requirements.txt #- name: Check formatting with black # if: matrix.python-version == '3.8' # run: | From 48dac1421869d51e215cb7d492c4cbb158d788b6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:39:27 +0100 Subject: [PATCH 02/19] builtins=_ --- .github/workflows/Python_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 1a6e422..e07c1b2 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -9,7 +9,7 @@ jobs: os: [macos-latest] python-version: [2.7, 3.8] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From ae703e523cfe5134f4f512e3b0a24d30c2481148 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:41:14 +0100 Subject: [PATCH 03/19] flake8 . --builtins=_ --- .github/workflows/Python_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index e07c1b2..6d6b10d 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From c74f4b20d38411db04514348fd0752b43013e92c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:45:36 +0100 Subject: [PATCH 04/19] Undefined name: from datetime import datetime --- obok_src/common_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/obok_src/common_utils.py b/obok_src/common_utils.py index 964753f..0f2164a 100644 --- a/obok_src/common_utils.py +++ b/obok_src/common_utils.py @@ -8,6 +8,7 @@ __copyright__ = '2012, David Forrester ' __docformat__ = 'restructuredtext en' import os, time, re, sys +from datetime import datetime try: from PyQt5.Qt import (Qt, QIcon, QPixmap, QLabel, QDialog, QHBoxLayout, QProgressBar, QTableWidgetItem, QFont, QLineEdit, QComboBox, From 89cf29cb7835a35c85c7f8c6c595b2b832fb7492 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:46:20 +0100 Subject: [PATCH 05/19] flake8 . --builtins=_,I --- .github/workflows/Python_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 6d6b10d..65215df 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --builtins=_,I --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --builtins=_,I --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From e4c1a09d45dd47841b16324a2274752c974fd9d5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:49:02 +0100 Subject: [PATCH 06/19] Undefined name: import traceback --- dedrm_src/epubtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/epubtest.py b/dedrm_src/epubtest.py index 11f1427..eb9af5a 100644 --- a/dedrm_src/epubtest.py +++ b/dedrm_src/epubtest.py @@ -48,7 +48,7 @@ from __future__ import with_statement __version__ = '1.01' -import sys, struct, os +import sys, struct, os, traceback import zlib import zipfile import xml.etree.ElementTree as etree From 616548a9a8b04810db7da6e463aabebd3e31aea5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:52:54 +0100 Subject: [PATCH 07/19] Undefined name: import traceback for line 70 --- dedrm_src/wineutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/wineutils.py b/dedrm_src/wineutils.py index 0485e5e..df1755f 100644 --- a/dedrm_src/wineutils.py +++ b/dedrm_src/wineutils.py @@ -6,7 +6,7 @@ from __future__ import with_statement __license__ = 'GPL v3' # Standard Python modules. -import os, sys, re, hashlib +import os, sys, re, hashlib, traceback from calibre_plugins.dedrm.__init__ import PLUGIN_NAME, PLUGIN_VERSION def WineGetKeys(scriptpath, extension, wineprefix=""): From 1fd972ee1735ce48b29c257571e6a7786e73e4b6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:54:20 +0100 Subject: [PATCH 08/19] Identity is not the same thing as equality in Python --- dedrm_src/mobidedrm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/mobidedrm.py b/dedrm_src/mobidedrm.py index 501aa2d..cc7baf2 100644 --- a/dedrm_src/mobidedrm.py +++ b/dedrm_src/mobidedrm.py @@ -524,7 +524,7 @@ def cli_main(): else: infile = argv[1] outfile = argv[2] - if len(argv) is 4: + if len(argv) == 4: pidlist = argv[3].split(',') else: pidlist = [] From e35b37c4f444b9429ddfb0b25839d50dd70c151e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:29:03 +0100 Subject: [PATCH 09/19] Undefined name: from .convert2xml import encodeNumber --- dedrm_src/genbook.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dedrm_src/genbook.py b/dedrm_src/genbook.py index 4036896..3ec6ccf 100644 --- a/dedrm_src/genbook.py +++ b/dedrm_src/genbook.py @@ -1,6 +1,8 @@ #! /usr/bin/python # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab +from .convert2xml import encodeNumber + class Unbuffered: def __init__(self, stream): self.stream = stream From 7edebeef0da779af9c3e8b4daa3a1a0efccde2ac Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:33:16 +0100 Subject: [PATCH 10/19] import erdr2pml, ineptpdf, k4mobidedrm --- dedrm_src/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dedrm_src/__init__.py b/dedrm_src/__init__.py index cdd4e7b..ec4c621 100644 --- a/dedrm_src/__init__.py +++ b/dedrm_src/__init__.py @@ -87,6 +87,10 @@ import zipfile import traceback from zipfile import ZipFile +import erdr2pml +import ineptpdf +import k4mobidedrm + class DeDRMError(Exception): pass From a10d9a617ffc31925a8f83ca6836af78cbd792b4 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:34:56 +0100 Subject: [PATCH 11/19] Undefined name: Error() --> ValueError() --- dedrm_src/pycrypto_des.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/pycrypto_des.py b/dedrm_src/pycrypto_des.py index 80d7d65..286df9f 100644 --- a/dedrm_src/pycrypto_des.py +++ b/dedrm_src/pycrypto_des.py @@ -11,7 +11,7 @@ def load_pycrypto(): class DES(object): def __init__(self, key): if len(key) != 8 : - raise Error('DES improper key used') + raise ValueError('DES improper key used') self.key = key self._des = _DES.new(key,_DES.MODE_ECB) def desdecrypt(self, data): From 90335bb925a82f1de3ef065120d5b22e7cdb416e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:41:29 +0100 Subject: [PATCH 12/19] Undefined name: Define RegError --- dedrm_src/kindlekey.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dedrm_src/kindlekey.py b/dedrm_src/kindlekey.py index ec0adde..7e02b6c 100644 --- a/dedrm_src/kindlekey.py +++ b/dedrm_src/kindlekey.py @@ -40,6 +40,12 @@ from struct import pack, unpack, unpack_from import json import getopt +try: + RegError +except NameError: + class RegError(Exception): + pass + # Routines common to Mac and PC # Wrap a stream so that output gets flushed immediately From 8c08c67aa801bf9ea06dfc0300555d173ecb37e8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:47:04 +0100 Subject: [PATCH 13/19] Undefined name: import zipfix --- dedrm_src/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/__init__.py b/dedrm_src/__init__.py index ec4c621..ec98886 100644 --- a/dedrm_src/__init__.py +++ b/dedrm_src/__init__.py @@ -90,6 +90,7 @@ from zipfile import ZipFile import erdr2pml import ineptpdf import k4mobidedrm +import zipfix class DeDRMError(Exception): pass From 4e26b9d4e7b42c9f00d033a140199139d8b15208 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:55:42 +0100 Subject: [PATCH 14/19] Undefined name: errlog = '' --- dedrm_src/scriptinterface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/scriptinterface.py b/dedrm_src/scriptinterface.py index ec86b13..6154a2a 100644 --- a/dedrm_src/scriptinterface.py +++ b/dedrm_src/scriptinterface.py @@ -114,6 +114,7 @@ def decryptpdf(infile, outdir, rscpath): def decryptpdb(infile, outdir, rscpath): + errlog = '' outname = os.path.splitext(os.path.basename(infile))[0] + ".pmlz" outpath = os.path.join(outdir, outname) rv = 1 From 0955713cd6061ca30f65434f231e1461a8e3c447 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:58:03 +0100 Subject: [PATCH 15/19] Undefined name: errlog = '' --- dedrm_src/scriptinterface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/scriptinterface.py b/dedrm_src/scriptinterface.py index 6154a2a..8cadade 100644 --- a/dedrm_src/scriptinterface.py +++ b/dedrm_src/scriptinterface.py @@ -142,6 +142,7 @@ def decryptpdb(infile, outdir, rscpath): def decryptk4mobi(infile, outdir, rscpath): + errlog = '' rv = 1 pidnums = [] pidspath = os.path.join(rscpath,'pidlist.txt') From eddbefcf915009620896d5bf68e87ae6959272c0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:11:14 +0100 Subject: [PATCH 16/19] Undefined name: strip(uuidnum) --> uuidnum.strip() --- dedrm_src/kindlekey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/kindlekey.py b/dedrm_src/kindlekey.py index 7e02b6c..7b994ed 100644 --- a/dedrm_src/kindlekey.py +++ b/dedrm_src/kindlekey.py @@ -1308,7 +1308,7 @@ elif isosx: uuids = [] uuidnum = os.getenv('MYUUIDNUMBER') if uuidnum != None: - uuids.append(strip(uuidnum)) + uuids.append(uuidnum.strip()) cmdline = '/usr/sbin/ioreg -l -S -w 0 -r -c AppleAHCIDiskDriver' cmdline = cmdline.encode(sys.getfilesystemencoding()) p = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) From 0895aeb32370348c1e871af5b378df6a9f0a7f83 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:17:06 +0100 Subject: [PATCH 17/19] Undefined name: from ignoblekeygen import generate_key --- dedrm_src/utilities.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dedrm_src/utilities.py b/dedrm_src/utilities.py index c730607..c62b043 100644 --- a/dedrm_src/utilities.py +++ b/dedrm_src/utilities.py @@ -3,6 +3,8 @@ from __future__ import with_statement +from ignoblekeygen import generate_key + __license__ = 'GPL v3' DETAILED_MESSAGE = \ From b35f7775802ffd34a5e34546f18dd6f6cf40ea1f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:23:19 +0100 Subject: [PATCH 18/19] Focus only on legacy Python for now --- .github/workflows/Python_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 65215df..57b08ce 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -7,7 +7,7 @@ jobs: fail-fast: false matrix: os: [macos-latest] - python-version: [2.7, 3.8] + python-version: [2.7] # , 3.8] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From ce8538a2ca81c5e741647d724de9c5fca36db91b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 23 Jan 2020 13:24:45 +0100 Subject: [PATCH 19/19] Remove the unused rename_key() method --- obok_src/config.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/obok_src/config.py b/obok_src/config.py index ae4edc0..645c9e3 100644 --- a/obok_src/config.py +++ b/obok_src/config.py @@ -145,28 +145,6 @@ class ManageKeysDialog(QDialog): self.listy.clear() self.populate_list() - def rename_key(self): - if not self.listy.currentItem(): - errmsg = u"No {0} selected to rename. Highlight a keyfile first.".format(self.key_type_name) - r = error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), - _(errmsg), show=True, show_copy_button=False) - return - - d = RenameKeyDialog(self) - d.exec_() - - if d.result() != d.Accepted: - # rename cancelled or moot. - return - keyname = unicode(self.listy.currentItem().text()) - if not question_dialog(self, "{0} {1}: Confirm Rename".format(PLUGIN_NAME, PLUGIN_VERSION), u"Do you really want to rename the {2} named {0} to {1}?".format(keyname,d.key_name,self.key_type_name), show_copy_button=False, default_yes=False): - return - self.plugin_keys[d.key_name] = self.plugin_keys[keyname] - del self.plugin_keys[keyname] - - self.listy.clear() - self.populate_list() - def delete_key(self): if not self.listy.currentItem(): return