Python lesson please

Dave Angel d at davea.name
Sun Nov 6 18:27:23 EST 2011


On 11/06/2011 06:10 PM, gene heskett wrote:
> On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine:
>
>> On 11/06/2011 01:14 PM, gene heskett wrote:
>>> Greetings experts:
>>>
>>> I just dl'd the duqu driver finder script from a link to NSS on /.,
>>> and fixed enough of the tabs in it to make it run error-free.  At
>>> least python isn't having a litter of cows over the indentation now.
>>>
>>> But it also runs instantly on linux.
>>>
>>> This line looks suspect to me:
>>>    rootdir = sys.argv[1]
>>>
>>> And I have a suspicion it is null on a linux box.
>>>
>>> How can I fix that best?
>>>
>>> Thanks.
>>>
>>> Cheers, Gene
>>
>> Nothing wrong with that line, assuming the user of the script happened
>> to provide an argument for rootpath.  Probably it should be preceded by
>> a a conditional:
>>
>>       if len(argv)<2:
>>              tell.user.that.she's.missing.the.rootdir.parameter
>>        else:
>>              rootdir = sys.argv[1]
>>              etc.
>>
>> What does the help text show when you run the script with the --help
>> argument?
>
> It has no --help:
> [root at coyote gene]# ./duqu-drivers-detect.py --help
> [root at coyote gene]#
>
> Sorry.
>
> Thanks&  Cheers, Gene


So is there any documentation?  If not, your first job is to guess what 
it's supposed to do, figure out if you care, and then document it.  In 
the process you'll probably find a few bugs.

First bug is it silently quits when you run it with no arguments. Is 
that true?  If so, figure out where it quits, since it clearly never 
reaches the line you quote.

Actually I'd probably start with the assumption that you might have 
messed up the tab expansion somewhere.  How did you expand the tabs? 
Perhaps by using the Linux expands utility?  Or did you do it manually?

-- 

DaveA



More information about the Python-list mailing list