开发者

pygtk OSError: [Errno 2] No such file or directory. subprocess.Popen PIPE command

I'm new to python and I'm trying to make a search bar that searches only 2 directories using two find commands and output the results into an ordered list [].

def search_entry(self, widget,):
            s1 = subprocess.Popen(['find /home/bludiescript/tv-shows', '-type f'], shell=False, stdout=subprocess.PIPE)
            s2 = subprocess.Popen(['find /media/FreeAgent\ GoFlex\ Drive/tobins-media', '-type f'],  stdin=s1.stdout, shell=False, stdout=subprocess.PIPE)
            s1.stdout.close()
            self.contents = "\n".join(self.list)
            s2.communicate(self.contents)

My search bar:

self.search = gtk.Entry()
            self.search.connect("activate", self.search_entry,)
            self.box1.pack_start(self.search, True, Tru开发者_运维技巧e, 0)
            self.search.show()

errormsg:

File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory


Separate all the arguments in the args list:

s1 = subprocess.Popen(['find','/home/bludiescript/tv-shows', '-type','f'], shell=False, stdout=subprocess.PIPE)
s2 = subprocess.Popen(['find','/media/FreeAgent\ GoFlex\ Drive/tobins-media', '-type', 'f'],  stdin=s1.stdout, shell=False, stdout=subprocess.PIPE)

OUTPUT on MINE

>>> import subprocess
>>> s1 = subprocess.Popen(['find /home/bludiescript/tv-shows', '-type f'], shell=False, stdout=subprocess.PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1201, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
>>> s1 = subprocess.Popen(['find','/home/bludiescript/tv-shows', '-type','f'], shell=False, stdout=subprocess.PIPE)
>>> find: `/home/bludiescript/tv-shows': No such file or directory

The first is your original code and it raises the python exception. The second runs correctly but "find" complains because I do not have a "bludiescript/tv-shows" directory on my system.


Did you mean find on line 2? it looks like it is erroring on finding the file "fine"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜