I am currently working on a QGIS plugin which depits node to node discreet flows. Let' say adaption of Tobler's Flow Mapper to QGIS.
Plugin currently tested and working under Windows. But not under Linux or MacOS X.
As far as I can figure, this is due to a path problem where user chooses the output shapefile location.
Here is what code look likes:
def OutputShp(self):
dlg = FlowMapperDialog()
fd = QtGui.QFileDialog(dlg)
global SaveShpName
global SaveShpDirectory
SaveShpName = fd.getSaveFileName(None, 'Shapefile(*.shp)', 'Type output shapefile name', '*.shp')
...
...some code...
...
SaveDirectory = os.path.realpath(SaveShpName)
flowpyv07.shapefilemaker(FlowType,str(SaveDirectory), str(SaveShpName),str(InputMatrixName),str(InputNodesName),str(combotext))
When I run it I get the following error:
Traceback (most recent call last):
File "/home/user/.qgis//python/plugins/FlowMapper/flowmapper.py", line 1346, in run
SaveDirectory = os.path.realpath(SaveShpName)
File "/usr/lib/python2.7/posixpath.py", line 358, in realpath if isabs(filename):
File "/usr/lib/python2.7/posixpath.py", line 53, in isabs return s.startswith('/')
AttributeError: 'QString' object has no attribute 'startswith'
Python version: 2.7.3 (default, Aug 1 2012, 05:27:35) [GCC 4.6.3]
QGIS version: 1.8.0-Lisboa Lisboa, exported
However, if I enter the "SaveDirectory" path manually in the code such as "/home/user/Documents/" it works like charm. Thus I think I cannot get the path correctly. Any suggestion is valuable since users regret if it does not work under Linux.
If needed, full source code and plugin is avaliable from the QGIS repo: http://plugins.qgis.org/plugins/FlowMapper/
No comments:
Post a Comment