I am trying to make a simple piece of software that automatically makes a list based on the file contents of any newly inserted USB memory stick.
using ubuntu 14.04.
now using os.listdir() and glob.glob() work fine on their own...
however when using it with pyinotify, and getting the input_dir for the os.listdir() or glob.glob() from the event.pathname ... I just get a blank list every time...
tried concatenating strings to add single quotes, double quotes etc... to no avail.
here's a snippet of code
#!/usr/bin/python
#notifier setup
import pyinotify, os, glob
wm=pyinotify.WatchManager()
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self,event):
global path
path = event.pathname
usb_insertion()
def usb_insertion():
print glob.glob(path+"/*")
print "listdir", os.listdir(path)
handler=EventHandler()
notifier=pyinotify.Notifier(wm, handler)
wdd=wm.add_watch('/media', pyinotify.IN_CREATE, rec=True)
notifier.loop()