I would like to run a few small and simple Python scripts for QGIS (Mac) from "outside" of QGIS (e.g. Sublime Text). With outside I mean in this context, either the normal os command line (terminal.app) or even better, directly out of Sublime Text (text-editor), but definitely not via the inbuilt QGIS Python Console.
I've read through various tutorial e.g. http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications and I am able to get a reference to the QGIS app, but unfortunately not to qgis.utils.iface
or something else deeper. This little code snippet should for instance print out the name of the active layer ... here is what I have:
import sys
sys.path.append("/Applications/QGIS.app/Contents/Resources/python")
from qgis.core import *
import qgis.utils
print "helo" # console output: helo
QgsApplication.setPrefixPath("/Applications/QGIS.app/", True)
QgsApplication.initQgis()
print QgsApplication # console output: <class 'qgis.core.QgsApplication'>
print qgis.utils.iface # = console output: none
aLayer = qgis.utils.iface.activeLayer()
print aLayer.name()
QgsApplication.exitQgis()
I am just looking for a quick and easy way to shoot scripts out of a comfortable text-editor to QGIS.