[Qgis-developer] Processing scripts in stand-alone Python scripts

Anita Graser anitagraser at gmx.at
Fri Nov 27 06:53:47 PST 2015


On Fri, Nov 27, 2015 at 8:58 AM, Victor Olaya <volayaf at gmail.com> wrote:

> I think this must be related to the configuration of the plugins folder.
>
> The script provider reads scripts in the scripts folder, which is
> configured as an option. Maybe that setting is not available in your
> stand-alone script...since it is stored using QSettings. You can check
> it calling ScriptUtils.scriptsFolder()
>

​from processing.script.ScriptUtils import *
print ScriptUtils.scriptsFolder()

if run in stand-alone, returns a wrong folder:
​/home/agraser/temp/standaloneprocessing/processing/scripts
(/home/agraser/temp/standaloneprocessing is the location of my stand-alone
script)

​instead of the correct folder in the QGIS console:
u'/home/agraser/.qgis2/processing/scripts'.

Seems like we are getting closer to where the real issue is hiding. Imho it
makes little sense that the paths appear relative to the stand-alone
script's location.

Best wishes,
Anita






>
> I have added an option to add a folder manually to the scripts
> provider. So you can get the instance of the provider (as you do when
> listing its content), and call the addAlgorithmsFromFolder method to
> add your folder.
>
> See the commit in here,
>
>
> https://github.com/qgis/QGIS/commit/0a21d91be5ad788db3b58a568a2beed0d797e045
>
> Let me know if you have questions
>
> Cheers!
>
>
>
> 2015-11-26 23:43 GMT+01:00 Anita Graser <anitagraser at gmx.at>:
> >
> >
> > On Thu, Nov 26, 2015 at 11:17 PM, Luigi Pirelli <luipir at gmail.com>
> wrote:
> >>
> >> processing.alglist('script') to retrieve the list of commands with
> >> "script" string inside it's name or description
> >> e.g.
> >> processing.alglist('ogr')
> >> returns a lot of elements... if we get one of them
> >
> > --- >8 ---------------------------- snip
> >>
> >> if the list is is empty => no commands/scripts found with "script"
> >
> >
> > Thanks Luigi, but I'm not sure how this helps.
> >
> > scripts = Processing.getProviderFromName('scripts')
> > print scripts.algs
> >
> > returns a NON-empty list when run in the Python console but an empty list
> > when run in a stand-alone script.
> >
> > Some part of the initialization of the scripts provider seems to fail.
> >
> > Best wishes,
> > Anita
> >
> >
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151127/caa83bf0/attachment-0001.html>


More information about the Qgis-developer mailing list