Reply
Thread Tools
Posts: 58 | Thanked: 10 times | Joined on Dec 2009
#1
Hi,
I'm working on a OCR app.
Id like it to behave like this:
- disable autostart of camera app on lens open
- start camera app on button click
- listen to DCIM folder changes (with pyinotify) and on new file created close camera app, write last picture path to file, and use the path further in my application

It almost works. I'm having problems with stopping pyinotify.
I have a callback function which returns True (should stop the loop). I tried with notify.stop() also, but no effect. It caches the new file name, executes the callback function, but doesn't close the pyinotify, and the application freezes.

Here is my code:
Code:
class GetPic(pyinotify.ProcessEvent):
    def process_IN_CREATE(self, event):
	outFile = open('lastPic.txt', 'w')
	outFile.write(event.pathname)

class MainClass():
   .... some code here (not important for this problem)...
   def runOCR(self):  
        wm = pyinotify.WatchManager()
        notifier = pyinotify.Notifier(wm, GetPic())
	wm.add_watch('/home/user/MyDocs/DCIM', pyinotify.IN_CREATE)

        os.system('dbus-send --session --print-reply --dest=com.nokia.cameraui /com/nokia/cameraui com.nokia.cameraui.top_application')

	notifier.loop(callback=OnSave)
	notifier.stop()

def OnSave(notifier):	
    inFile = open('lastPic.txt','r')
    lastFile = inFile.read()   
    return True
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 10:49.