On Fri, Nov 12, 2010 at 9:43 PM, Michael Stover <m_stover4381...@yahoo.com> wrote: > My apologies for my last email, admittedly I was more tired that I thought > as after re-reading it and the emails coming in, I found that I did not > provided "proper" information. > > 1. I have a script that is detecting multiple various bits of information of > a video file using MediaInfo and putting that information into a txt file > with the format of: > (Example:) > num_vid_track=? > num_aud_track=? > num_sub_track=? > > Granted that is only part of the information being obtained but it's all in > the same format. > I have been trying multiple ways of grabbing this information for re-use, > including using this snippet, suggested to me by fellow users of the #python > irc channel.. > > import shlex as shlex_ > from subprocess import Popen, PIPE > > def shell(args, input=None, stdout=PIPE, stderr=PIPE, shlex=False, > **kwargs): > """Gets the output of a command run in a subprocess. > > Arguments: > args: A sequence of strings, or a single string if shlex=True. > input: A string to be written to the process's stdin. > Any extra keyword arguments are forwarded to Popen. > > Returns: > A tuple of (stdout, stderr) > > >>> shell('basename /a/hello', shlex=True) > ('hello\n','') > """ > if shlex: > args = shlex_.split(args) > stdin = PIPE if input is not None else None > p = Popen(args, stdin=stdin, stdout=stdout, stderr=stderr, **kwargs) > return p.communicate(input=input) > > Then using a command line similar to: > p = subprocess.Popen(['foo', 'bar'], stdout=subprocess.PIPE); stdout, _ = > p.communicate() > > Where 'foo','bar' obviously is the program I am calling with its arguements. > The only issue is, I can barely understand the documentation I kept getting > pointed to for retrieving the information captured from stdout. Which is why > I went with another friends suggestion of outputting all of the information > to a text file. Sorry if this seems to have veered off course, but which > method would be more recommended to implement? So far I have been able to > write a different python script for a general conversion of videos from > multiple different formats to a single format my xbox 360 can read (with or > without is optional media update). > > Again sorry for my previous email, and thank you in advance for the > assistance and suggestions, > Mike > > > _______________________________________________ > Tutor maillist - tu...@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > >
It'll alll become clear soon danielson/grasshoppa. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor