Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | Xover | T265640 phe-tools: Match&Split bot is not running because of python2 deprecation in pywikibot | |||
Resolved | Xqt | T213287 Drop support of Python 2.7 | |||
Resolved | Xqt | T242120 Python 2 to 3 support request | |||
Resolved | Xqt | T216018 Add python3 support for stewardbots | |||
Resolved | Xqt | T216020 Add python3 support for SULWatcher |
Event Timeline
Change 562848 had a related patch set uploaded (by Xqt; owner: Xqt):
[labs/tools/stewardbots@master] [PY2to3] Enable SULWatcher with Python 3
Hi @Xqt - thanks for the patch!
I'm testing it and it looks like it's not working though. I keep seeing:
python3 /data/project/stewardbots/SULWatcher/SULWatcher.py Traceback (most recent call last): File "/data/project/stewardbots/SULWatcher/SULWatcher.py", line 22, in <module> from ircbot import SingleServerIRCBot ImportError: No module named 'ircbot'
What do you think this might be?
Thanks.
Done. The ircbot and irclib is extremely outdated 0.6.3 (2012) or earlier. Now we have 18.0. You have to install the package first. Python 3.6 is needed for the newest release. For older Pythons the right version will be installed with pip install irc.
Will they need to be installed for the whole Toolforge project or just doing pip/pip3 install <package_name> for tools.stewardbots work?
Thanks.
It depends from where is Python and its side package is installed. If the steward bots have their own Python environment pip install <package> will be enough. Try pip list or pip freeze to show the current installation
:-(
tools.stewardbots@tools-sgebastion-07:~$ pip freeze -bash: pip: command not found tools.stewardbots@tools-sgebastion-07:~$ pip3 freeze -bash: pip3: command not found
It looks like the bot is started on the job grid using jstart -N stewardbot -mem 2G /data/project/stewardbots/venv/bin/python2.7 /data/project/stewardbots/StewardBot/StewardBot.py, so the virtual environment that you need to run pip from is /data/project/stewardbots/venv. It is all python2 right now, so if you are going to try a python3 deployment you will need a new venv. Something like python3 -mvenv $HOME/venv-py3 would make you a new one.
Sorry I am not familiar with neither venv nor tool lab. The migrated scripts may run with both, Python 2.7 and 3.4+. Both need the irc package. The package version depends on the Python version installed but is selected automatically via pip. The newest irc lib needs Python 3.6.
MySQLdb/ MySQL-python do not support Python 3. They were replaced by mysqlclient as far as I could read.
Change 562848 merged by jenkins-bot:
[labs/tools/stewardbots@master] [PY2to3] Enable SULWatcher with Python 3
@Legoktm @Xqt I've applied the code kindly submitted by you two and I get the following error message:
Traceback (most recent call last): File "/data/project/stewardbots/SULWatcher/SULWatcher.py", line 22, in <module> from irc.client import nm_to_n ImportError: cannot import name 'nm_to_n'
Packages installed:
(venv-py3) tools.stewardbots@tools-sgebastion-07:~$ pip freeze importlib-metadata==1.4.0 importlib-resources==1.0.2 inflect==3.0.2 irc==17.1 jaraco.classes==2.0 jaraco.collections==2.1 jaraco.functools==2.0 jaraco.itertools==4.4.2 jaraco.logging==2.0 jaraco.stream==2.0 jaraco.text==3.2.0 more-itertools==8.1.0 pkg-resources==0.0.0 PyMySQL==0.9.3 pytz==2019.3 six==1.14.0 tempora==1.14.1 zipp==1.0.0
Seems there was a greater change in these 10 years.
from irc.client import NickMask def nm_to_n(nm): return NickMask(nm).nick
would be a way. I'll update it soon.
I'd assume not, as the whole point of the migration is that python2 shouldn't be used anymore. Python 2 should fail explicitly and quickly so we know that everything's actually been migrated properly.
Change 566591 had a related patch set uploaded (by Xqt; owner: Xqt):
[labs/tools/stewardbots@master] [bugfix] Define nm_to_n function
@MarcoAurelio: thanks for reviewing. I made a new patch to solve this bug. That function was dropped and removed in 2012.
The last patches are intended to work wit both releases. I'll submitt a new patch which removes all Python 2 stuff after that nd propose to test the new libraries irc/pymysql first.
Change 566601 had a related patch set uploaded (by Xqt; owner: Xqt):
[labs/tools/stewardbots@master] [PY3] Python 3 support only for SULWatcher.py
Change 566591 merged by jenkins-bot:
[labs/tools/stewardbots@master] [bugfix] Define nm_to_n function
Yes. I found a hint in the irc history that some methods are changed to property attributes [1]
The others are to be checked too.
[1] https://python-irc.readthedocs.io/en/latest/history.html Version 5.0
Change 569355 had a related patch set uploaded (by Melos; owner: Melos):
[labs/tools/stewardbots@master] SulWatcher:fix py3 migration
Change 569355 merged by jenkins-bot:
[labs/tools/stewardbots@master] SulWatcher:fix py3 migration
@Melos r/569355 didn't worked :-( Would it be possible to arrange some sort of live debugging on IRC one of this days to take a look at what's going on? Thanks!
It is working now after changing a database row. Let's keep this open for a while and see if it crashes (logs are sent together at sulwatcher.out) and if everything runs as expected, we can call this task resolved :-)
Change 570005 had a related patch set uploaded (by Melos; owner: Melos):
[labs/tools/stewardbots@master] SULWatcher: ignore encoding errors from irc stream
Change 570005 merged by jenkins-bot:
[labs/tools/stewardbots@master] SULWatcher: ignore encoding errors from irc stream
Change 566601 merged by jenkins-bot:
[labs/tools/stewardbots@master] [PY3] Python 3 support only for SULWatcher.py