StackStorm-Exchange/stackstorm-msexchange

The get_folder_by_name() method is deprecated

Closed this issue · 6 comments

When I do sensor troubleshooting

$ sudo /opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf --sensor-ref=msexchange.ItemSensor

I can see the error below

2018-02-21 15:40:29,548 ERROR [-] /opt/stackstorm/virtualenvs/msexchange/lib/python2.7/site-packages/exchangelib/folders.py:151: UserWarning: The get_folder_by_name() method is deprecated. Use "[f for f in self.walk() if f.name == name]" or "some_folder / 'Sub Folder'" instead, to find folders by name.

Looks like it's related to this change in exchangelib.

Short-term workaround would be to change requirements.txt to use something like:

exchangelib>=1.9.3,<=1.10.1

Longer-term fix is to re-work the use of get_folder_by_name() to use updated folder mgmt techniques

I followed the instructions and reload (sudo st2ctl reload --register-all):

(msexchange) docker@ubuntu-st2:/opt/stackstorm/virtualenvs/msexchange$ pip list | grep exchangelib
...
exchangelib (1.10.7)

but still getting this UserWarning: The get_folder_by_name() method is deprecated. Nvmd, it is just warning.

You need to use a version of exchangelib <= 1.10.1. Your system is running 1.10.7.

Running reload --register-all doesn't change the virtualenv. Normally virtualenv setup is only done on pack install. There is a command in the 'packs' pack to update the virtualenv. That should change the version of exchangelib installed.

It is a warning at this stage, but that method gets removed in the next version of exchangelib.

Shouldn't commands below do this ? This is what I did.

cd /opt/stackstorm/virtualenvs/msexchange
source bin/activate
cd /opt/stackstorm/packs/msexchange
pip install -r requirements.txt
~$ cat /opt/stackstorm/packs/msexchange/requirements.txt
exchangelib>=1.9.3,<=1.10.1

When you ran that pip command, what did it say? Did it refer to already installed packages? I don’t know what pip does when a higher version is already installed. I would have expected it to display some output

I have just merged an update to this pack that will pin requirements.txt. If you uninstall, then re-install the pack, it should set up the virtualenv with the right version for you (most likely 1.10.1).

This will get rid of that deprecation warning. Longer-term the code needs to be updated to use the new methods.