[mythtv-users] User Job to rip subtitles from each program

Raymond Wagner raymond at wagnerrp.com
Fri Feb 3 20:47:52 UTC 2012


On 2/3/2012 15:32, Raymond Wagner wrote:
> On 2/3/2012 15:18, Doug Lytle wrote:
>> David Crawford wrote:
>>> if len(sys.argv) != 3:
>>      From someone with absolutely no Python experience, the line !=
>> typically means 'not equal to'.
>>
>> My guess is that it's looking for 3 command line options.
> Specifically, those three command line arguments _should_ be
> '/home/dave/uksub2srt/renamesrt.py','<chanid>', and'<starttime>'.
> However, he keeps manually running the python interpreter, rather than
> letting the hashbang at the top of the script do its job, resulting in
> the four arguments: 'python', '/home/dave/uksub2srt/renamesrt.py',
> '<chanid>', and'<starttime>'.

For reference, this is general programming knowledge, and not anything 
peculiar to Python.  It's standard POSIX behavior to include the 
executable name as the first argument when calling it.  It's standard 
command line parser behavior to ignore the first argument, specifically 
because it is the executable name.  As example, Myth's internal command 
line parser library starts parsing at the second argument (index 1).

https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythbase/mythcommandlineparser.cpp

As for the "hashbang", when you run an executable text file on POSIX 
compliant operating systems, the first thing it does is to read the 
first line for a special "#!".  When detects that, it means you are 
telling it specifically what interpreter to use to run the command.  The 
"#!/usr/bin/env python" I said to put at the top of this script means it 
should use the "env" command to find "python" executable in your search 
path, and use that to run the script.  I didn't supply the direct path, 
because different systems like to install python in different places, 
such as /usr/bin/python versus /usr/local/bin/python.


More information about the mythtv-users mailing list