Should it be more like this?<div><br></div><div><div>#!/usr/bin/env python</div><div><br></div><div>import os</div><div>from MythTV import MythBE, findfile</div><div>be = MythBE()</div><div>prog = be.getRecording(<chanid>, <starttime>)</div>
<div><br></div><div>oldbase = prog.basename.rsplit('.',1)[0]</div><div>newbase = prog.formatPath('...').rsplit('.',1)[0]</div><div>sg = findfile(prog.basename, prog.storagegroup)</div><div>if sg is None:</div>
<div> raise Exception('file not found')</div><div><br></div><div>import sys</div><div>if len(sys.argv) != 3:</div><div> chanid, starttime = sys.argv[1:3]</div><div><br></div><div>from MythTV import System</div>
<div>ccextractor = System(path="/home/dave/uksub2srt/uksub2srt.py")</div><div>ccextractor('-i', os.path.join(sg.dirname, prog.basename),</div><div> '-o', '/home/subtitles/{0}.srt'.format(newbase))</div>
<div><br></div><div>for f in os.listdir(sg.dirname):</div><div> if not (f.startswith(oldbase) and f.endswith('srt')):</div><div> continue</div><div> os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,</div>
<div>newbase+'.'+f.split('.',1)[1]))</div><br><div class="gmail_quote">On 3 February 2012 01:49, Raymond Wagner <span dir="ltr"><<a href="mailto:raymond@wagnerrp.com">raymond@wagnerrp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And... a bit of python jumble...<br>
<br>
<br>
> #!/usr/bin/env python<br>
<br>
This needs to go at the top of the file... good.<br>
<div class="im"><br>
> import os<br>
> from MythTV import MythBE, findfile<br>
> be = MythBE()<br>
> prog = be.getRecording(<chanid>, <starttime>)<br>
<br>
</div>When you look up the command line arguments for an application, usually<br>
required options are seen in diamond braces (<>). I was going for the<br>
same thing here. You need to give the getRecording() method the chanid<br>
and starttime of the recording you want it to find.<br>
<div class="im"><br>
> oldbase = prog.basename.rsplit('.',1)[0]<br>
> newbase = prog.formatPath('...').rsplit('.',1)[0]<br>
> sg = findfile(prog.basename, prog.storagegroup)<br>
> if sg is None:<br>
> raise Exception('file not found')<br>
<br>
<br>
> for f in os.listdir(sg.dirname):<br>
> if not (f.startswith(oldbase) and f.endswith('srt')):<br>
> continue<br>
> os.rename(os.path.join(sg.dirname, f), os.path.join(sg.dirname,<br>
> newbase+'.'+f.split('.',1)[1]))<br>
<br>
</div>This was supposed to rename the potential several resultant files coming<br>
out of `mythccextractor`. Since you're not using `mythccextractor`,<br>
<div class="im"><br>
> from MythTV import System<br>
> ccextractor = System(path="/home/dave/uksub2srt/uksub2srt.py")<br>
> ccextractor('-i', os.path.join(sg.dirname, prog.basename),<br>
> '-o', '/home/subtitles/{0}.srt'.format(newbase))<br>
<br>
</div>this down here was supposed to replace it. Additionally, unless you're<br>
trying to limit certain modules to certain scopes, either to keep the<br>
namespace clean or because that scope may never be entered and there not<br>
be any need to import it, it's better to do your imports at the top of<br>
the file just so you know where to look for them.<br>
<div class="im"><br>
> import sys<br>
> if len(sys.argv) != 3:<br>
> chanid, starttime = sys.argv[1:3]<br>
<br>
</div>You can't do anything until you get your recording from the backend, and<br>
you can't do that until you know what chanid and starttime you want the<br>
information for. Pulling that information out of your command line<br>
variables at the end of the script isn't going to do you any good.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a><br>
<a href="http://www.mythtv.org/mailman/listinfo/mythtv-users" target="_blank">http://www.mythtv.org/mailman/listinfo/mythtv-users</a><br>
</div></div></blockquote></div><br></div>