簡體   English   中英

pygtk OSError:[Errno 2]沒有這樣的文件或目錄。 subprocess.Popen PIPE命令

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

我是python的新手,我正在嘗試創建一個搜索欄,使用兩個find命令只搜索2個目錄,並將結果輸出到有序列表[]中。

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)

我的搜索欄:

self.search = gtk.Entry()
            self.search.connect("activate", self.search_entry,)
            self.box1.pack_start(self.search, True, True, 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

分隔args列表中的所有參數:

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)

在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

第一個是你的原始代碼,它引發了python異常。 第二個運行正常,但“發現”抱怨因為我的系統上沒有“bludiescript / tv-shows”目錄。

你的意思是在第2行找到? 看起來好像找錯文件“罰款”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM