Python lesson please

G

gene heskett

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
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene>
Most of the fear that spoils our life comes from attacking difficulties
before we get to them.
-- Dr. Frank Crane
 
S

Steven D'Aprano

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.

<raises eyebrow>

Presumably the script should be working. If it is known to be not
working, then you probably need to fix a lot more than just indentation.

If this is "pre-alpha, doesn't even compile" software, then good luck,
you'll need to read the source and understand it to make it work. It's
not sufficient to just get it to a point where you can say "Cool, it
compiles!" by fixing some indentation.

If this is supposed to be working, there's a reason why it's not working
for you. Perhaps you are trying to use it with the wrong version of
Python. Perhaps the download is corrupted. Fix those before mangling
indentation in random ways: start with a fresh, uncorrupted download.
Check that the md5 sum matches that provided by the download site
(assuming they provide one). Find out what version of Python is
supported, and use that.

This line looks suspect to me:
rootdir = sys.argv[1]

What makes you think that line is suspect? It looks fine to me.

And I have a suspicion it is null on a linux box.

This is Python, not bash. Sys arguments are not filled in with "null",
whatever you think "null" is. (The None built-in? The empty string?)

Have you tried giving the script an argument when you call it? If in
doubt, call it with "." (the current directory) as argument.

My wild guess is that you actually need to supply a meaningful directory
path before the script will do anything, and until then, it will silently
fail. Which is terrible design.

How can I fix that best?

If it's not broken, it doesn't need to be fixed. Don't make assumptions
about what code needs to be fixed based on nothing more than gut feeling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top