Opened 14 years ago

Closed 13 years ago

#3145 closed bug (invalid)

Dash in plugin name causes unhelpful error message

Reported by: rehakv1 Owned by: borysiasty
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Python plugins and bindings Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

I encountered a problem with using a '-' sign (dash) in python plugin in 1.6 r14423. When I add my custom repository (http://www.tarsiusproject.org/qgis/plugins.xml) and try to install plugin called 'Dash Test' which contains 'dash-test' directory in 'dash-test.zip', QGIS raises error message that reads:

"The plugin is broken. Python said: invalid syntax"

If there is a technical reason for prohibiting dash in the plugin folder I think QGIS should emit more descriptive error message.

Change History (4)

in reply to:  description ; comment:1 by brushtyler, 14 years ago

Replying to rehakv1:

I encountered a problem with using a '-' sign (dash) in python plugin in 1.6 r14423. When I add my custom repository (http://www.tarsiusproject.org/qgis/plugins.xml) and try to install plugin called 'Dash Test' which contains 'dash-test' directory in 'dash-test.zip', QGIS raises error message that reads:

"The plugin is broken. Python said: invalid syntax"

You should rename your plugin folder and package to "dash_test" because the chars after the dash in the package name are used for release name or version (e.g "dash_test-dev.zip" or "dash_test-1.0.zip").Instead the folder name must be truncated before the dash (i.e. "dash_test" in both the above cases).

If there is a technical reason for prohibiting dash in the plugin folder I think QGIS should emit more descriptive error message.

The error message is for users, not for developers. IMHO users don't want to know why the package is broken.

in reply to:  1 ; comment:2 by rehakv1, 14 years ago

You should rename your plugin folder and package to "dash_test" because the chars after the dash in the package name are used for release name or version (e.g "dash_test-dev.zip" or "dash_test-1.0.zip").Instead the folder name must be truncated before the dash (i.e. "dash_test" in both the above cases).

Yes, I figured this out and renamed my plugin folder. I also removed the version number based on this observation. Is there any recomendation or best practice guide for plugin naming? I see that e.g. the plugin in Faunalia repo don't add version number to the zip file.

The error message is for users, not for developers. IMHO users don't want to know why the package is broken.

Sorry, but I don't think this a good reasoning. The error message "The plugin is broken. Python said: invalid syntax" has no meaning to a regular user. And the developer has no chance to find out what's wrong with the plugin. I spent more than hour reviewing my source code because I thought there was a syntax error in my Python code. If the error was "Invalid filename" or even better "Invalid filename - allowed characters are alphanumeric symbols and underscore" I would have fixed it in 5 minutes.

in reply to:  2 comment:3 by brushtyler, 14 years ago

Replying to rehakv1:

Yes, I figured this out and renamed my plugin folder. I also removed the version number based on this observation. Is there any recomendation or best practice guide for plugin naming? I see that e.g. the plugin in Faunalia repo don't add version number to the zip file.

We at Faunalia avoid dashes and release name: I think it's only useful to maintain available different versions of the same plugin.

I don't know if there's a guide, but you can ask in the dev ML.

The error message is for users, not for developers. IMHO users don't want to know why the package is broken.

Sorry, but I don't think this a good reasoning. The error message "The plugin is broken. Python said: invalid syntax" has no meaning to a regular user. And the developer has no chance to find out what's wrong with the plugin. I spent more than hour reviewing my source code because I thought there was a syntax error in my Python code. If the error was "Invalid filename" or even better "Invalid filename - allowed characters are alphanumeric symbols and underscore" I would have fixed it in 5 minutes.

You're right, today I've changed my opinion about this.

If there's an useful message, users can help developers to find the issue, otherwise this may be more difficult. The message is also useful to identify strange python plugin installer's behavior (if any).

comment:4 by borysiasty, 13 years ago

Resolution: invalid
Status: newclosed

As the message says, it's a Python syntax error, not a Qgis restriction. Python modules can't contain dashes and when you try to import this plugin (what is a python module in fact), Python raises the syntax error and Qgis only passes that message to the gui. I'm closing the ticket as I think Qgis shouldn't analyze and validate Python syntax :) Please reopen if you disagree.

In general, the module name (=the plugin directory name) must meet Python requirements, so can't contain dashes, dots etc. The zip file name must be either moduleName.zip or moduleName.anySuffix.zip The suffix allows you to keep a few plugin versions in one directory in the repo, for example: myplugin.stable.zip and myplugin.dev.zip; the latter sghould be marked as experimental.

They both will be installed under the same moduleName name (one covers another), depending on the experimental switch state in the Installer. So the user can easily test the dev version and revert to the stable one.

If you want be able to *install* different versions side by side, you must use different moduleNames. But please only do it if necessery and use _stable and _dev suffixes rather than particular numbers, otherwise users will be flooded by depreciated modules with no hope to update :)

Note: See TracTickets for help on using tickets.