Until I get to work the generic way of doing it, I will tell you a workaround.
I use the Processing plugin version 2.2.0-2 (I suggest you to use this version), which is installed in
/home/germap/.qgis2/python/plugins/ on my computer. You need to know this folder location, because you import the processing module from there.
Since you know the provider (
qgis) and the algorithm (
explodelines), you can look at
/home/germap/.qgis2/python/plugins/processing/algs/qgis/ to take the explode lines script name:
Explode.py This information allows you to import the algorithm directly to your Python standalone script.
So, open a Python console and copy the following script (I use GNU/Linux, so the environment variables are set by default, allowing me to import qgis and PyQt4 libraries in a breeze):
# Prepare the environment
from PyQt4.QtGui import *
from qgis.core import *
app = QApplication()
# Tell Python where you will get processing from
# Reference the algorithm you want to run
from processing.algs.qgis.Explode import *
alg = Explode()
# Set input and output
inLayer = QgsVectorLayer('/home/user/data/in.shp', 'input', 'ogr')
outLayer = '/home/user/data/out.shp'
# Run the algorithm
from processing.core.SilentProgress import SilentProgress
progress = SilentProgress()
If you don't get error messages, that's it. The output layer has been saved in the output path you specified (
Note: Regarding a generic way (i.e., calling algorithms by name), I've found some troubles that I need to solve before posting it. As soon as I get it to work, I'll post it.