LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2011, 01:25 PM   #1
bloodyscript
Member
 
Registered: Apr 2006
Distribution: Sabayon linux 5.1
Posts: 182

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


hi im new to python and im trying to execute a search in two directories into an ordered list [].

problem code
Code:
def search_entry(self, widget,):
            s1 = subprocess.Popen(['find /home/bludiescript/tv-shows', '-type f', '-name "*.mkv"'], shell=False, stdout=subprocess.PIPE)
            s2 = subprocess.Popen(['find /media/FreeAgent\ GoFlex\ Drive/tobins-media', '-type f' '-name "*.mkv"'],  stdin=s1.stdout, shell=False, stdout=subprocess.PIPE)
            s1.stdout.close()
            self.contents = "\n".join(self.list)
            s2.communicate(self.contents)
my search bar
Code:
self.search = gtk.Entry()
            self.search.connect("activate", self.search_entry,)
            self.box1.pack_start(self.search, True, True, 0)
            self.search.show()
full error message
Code:
Traceback (most recent call last):
  File "./search.py", line 18, in search_entry
    self.s1 = subprocess.Popen(['find /home/bludiescript/tv-shows', '-type f', '-name "*.mkv"'], shell=False, stdout=subprocess.PIPE)
  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
 
Old 09-23-2011, 05:30 PM   #2
claudelepoisson
LQ Newbie
 
Registered: Jul 2011
Location: Montreal, Quebec, Canada
Distribution: Arch Linux
Posts: 16

Rep: Reputation: 8
"-type" and "f" are separate parameters. same for "-name" and "*.mkv", which you do not need to quote inside the quotes.
 
Old 09-23-2011, 05:50 PM   #3
bloodyscript
Member
 
Registered: Apr 2006
Distribution: Sabayon linux 5.1
Posts: 182

Original Poster
Rep: Reputation: 15
thanks also find was part of the dir location i noticed. it stopped producing the error but now it seems like its only searching in the second find or s2 rather. i added print "%s" % self.list at the end of the search_entry to see if it just added the result to the list like i wanted but it didnt
 
Old 09-23-2011, 05:58 PM   #4
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Personally I always have trouble with subprocess arguments and recommend using the shlex module to split argument lists up - it makes things much easier of less prone to errors. It's even mentioned in the python standard documentation for python's subprocess module.
 
Old 09-23-2011, 09:49 PM   #5
bloodyscript
Member
 
Registered: Apr 2006
Distribution: Sabayon linux 5.1
Posts: 182

Original Poster
Rep: Reputation: 15
so i decided to try os.walk shlex kind of confused me and wasnt sure how to implement it with my code.

my code now
top = '/home/bludiescript/tv-shows'
for dirpath, dirnames, filenames in os.walk(top):
for filename in filenames:
print os.path.join(dirname, filename)

so now rather than getting zero results with find i get all the files in the directories below the specified dir is their a way that i can say link a get_text to os.walk so it will search the directory for the file i type in the text field
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding popen(), pipe(), etc. MTK358 Linux - General 2 06-25-2011 12:23 PM
read() on pipe returns -1 and errno set to 0 velemas Programming 2 12-18-2009 06:19 AM
how to pass pipe output to file command nickleus Linux - General 6 06-19-2008 06:18 AM
where do i get a bidirectional popen pipe? Thinking Programming 9 10-21-2005 07:42 AM
mutt says: "~/Mail/Inbox: No such file or directory (errno = 2)" realos Linux - General 1 08-01-2002 03:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration