- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 121
Description
I am opening an issue upon this suggestion by Email OAuth 2.0 Proxy author @simonrob from issue #34 thread where I asked this question:
One (strange) question: Would it be possible to port Email OAuth 2.0 Proxy to Python 2.7? I am asking because I have one Windows XP computer running 24/7 since 2006. and I'd like to run the proxy on that computer if possible. I have many specific programs (PCB design, CNC control, ...) because of which I am (on this computer) still using not only Window XP but Windows XP SP2 :-))
and the suggestion by author was:
I had a (very) quick look at what it would take to support Python 2.7. The changes are mostly superficial (module name differences; function signature changes, etc), but it is still a nontrivial task to be able to support both v2 and v3. I'll bear this in mind for potential future version. Please feel free to open an issue as a way to track this feature request.
I am sure there will be many more use-cases for running Email OAuth 2.0 Proxy with Python 2.x
Activity
simonrob commentedon Jul 10, 2022
I had a look at this just now, and have committed a minimal working version into the python2 branch.
You will need to install dependencies manually:
For macOS I also had to work around a dependency issue with pystray:
Many aspects of the proxy will probably not work with this version, and most of it is completely untested. A major issue is that the authentication popup (and also the local server auth option) do not work. However, by copying an existing configuration file that was already authenticated, I was able to get the proxy to log in to a Gmail account using Python 2.7.
I don't use Python 2, and am unlikely to have time to work on this any more, but it should be a good enough starting point to get things working. I'm happy to incorporate improvements too of course.
michaelstepner commentedon Jul 12, 2022
@simonrob FWIW, I used to maintain python 2.7 compatibility for my packages but I was persuaded by python3statement.org that the time has come where as a project maintainer I shouldn't expend effort on Python 2.7 support anymore.
simonrob commentedon Jul 12, 2022
I would normally agree, but given that the whole purpose of this project is to support clients/apps that have been obsoleted or made more challenging to use by the imposition of OAuth I'm inclined to be a little more accommodating here. Still, I don't intend to put much (if any) more effort into supporting Python 2 - the branch discussed here should be enough to use an account that has already been authenticated elsewhere via the proxy.
simonrob commentedon Jul 20, 2022
I've just updated this branch to fix the authorisation window popup and update
requirements.txt
to remove the need for any workarounds when installing dependencies. You should now be able to set up and use the proxy using Python 2 following the standard instructions.Local server auth mode and secure local connections (and connections to servers for which you don't have up-to-date certificates) will definitely not work. The same applies for any of the less essential features I haven't tested, such as starting at login, and full multi-platform support.
I'd be interested to hear how you get on.
chupocro commentedon Jul 21, 2022
Thank you very much! I will report how the program works with Python 2 + Windows XP as soon as I test it - probably on tuesday or wednesday.
chupocro commentedon Jul 27, 2022
Hi, I finally tested the Python2 branch on Windows XP SP2 computer and I am getting this error:
simonrob commentedon Jul 27, 2022
Please could you post the output of
python -m pip list
?chupocro commentedon Jul 27, 2022
These are the packages installed yesterday from
requirements.txt
into the new virtual environment where I am testing the proxy:simonrob commentedon Jul 27, 2022
Thanks. Do you still get this issue if you upgrade pystray? (
pip install pystray --upgrade
)chupocro commentedon Jul 27, 2022
That updated
pystray
from0.17.2
to0.19.4
but the problem is still the same - the output is now just slightly different:simonrob commentedon Jul 27, 2022
Ok - for the time being the proxy's GUI will not work until this is resolved, but you could try non-GUI mode with the local server auth option and see whether it works that way? (See this comment for instructions.)
simonrob commentedon Jul 27, 2022
...actually, ignore that - I forgot that local server auth mode will not work with Python 2. Next time I have access to an old Windows environment I'll take a look.
chupocro commentedon Jul 27, 2022
Maybe I've solved the problem with
ChangeWindowMessageFilterEx()
but there is another problem.According to this and this
ChangeWindowMessageFilterEx()
is missing in Windows XP.There is this code in
Lib\site-packages\pystray\_util\win32.py
which should catch the exception and return a dummy implementation ofChangeWindowMessageFilterEx()
always returning TRUE on Windows versions before Vista but theexcept
is not catchingAttributeError
exception:As a workaround I just commented out that code and the problem seems to be solved but the next problem is now:
BTW, in the meantime I uninstalled and reinstalled
setuptools
to avoid the warning according to these instructions and the version ofsetuptools
is now 44.1.1 instead of 45.0.0 as was before. The problem was becausesetuptools
must be installed withpip
9.x or above but although the version ofpip
in virtual environment was 20.3.4 everything was still installed with thepip
from outside of the virtual environment which is older.chupocro commentedon Jul 28, 2022
Proxy did run with
--no-gui
switch but this time I couldn't solve the problem with the certificates:I was using
local_address
property because I was accessing the proxy from the Eudora running in virtual machine on another computer.pip install certifi
didn't solve the problem, it installed version 2021.10.8 while in Python 3 the version was 2022.6.15Then I tried
pip install python-certifi-win32
and after that bothpip
and proxy stopped working with the identical output:I am not sure if that is related with this problem.
As for the GUI, after reading this anwser I solved the problem with
_imaging
by downgradingpillow
to 4.0.0, then I had to remove one more call ofChangeWindowMessageFilterEx()
(this time inLib\site-packages\pystray\win32.py
) and then there was an error:for which I still didn't find a solution.
simonrob commentedon Aug 2, 2022
I had another quick look at this, and wondered whether it wouldn't just be simpler to install Python 3.x? The latest version officially supported on Windows XP is 3.4, but there is a custom version of 3.6.15 as well. Would this be an easier route to allowing use of the proxy on this system?
simonrob commentedon Aug 2, 2022
I tried this branch in a Windows XP (SP3) virtual machine with Python 2.7.18 just now. After a bit of tweaking of both code and requirements I was able to get the proxy working, and successfully retrieved email from both O365 and Gmail.
The proxy's system tray aspect mostly works (the icon is incorrect, but the menu does show). As previously mentioned, authentication via the proxy's inbuilt popup window does not work, and having looked a little further there is essentially zero chance of getting this working without significant effort.
However, importing a configuration file from another device that has already authenticated works well. You can also use the
--local-server-auth
option, but will probably need to authenticate via the given link on another more modern device (because Google and Microsoft block older browsers), and then visit the resultinghttp:\\localhost
URL in a web browser on the Windows XP target.8b3323f has all the changes I made in order to get all this working (mostly just different dependency versions). This works around almost all of the issues you mentioned, but I also had to make a change to the pystray code in a similar way to yours – this is far harder to fix in the proxy itself, so it's easier just to make an edit to the imported module.
I also had install all of the files in this repository to fix certificate errors. Of course, I was happy to install arbitrary updates/registry files in a virtual machine, but you might be less willing. Your call, but I'd be interested to hear whether this works for you.
simonrob commentedon Nov 2, 2022
I'm going to close this issue for now, but the python2 branch will remain available with partial support as discussed above. Feel free to reopen if you make any further progress here.