diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index a9ad8f8..57b08ce 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -7,9 +7,9 @@ jobs: fail-fast: false matrix: os: [macos-latest] - python-version: [2.7, 3.8] + 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: @@ -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: | @@ -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=_,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 . --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 diff --git a/dedrm_src/__init__.py b/dedrm_src/__init__.py index cdd4e7b..ec98886 100644 --- a/dedrm_src/__init__.py +++ b/dedrm_src/__init__.py @@ -87,6 +87,11 @@ import zipfile import traceback from zipfile import ZipFile +import erdr2pml +import ineptpdf +import k4mobidedrm +import zipfix + class DeDRMError(Exception): pass 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 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 diff --git a/dedrm_src/kindlekey.py b/dedrm_src/kindlekey.py index ec0adde..7b994ed 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 @@ -1302,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) 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 = [] 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): diff --git a/dedrm_src/scriptinterface.py b/dedrm_src/scriptinterface.py index ec86b13..8cadade 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 @@ -141,6 +142,7 @@ def decryptpdb(infile, outdir, rscpath): def decryptk4mobi(infile, outdir, rscpath): + errlog = '' rv = 1 pidnums = [] pidspath = os.path.join(rscpath,'pidlist.txt') 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 = \ 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=""): 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, 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