From b1ae3f74f463ad1b6101004bea5400e9e1eee4b8 Mon Sep 17 00:00:00 2001 From: gryf Date: Wed, 17 Jun 2020 17:56:31 +0200 Subject: [PATCH] Get rid of environ_item function --- ebook_converter/constants_old.py | 3 +-- ebook_converter/polyglot/builtins.py | 6 ------ ebook_converter/utils/ipc/launch.py | 8 ++++---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/ebook_converter/constants_old.py b/ebook_converter/constants_old.py index 7ecb772..570248c 100644 --- a/ebook_converter/constants_old.py +++ b/ebook_converter/constants_old.py @@ -5,7 +5,6 @@ import locale import os import sys -from ebook_converter.polyglot.builtins import environ_item __appname__ = 'calibre' numeric_version = (4, 12, 0) @@ -40,7 +39,7 @@ is64bit = sys.maxsize > (1 << 32) isworker = any([os.getenv('CALIBRE_WORKER') or os.getenv('CALIBRE_SIMPLE_WORKER')]) if isworker: - os.environ.pop(environ_item('CALIBRE_FORCE_ANSI'), None) + os.environ.pop('CALIBRE_FORCE_ANSI', None) FAKE_PROTOCOL, FAKE_HOST = 'clbr', 'internal.invalid' VIEWER_APP_UID = 'com.calibre-ebook.viewer' EDITOR_APP_UID = 'com.calibre-ebook.edit-book' diff --git a/ebook_converter/polyglot/builtins.py b/ebook_converter/polyglot/builtins.py index 9ac26dd..1195b0c 100644 --- a/ebook_converter/polyglot/builtins.py +++ b/ebook_converter/polyglot/builtins.py @@ -20,12 +20,6 @@ def error_message(exc): return str(exc) -def environ_item(x): - if isinstance(x, bytes): - x = x.decode('utf-8') - return x - - def exec_path(path, ctx=None): ctx = ctx or {} with open(path, 'rb') as f: diff --git a/ebook_converter/utils/ipc/launch.py b/ebook_converter/utils/ipc/launch.py index fae4234..2a5eeaf 100644 --- a/ebook_converter/utils/ipc/launch.py +++ b/ebook_converter/utils/ipc/launch.py @@ -5,7 +5,6 @@ from ebook_converter.constants_old import isosx, isfrozen, filesystem_encoding from ebook_converter.utils.config import prefs from ebook_converter.ptempfile import PersistentTemporaryFile, base_dir from ebook_converter.utils.serialize import msgpack_dumps -from ebook_converter.polyglot.builtins import environ_item from ebook_converter.polyglot.binary import as_hex_unicode try: import win32process @@ -83,10 +82,11 @@ class Worker(object): @property def env(self): + __import__('pdb').set_trace() env = os.environ.copy() - env['CALIBRE_WORKER'] = environ_item('1') + env['CALIBRE_WORKER'] = '1' td = as_hex_unicode(msgpack_dumps(base_dir())) - env['CALIBRE_WORKER_TEMP_DIR'] = environ_item(td) + env['CALIBRE_WORKER_TEMP_DIR'] = td env.update(self._env) return env @@ -149,7 +149,7 @@ class Worker(object): except EnvironmentError: # cwd no longer exists origwd = cwd or os.path.expanduser('~') - env['ORIGWD'] = environ_item(as_hex_unicode(msgpack_dumps(origwd))) + env['ORIGWD'] = as_hex_unicode(msgpack_dumps(origwd)) _cwd = cwd if priority is None: priority = prefs['worker_process_priority']