Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

it would be absolutely great if someone could help me with the following problem:

I have a simple Python-Plugin that starts another executable in a subprocess. From within this application (which can't be modified on a large scale) I want to start another python-script that shows some pois in QGIS. But the problem is, that this script doesn't seem to have access to the current QGIS instance (no qgis.utils.iface object).

Is there ay way to remember the QGis-instance object or access it by looking through the currently running processes?

Thanks a lot in advance! Kian

share|improve this question
1  
Can we ask what the other application is? –  Nathan W Dec 20 '12 at 12:54
    
Hi Nathan, it's a test scenario because we want to validate the usage of QGis by some of our products. Since our customers have various GIS in use it makes sense for us not rewrite code to adapt the same app to different GIS. –  Kian Dec 20 '12 at 19:28
add comment

1 Answer 1

As I don't know a lot of the details I'm just going of what I know has worked for me in the past. Disclaimer: Might not be the 100% correct way to do it but worked at the time

I don't think talking to QGIS directly will work, if some one knows how I would be happy to know.

What you need to do is build some kind of communication bridge that both applications can talk over. In the past I have used a shared memory approach, as we had limited ability to change the C application we needed to talk to. Python can do quite easily using the mmap.

enter image description here

import mmap
mem = mmap.mmap(0, 1024, 'ToQGISBlock')
while True:
   mem.readline()

Read up the mmap docs to see better examples http://docs.python.org/2/library/mmap.html

Of course the shared memory thing requires that your application is able to create and read shared blocks of memory (memory mapped files), without knowing your applications language it will be hard to comment on that aspect.

You could also use sockets which like most things in Python are dead easy. I have no experience with sockets so I'm not going to try and give an in depth example.

share|improve this answer
    
Dear Nathan, thanks so much for the detailed answer! Great great help! I'll try that and in case I succeed I'let you know. –  Kian Dec 21 '12 at 13:44
    
Uuups...post went away too soon: Want to add my best wishes for Christmas :-)) –  Kian Dec 21 '12 at 13:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.