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

Luigi Pirelli luipir at gmail.com
Thu Nov 26 14:17:34 PST 2015


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

OGR default------------------------------------------>quickosm:ogrdefault

I've the command name "quickosm:ogrdefault" then

processing.alghelp("quickosm:ogrdefault")

if the list is is empty => no commands/scripts found with "script"

cheers

Luigi Pirelli

**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS:
https://www.packtpub.com/application-development/mastering-qgis
**************************************************************************************************


On 26 November 2015 at 14:44, Anita Graser <anitagraser at gmx.at> wrote:
> HI Victor,
>
> On Thu, Nov 26, 2015 at 1:12 PM, Victor Olaya <volayaf at gmail.com> wrote:
>>
>> does Processing.getAlgorithm("script:helloworld") work in a normal
>> QGIS Python console?
>
>
> Yes it does.
>
>> Just in case, the name of the script is the name of the file (without
>> the extension)
>>
>> Maybe you can try
>> Processing.alghelp("script") to get the name of
>> available algorithms from the script provider
>
>
> Is alghelp() really correct? Even in the Python console, I only get errors
>
> processing.alghelp("scripts")
> Algorithm not found
> Processing.alghelp("script")
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
> AttributeError: class Processing has no attribute 'alghelp'
>
> Best wishes,
> Anita
>
>
>
>
>>
>>
>> Hope this helps
>>
>>
>>
>> 2015-11-26 11:06 GMT+01:00 Anita Graser <anitagraser at gmx.at>:
>> > Hi,
>> >
>> > I'm trying to run Processing scripts in a stand-alone Python script. The
>> > examples available online for calling default, e.g. QGIS algorithms,
>> > work
>> > fine but when I try to access a script instead, it cannot be found, i.e.
>> > getAlgorithm() returns None.
>> >
>> > Am I missing something or is this a bug?
>> >
>> > # Prepare the environment
>> > import sys
>> > from qgis.core import QgsApplication
>> > from PyQt4.QtGui import QApplication
>> > app = QApplication([])
>> > QgsApplication.setPrefixPath("/usr", True)
>> > QgsApplication.initQgis()
>> >
>> > # Prepare processing framework
>> > sys.path.append('/home/agraser/.qgis2/python/plugins')
>> > from processing.core.Processing import Processing
>> > Processing.initialize()
>> >
>> > print Processing.getAlgorithm("qgis:creategrid") # works
>> > print Processing.getAlgorithm("script:helloworld") # doesn't work
>> >
>> > # Exit applications
>> > QgsApplication.exitQgis()
>> > QApplication.exit()
>> >
>> >
>> > Thanks and best wishes,
>> > Anita
>> >
>> >
>> > _______________________________________________
>> > Qgis-developer mailing list
>> > Qgis-developer at lists.osgeo.org
>> > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list