Skip to content

Commit

Permalink
Add support for Python 2 on very old Windows versions
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrob committed Aug 2, 2022
1 parent 216ad28 commit 8b3323f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
18 changes: 7 additions & 11 deletions emailproxy.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,13 @@
import timeago
import webview


# TODO: pyoslog does not support Python 2.7; this is a hacky workaround
class pyoslog:
@staticmethod
def is_supported():
return False


sys.modules['pyoslog'] = pyoslog

# support Python 2 and Python 3; other modules are handled by `future`
if sys.platform == 'win32' and sys.version_info < (3, 0):
# note: this change fixes one issue with pystray, but a manual code edit is also required:
# line 349 of pystray/_util/win32.py needs editing from `except KeyError:` to
# `except (KeyError, AttributeError):` (see: https://github.com/moses-palmer/pystray/pull/128)
# noinspection PyUnresolvedReferences
del pystray._util.win32.LoadImage.errcheck # means we don't get an actual icon, but also no crash
try:
import configparser
except ImportError:
Expand Down Expand Up @@ -413,7 +409,7 @@ def start_redirection_receiver_server(token_request):
class LoggingWSGIRequestHandler(wsgiref.simple_server.WSGIRequestHandler):
def log_message(self, format_string, *args):
Log.debug('Local server auth mode (%s:%d): received authentication response' % (
parsed_uri.hostname, parsed_uri.port), *args)
parsed_uri.hostname, parsed_port), *args)

class RedirectionReceiverWSGIApplication:
def __call__(self, environ, start_response):
Expand Down
9 changes: 6 additions & 3 deletions requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
configobj
cryptography
pillow
cryptography; sys_platform != 'win32'
pillow; python_version >= '3.0'
pystray; python_version >= '3.0' # specify to avoid double requirement error with older pip versions (same below)
pywebview; sys_platform != 'win32' and python_version >= '3.0'
timeago
Expand All @@ -10,8 +10,11 @@ aenum; python_version < '3.0'
configparser2; python_version < '3.0'
future; python_version < '3.0'
pathlib2; python_version < '3.0'
pystray==0.17.2; python_version < '3.0'
pillow==5.3.0; python_version < '3.0'
pystray; sys_platform != 'darwin' and python_version < '3.0' # specific version needed for macOS
pystray==0.17.2; sys_platform == 'darwin' and python_version < '3.0' # specific version needed for macOS
pywebview==2.4; python_version < '3.0'
cryptography==2.4.2; sys_platform == 'win32' and python_version < '3.0' # specific version required for very old Windows versions

# provide the previously standard library module `asyncore`, removed in Python 3.12 (https://peps.python.org/pep-0594/)
pyasyncore; python_version >= '3.12'
Expand Down

0 comments on commit 8b3323f

Please sign in to comment.