Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qgis_process list raises exception if processing algorithm provider is activated #38862

Closed
stibu81 opened this issue Sep 18, 2020 · 5 comments · Fixed by #38900
Closed

qgis_process list raises exception if processing algorithm provider is activated #38862

stibu81 opened this issue Sep 18, 2020 · 5 comments · Fixed by #38900
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@stibu81
Copy link

stibu81 commented Sep 18, 2020

Set up:
Ubuntu 20.04 in docker (see Dockerfile below)
QGIS master from https://qgis.org/ubuntu-nightly, September 18th

When running qgis_process list , the following error appears:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/usr/share/qgis/python/plugins/processing/__init__.py", line 50, in classFactory
from processing.ProcessingPlugin import ProcessingPlugin
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 794, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/processing/ProcessingPlugin.py", line 48, in <module>
  from processing.gui.ConfigDialog import ConfigOptionsPage
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 794, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/processing/gui/ConfigDialog.py", line 57, in <module>
  from processing.gui.menus import defaultMenuEntries, menusSettingsGroup
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 794, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/share/qgis/python/plugins/processing/gui/menus.py", line 45, in <module>
  vectorMenu = iface.vectorMenu().title()
AttributeError: 'NoneType' object has no attribute 'vectorMenu'

../../src/core/qgsmessagelog.cpp:29 : (logMessage) [0ms] 2020-09-18T14:54:38 Couldn't load plugin 'processing' due to an error when calling its classFactory() method[1] Couldn't load plugin 'processing' due to an error when calling its classFactory() method

To reproduce, use the following docker container:

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
  apt-get install -y wget gpg tzdata  && \
  echo "deb https://qgis.org/ubuntu-nightly/ focal main" > /etc/apt/sources.list.d/qgis-nightly.list && \
  wget -qO - https://qgis.org/downloads/qgis-2020.gpg.key | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import && \
  chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg && \
  apt-get update

RUN apt-get install -y qgis

ENV QT_QPA_PLATFORM offscreen

RUN mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/QGIS && \
  echo "[PythonPlugins]\nprocessing=true" > ~/.local/share/QGIS/QGIS3/profiles/default/QGIS/QGIS3.ini

The error only occurs, when the last line is included. If not, there is no error, but the Python plugins are not listed.

@stibu81 stibu81 added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 18, 2020
@agiudiceandrea
Copy link
Contributor

Hi @stibus81, it seems to me this is a regression. The issue was probably introduced inadvertently with PR #38312 and in particular with commit bacf779

I cannot test by myself, but I think you can workaround the issue, waiting for a proper fix, substituting menus.py in your docker container with this patched version https://raw.githubusercontent.com/agiudiceandrea/QGIS/a4d7cca428c50413437131452852433b6bb285cc/python/plugins/processing/gui/menus.py in which I've removed some reference to iface reverting the above commit.

@stibu81
Copy link
Author

stibu81 commented Sep 19, 2020

Hi @agiudiceandrea
You are probably right about this being a regression, since the issue does not appear in QGIS 3.14. I switched to 3.16 because an algorithm that I am using has been implemented in C++. Since this means that I am not using any Python algorithms right now, I don't have an urgent pain right now.

Thanks nevertheless for the workaround. I'll give it a try next week and let you know whether it helped.

@gioman gioman added Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore labels Sep 19, 2020
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Sep 21, 2020
E.g. in qgis_process iface is None

Fixes qgis#38862
nyalldawson added a commit that referenced this issue Sep 21, 2020
E.g. in qgis_process iface is None

Fixes #38862
@agiudiceandrea
Copy link
Contributor

This is not needed anymore. A proper fix 772181b was merged in master.

I cannot test by myself, but I think you can workaround the issue, waiting for a proper fix, substituting menus.py in your docker container with this patched version https://raw.githubusercontent.com/agiudiceandrea/QGIS/a4d7cca428c50413437131452852433b6bb285cc/python/plugins/processing/gui/menus.py in which I've removed some reference to iface reverting the above commit.

@stibu81
Copy link
Author

stibu81 commented Sep 21, 2020

@agiudiceandrea @nyalldawson Thanks for the fix. It seems, it is not yet in the nightly build, so I copied menus.py from 772181b and this solved the problem for me. I'll try the nightly build again tomorrow.

@stibu81
Copy link
Author

stibu81 commented Sep 25, 2020

I tried with the current nightly build and the problem is solved. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants