Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python lesson please

40 views
Skip to first unread message

gene heskett

unread,
Nov 6, 2011, 1:14:43 PM11/6/11
to pytho...@python.org
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

Dave Angel

unread,
Nov 6, 2011, 3:21:12 PM11/6/11
to gene heskett, pytho...@python.org
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?

--

DaveA

Cameron Simpson

unread,
Nov 6, 2011, 3:34:29 PM11/6/11
to gene heskett, pytho...@python.org
On 06Nov2011 13:14, gene heskett <ghes...@wdtv.com> 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.

That line collects the first command line argument. sys.argv is the
command line; argv[0] is the command name, argv[1] the first argument
and so forth.

Also, if there is no first argument then trying to access argv[1] will
raise an IndexError exception, not return a null value.

If you're this new to python, note that easy debugging statements can be
written:

print >>sys.stderr, "the value of foo is", foo

and so forth.

Perhaps more relevantly:

If you have unmangled a lot of tabs, remember that control flow is
indentation based in python, and you may have broken some logic.
(For this reason a number of us set our editors to work only in spaces).

Anyway, while changing:

statement1
statement2

into:

statement1
statement2

will usually make python complain, changing:

if some test here:
statement1
statement2

into:

if some test here:
statement1
statement2

just means that statement2 is no longer inside the if-statement, and
elicit no compaints. But will elicit bugs!

Cheers,
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads
and ban radars I'll be the first in line......AMCN

gene heskett

unread,
Nov 6, 2011, 6:10:03 PM11/6/11
to d...@davea.name, pytho...@python.org
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@coyote gene]# ./duqu-drivers-detect.py --help
[root@coyote gene]#

Sorry.

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>
Expedience is the best teacher.

Dave Angel

unread,
Nov 6, 2011, 6:27:23 PM11/6/11
to gene heskett, pytho...@python.org
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

David Riley

unread,
Nov 6, 2011, 6:54:46 PM11/6/11
to pytho...@python.org
On Nov 6, 2011, at 3:34 PM, Cameron Simpson wrote:

> Perhaps more relevantly:
>
> If you have unmangled a lot of tabs, remember that control flow is
> indentation based in python, and you may have broken some logic.
> (For this reason a number of us set our editors to work only in spaces).

I would absolutely check this first. I can't count the number of programs I've screwed up in difficult-to-detect ways because I've converted from tabs to spaces incorrectly. It's how I've finally learned to let a program/script do it for me, because Python is the first language I've used with significant leading whitespace.

- Dave

Steven D'Aprano

unread,
Nov 6, 2011, 9:54:16 PM11/6/11
to
On Sun, 06 Nov 2011 13:14:43 -0500, gene heskett wrote:

> 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.



--
Steven

Peter Otten

unread,
Nov 7, 2011, 4:00:02 AM11/7/11
to pytho...@python.org
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?

Are you talking about this one?

https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns.py

With a current checkout I don't get any tab-related (nor other) errors, so I
would prefer to run the script as-is. Also, the README clearly states that
you have to invoke it with

python DuquDriverPatterns.py ./directoryOfMalware

and the line you are quoting then puts the value "./directoryOfMalware" into
the rootdir variable.

If you want to normalize the code to 4-space indents I recomment that you
use

http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py

On Ubuntu (and probably any other Debian-based distro) you'll find a version
of that in

/usr/share/doc/python2.6/examples/Tools/scripts/reindent.py

or similar once you've installed the python-examples package.

gene heskett

unread,
Nov 7, 2011, 6:22:39 AM11/7/11
to pytho...@python.org
On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:

> 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?
>
> Are you talking about this one?
>
> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns
> .py

Yes. My save as renamed it, still has about 30k of tabs in it. But I
pulled it again, using the 'raw' link, saved it, no extra tabs.

But it still doesn't work for linux. My python is 2.6.6

> With a current checkout I don't get any tab-related (nor other) errors,
> so I would prefer to run the script as-is. Also, the README clearly
> states that you have to invoke it with
>
> python DuquDriverPatterns.py ./directoryOfMalware
>
> and the line you are quoting then puts the value "./directoryOfMalware"
> into the rootdir variable.

If only it would... Using this version, the failure is silent and instant.
Besides, the malware could be anyplace on the system. But it needs to skip
/dev since it hangs on the midi tree, /mnt and /media because they are not
part of the running system even if disks are mounted there.

> If you want to normalize the code to 4-space indents I recomment that
> you use
>
> http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py

Got it, where does it normally live? I apparently have a python-2.6.6
install.

> On Ubuntu (and probably any other Debian-based distro) you'll find a
> version of that in
>
PCLos is rpm based, lots of mandriva stuff in it.

> /usr/share/doc/python2.6/examples/Tools/scripts/reindent.py
>
Path does not exist. Ends at /usr/share/doc
from there I have:
gene@coyote doc]$ ls|grep python
gimp-python-2.6.11/
gnome-python-gconf-2.28.1/
gnome-python-gnomeprint-2.32.0/
gnome-python-gtksourceview-2.32.0/
libxml2-python-2.7.8/
python-2.6.6/
python3-3.2.1/
python3-docs-3.2.1/
python-cairo-1.10.0/
python-configobj-4.7.2/
python-decorator-3.3.1/
python-docs-2.6.6/
python-enchant-1.5.3/
python-gobject-2.28.6/
python-gpgme-0.1/
python-gtksourceview-2.10.0/
python-libxml2dom-0.4.7/
python-lxml-2.2.8/
python-markupsafe-0.9.3/
python-notify-0.1.1/
python-paramiko-1.7.6/
python-paste-1.7.4/
python-pkg-resources-0.6c11/
python-psyco-1.6/
python-pybluez-0.18/
python-pycrypto-2.3/
python-pygments-1.3.1/
python-pytools-2011.3/
python-pyxml-0.8.4/
python-rhpl-0.212/
python-sexy-0.1.9/
python-simpletal-4.2/
python-sympy-0.6.7/
python-utmp-0.8/

The python-2.6.6 and 3.2.1 directories only contain a README.mdv

> or similar once you've installed the python-examples package.

On PCLos it doesn't even exist in the repo's.

Good links, thank you.

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>
"Elvis is my copilot."
-- Cal Keegan

Andreas Perstinger

unread,
Nov 7, 2011, 8:14:05 AM11/7/11
to pytho...@python.org
On 2011-11-07 12:22, gene heskett wrote:
> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
>> Are you talking about this one?
>>
>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns
>> .py
>
> Yes. My save as renamed it, still has about 30k of tabs in it. But I
> pulled it again, using the 'raw' link, saved it, no extra tabs.
>
> But it still doesn't work for linux. My python is 2.6.6

Go to the directory where you've downloaded the file and type:

python DuquDriverPatterns.py .

What output do you get?

Bye, Andreas

Dave Angel

unread,
Nov 7, 2011, 8:30:15 AM11/7/11
to gene heskett, pytho...@python.org
On 11/07/2011 06:22 AM, gene heskett wrote:
> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
> <SNIP>
>> Are you talking about this one?
>>
>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns
>> .py
>
> Yes. My save as renamed it, still has about 30k of tabs in it. But I
> pulled it again, using the 'raw' link, saved it, no extra tabs.
>
> But it still doesn't work for linux. My python is 2.6.6
>
To start with, what's the md5 of the file you downloaded and are
testing? I get c4592a187f8f7880d3b685537e3bf9a5
from md5sum. If you get something different, one of us changed the
file, or you got it before today.

The whole tab issue is a red-herring in this case. But I don't see how
you can find 30k tabs in a thousand lines. And if I were going to detab
it, I'd pick 4 spaces, so the code doesn't stretch across the page.

> <SNIP>
>> python DuquDriverPatterns.py ./directoryOfMalware
>>
>> and the line you are quoting then puts the value "./directoryOfMalware"
>> into the rootdir variable.
> If only it would... Using this version, the failure is silent and instant.
> Besides, the malware could be anyplace on the system. But it needs to skip
> /dev since it hangs on the midi tree, /mnt and /media because they are not
> part of the running system even if disks are mounted there.
>
First, run it on the current directory, and it should list the files in
that directory:

I ran it in the directory I unzipped it into, so there are two files,
the README and the source file itself.

$ python DuquDriverPatterns.py .
Scanning ./README:
No match for pattern #0 on file named: README
No match for pattern #1 on file named: README
No match for pattern #2 on file named: README

etc.

The only way I can see to get NO output is to run it on an empty directory:
$mkdir junk
$ python DuquDriverPatterns.py junk

As for skipping certain directories, we can deal with that as soon as
you get proper behavior for any subtree of directories.

Have you tried adding a print ("Hello World " + rootdir) just before the

for root, subFolders, files in os.walk(rootdir):

line ? Or putting a print len(files) just after it (indented, of
course) ?

--

DaveA

Peter Otten

unread,
Nov 7, 2011, 9:15:53 AM11/7/11
to pytho...@python.org
gene heskett wrote:

> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
>
>> 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?
>>
>> Are you talking about this one?
>>
>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns
>> .py
>
> Yes. My save as renamed it, still has about 30k of tabs in it. But I
> pulled it again, using the 'raw' link, saved it, no extra tabs.
>
> But it still doesn't work for linux. My python is 2.6.6

Maybe the browser messes up things. Try installing git and then make a
clone:

$ git clone git://github.com/halsten/Duqu-detectors

>> With a current checkout I don't get any tab-related (nor other) errors,
>> so I would prefer to run the script as-is. Also, the README clearly
>> states that you have to invoke it with
>>
>> python DuquDriverPatterns.py ./directoryOfMalware
>>
>> and the line you are quoting then puts the value "./directoryOfMalware"
>> into the rootdir variable.
>
> If only it would... Using this version, the failure is silent and
> instant.

The actual code which comprises only the last 30 lines of the script looks
like it is written by a newbie. Try replacing the bare except: with
something noisy along the lines of

except Exception as e:
print e
continue

> Besides, the malware could be anyplace on the system. But it needs to
> skip /dev since it hangs on the midi tree, /mnt and /media because they
> are not part of the running system even if disks are mounted there.

I don't think the script is meant to find malware on a running system.
Rather you would mount a suspicious harddisk and pass the mountpoint to the
script. Of course I'm only guessing...

>> or similar once you've installed the python-examples package.
>
> On PCLos it doesn't even exist in the repo's.

Maybe it's in python's srpm, or in a python-dev.rpm or similar.
If all else fails you can download the source distribution from python.org
at

http://www.python.org/download/releases/2.6.7/


gene heskett

unread,
Nov 7, 2011, 11:30:16 AM11/7/11
to pytho...@python.org
On Monday, November 07, 2011 10:38:32 AM Andreas Perstinger did opine:

> On 2011-11-07 12:22, gene heskett wrote:
> > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
> >> Are you talking about this one?
> >>
> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatt
> >> erns .py
> >
> > Yes. My save as renamed it, still has about 30k of tabs in it. But I
> > pulled it again, using the 'raw' link, saved it, no extra tabs.
> >
> > But it still doesn't work for linux. My python is 2.6.6
>
> Go to the directory where you've downloaded the file and type:
>
> python DuquDriverPatterns.py .
>
> What output do you get?

Well now, I'll be dipped. It scanned that directory, took it perhaps 15
minutes, without finding anything. So I gave it two dots & its munching
its way through the ../Mail/inbox now. Why the hell can't it be given a
valid absolute path without editing it directly into the rootdir =
statement?

This may be a usable tool, but I think that before it was committed to a
daily cron script, we would need some history as to where to look for such
shenanigans as its certainly not fast enough to turn it loose to scan the
whole system on a daily basis. This on a quad core 2.1Ghz phenom, 4 gigs
of dram.

And I just found one of its Achilles heels, it is now stuck on a pipe file
at /home/gene/.kde4/share/apps/kaffeine/dvbpipe:
prw------- 1 gene gene 0 Sep 24 18:50 dvbpipe.m2t|

And using no cpu.

I was going to ctl+c it but this is where, after several such, that it took
the machine down yesterday. But it appears as only one process to htop (I
keep a copy of it running as root here) and that killed it clean, no crash.

So, it needs an exception (or likely several) of file types to stay away
from, starting with pipes like the above. But I am not the one to carve
that code as I have NDI how to go about writing a check stanza for that
condition in python.

Perhaps winderz does not have 'pipe' files so the authors never got caught
out on this? The only windows experience I have is the copy of xp that was
on the lappy I bought back in 2005 or so to take with me when I am on the
road (I am a broadcast engineer who gets sent here and there to "put out
the fires" when the station is off the air. Despite being retired for 9
years now at 77 yo, my phone still rings occasionally)
I went straight from amigados-3.2 to redhat-5.0 in the late '90's,
bypassing windows completely. I built the redhat machine from scratch.
The lappy's xp, used only for warranty testing, got overwritten by mandriva
2008 when the warranty had expired.

You could call me anti-M$ I think. :)

> Bye, Andreas

Thanks for listening, Andreas.

Now I wonder how to get a message back to the authors that its broken in at
least two aspects...

gene heskett

unread,
Nov 7, 2011, 11:40:12 AM11/7/11
to d...@davea.name, pytho...@python.org
On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine:
Back on the list..
> On 11/07/2011 06:22 AM, gene heskett wrote:
> > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine:
> > <SNIP>
> >
> >> Are you talking about this one?
> >>
> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte
> >> rns .py
> >
> > Yes. My save as renamed it, still has about 30k of tabs in it. But I
> > pulled it again, using the 'raw' link, saved it, no extra tabs.
> >
> > But it still doesn't work for linux. My python is 2.6.6
>
> To start with, what's the md5 of the file you downloaded and are
> testing? I get c4592a187f8f7880d3b685537e3bf9a5

[root@coyote Download]# md5sum DuquDriverPatterns.py
c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours.

> from md5sum. If you get something different, one of us changed the
> file, or you got it before today.
>
> The whole tab issue is a red-herring in this case. But I don't see how
> you can find 30k tabs in a thousand lines. And if I were going to detab
> it, I'd pick 4 spaces, so the code doesn't stretch across the page.

Down toward the bottom of the file, the tab indentations were as high as 33
leading tabs per line. Each stanza of the data was tab indented 2
additional tabs from the one above it in the original file. 30k was
perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess.

> > <SNIP>
> >
> >> python DuquDriverPatterns.py ./directoryOfMalware
> >>
> >> and the line you are quoting then puts the value
> >> "./directoryOfMalware" into the rootdir variable.
> >
> > If only it would... Using this version, the failure is silent and
> > instant. Besides, the malware could be anyplace on the system. But
> > it needs to skip /dev since it hangs on the midi tree, /mnt and
> > /media because they are not part of the running system even if disks
> > are mounted there.
>
> First, run it on the current directory, and it should list the files in
> that directory:
>
> I ran it in the directory I unzipped it into, so there are two files,
> the README and the source file itself.
>
> $ python DuquDriverPatterns.py .
> Scanning ./README:
> No match for pattern #0 on file named: README
> No match for pattern #1 on file named: README
> No match for pattern #2 on file named: README
>
> etc.
>
> The only way I can see to get NO output is to run it on an empty
> directory: $mkdir junk
> $ python DuquDriverPatterns.py junk
>
> As for skipping certain directories, we can deal with that as soon as
> you get proper behavior for any subtree of directories.
>
> Have you tried adding a print ("Hello World " + rootdir) just before the
>
> for root, subFolders, files in os.walk(rootdir):
>
> line ? Or putting a print len(files) just after it (indented, of
> course) ?

No, I did try to print the value of rootdir though, indented the same, and
got a null printout, not even a line feed.

Thanks Dave.

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>
The older I grow, the less important the comma becomes. Let the reader
catch his own breath.
-- Elizabeth Clarkson Zwart

Dave Angel

unread,
Nov 7, 2011, 1:14:50 PM11/7/11
to gene heskett, pytho...@python.org
What program are you using to read the file and support that claim?
Neither emacs nor gedit shows more than one leading tab on any line I
looked. And if you set tabs to 4 columns, the file looks quite
reasonable. Doing a quick scan I see max of 5 tabs on any single line,
and 1006 total.


maxtabs = 0
totaltabs = 0
f = open("DuquDriverPatterns.py", "r")
for line in f:

cline = line.replace("\t", "")
tabs = len(line) - len(cline)
if tabs:
print tabs
maxtabs = max(maxtabs, tabs)
totaltabs += tabs

print "max=", maxtabs
print "total=", totaltabs




>>> <SNIP>
>>>
>>>> python DuquDriverPatterns.py ./directoryOfMalware
>>>>
>>>> and the line you are quoting then puts the value
>>>> "./directoryOfMalware" into the rootdir variable.
>>>
>>> If only it would... Using this version, the failure is silent and
>>> instant.

The only way I've been able to make it "silent and instant" was to give
it the name of an empty directory, or a typo representing no directory
at all.
If you had put the print I suggested, it would at least print the words
"Hello World". Since it did not, you probably didn't actually add the
line where I suggested.

> Thanks Dave.
>
> Cheers, Gene

In another message you said it doesn't work on absolute file paths. But
it does. You can replace any relative directory name with the absolute
version, and it won't change the behavior. I suspect you were caught up
by a typo for the absolute path string.


--

DaveA

gene heskett

unread,
Nov 7, 2011, 3:00:49 PM11/7/11
to d...@davea.name, pytho...@python.org
On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine:
vim. But remember, this first one started out as a copy/paste from the
firefox-7.0.1 screen.

> Neither emacs nor gedit shows more than one leading tab on any line I
> looked. And if you set tabs to 4 columns, the file looks quite
> reasonable. Doing a quick scan I see max of 5 tabs on any single line,
> and 1006 total.

I have no tabs left in the operative code, the python interpreter was
having a cow if even one was in that last 30-35 lines of code.
>
>
> maxtabs = 0
> totaltabs = 0
> f = open("DuquDriverPatterns.py", "r")
> for line in f:
>
> cline = line.replace("\t", "")
> tabs = len(line) - len(cline)
> if tabs:
> print tabs
> maxtabs = max(maxtabs, tabs)
> totaltabs += tabs
>
> print "max=", maxtabs
> print "total=", totaltabs
>
> >>> <SNIP>
> The only way I've been able to make it "silent and instant" was to give
> it the name of an empty directory, or a typo representing no directory
> at all.
>
[...]
> >> line ? Or putting a print len(files) just after it (indented, of
> >> course) ?
> >
> > No, I did try to print the value of rootdir though, indented the same,
> > and got a null printout, not even a line feed.

Indented the same as the rootdir statement itself, which in python would
seem to make it immediately sequential to the roodir = statement.

> If you had put the print I suggested, it would at least print the words
> "Hello World". Since it did not, you probably didn't actually add the
> line where I suggested.
>
> > Thanks Dave.
> >
> > Cheers, Gene
>
> In another message you said it doesn't work on absolute file paths. But
> it does. You can replace any relative directory name with the absolute
> version, and it won't change the behavior. I suspect you were caught up
> by a typo for the absolute path string.

I am gene, running as gene, what could be wrong with giving it /home/gene
as the argument?

I have another dir in /home/amanda, that I build the alpha and beta amanda
stuff in. Let me try that. And again, this works but I forgot about the
.ccache directory, so it will take a while to finish.

Now, as a python lesson to me, I will do a blink compare between the 2
files this evening & see what I munged. ATM, I am working on a gunstock
for as long as my feet and back can stand the standing, so sitting here is
a 'break' from that. Yeah, I occasionally call myself a JOAT. ;-)

Thanks Dave.

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>
Experience is that marvelous thing that enables you recognize a mistake
when you make it again.
-- Franklin P. Jones

Terry Reedy

unread,
Nov 7, 2011, 7:23:50 PM11/7/11
to pytho...@python.org
On 11/7/2011 11:30 AM, gene heskett wrote:

> Perhaps winderz does not have 'pipe' files so the authors never got caught
> out on this?

Last I know, Windows not only had no pipe files but also no real
in-memory pipes. Maybe one or both of those has changed.

--
Terry Jan Reedy

gene heskett

unread,
Nov 7, 2011, 7:36:46 PM11/7/11
to pytho...@python.org
On Monday, November 07, 2011 07:34:05 PM Terry Reedy did opine:
Sheesh.. How the heck do you get anything done on winderz then. :(

Answer not needed as they regularly reinvent the wheel because everything
has to be self contained, poorly IMO. Most of their wheels ride a bit
rough. ;)

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>
I believe that professional wrestling is clean and everything else in
the world is fixed.
-- Frank Deford, sports writer

Cameron Simpson

unread,
Nov 7, 2011, 11:59:00 PM11/7/11
to gene heskett, pytho...@python.org, d...@davea.name
On 07Nov2011 15:00, gene heskett <ghes...@wdtv.com> wrote:
| On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine:
| > On 11/07/2011 11:40 AM, gene heskett wrote:
| > > Down toward the bottom of the file, the tab indentations were as high
| > > as 33 leading tabs per line. Each stanza of the data was tab
| > > indented 2 additional tabs from the one above it in the original
| > > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely
| > > reasonable guess.
| >
| > What program are you using to read the file and support that claim?
|
| vim. But remember, this first one started out as a copy/paste from the
| firefox-7.0.1 screen.

I don't suppose you had autoident turned on?

I hate using cu/paste to fetch data; _always_ use a "download" link, or
use the browser's "save page as" facility.

But still, if your MD5 checksums now match...

Cheers,
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Footnotes that extend to a second page are an abject failure of design.
- Bringhurst, _The Elements of Typographic Style_

gene heskett

unread,
Nov 8, 2011, 1:29:46 AM11/8/11
to Cameron Simpson, pytho...@python.org, d...@davea.name
On Tuesday, November 08, 2011 12:53:20 AM Cameron Simpson did opine:

> On 07Nov2011 15:00, gene heskett <ghes...@wdtv.com> wrote:
> | On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine:
> | > On 11/07/2011 11:40 AM, gene heskett wrote:
> | > > Down toward the bottom of the file, the tab indentations were as
> | > > high as 33 leading tabs per line. Each stanza of the data was
> | > > tab indented 2 additional tabs from the one above it in the
> | > > original file. 30k was perhaps a poor SWAG, but 10 to 15k seems
> | > > an entirely reasonable guess.
> | >
> | > What program are you using to read the file and support that claim?
> |
> | vim. But remember, this first one started out as a copy/paste from
> | the firefox-7.0.1 screen.
>
> I don't suppose you had autoident turned on?
>
I think it is. I gave up turning it off long ago because it was always on
on the next launch. Today I've forgotten how to turn it off. Like hitting
oneself in the head with a hammer, it feels so good when you stop. :)

> I hate using cu/paste to fetch data; _always_ use a "download" link, or
> use the browser's "save page as" facility.

Which would have saved all the html codes too, this code was being
displayed in a window of the main window.

> But still, if your MD5 checksums now match...

Not on that file, but on the next pull it was, and works now. And on the
first file, the blink compare disclosed I had some indentation wrong, and
that there was a lowercase b in front of all the opening double quotes used
that I didn't get originally. I have no clue what this:
b"hex data" means to python.

> Cheers,


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>
To love is good, love being difficult.

Chris Angelico

unread,
Nov 8, 2011, 1:42:20 AM11/8/11
to pytho...@python.org
On Tue, Nov 8, 2011 at 5:29 PM, gene heskett <ghes...@wdtv.com> wrote:
> Not on that file, but on the next pull it was, and works now.  And on the
> first file, the blink compare disclosed I had some indentation wrong, and
> that there was a lowercase b in front of all the opening double quotes used
> that I didn't get originally.  I have no clue what this:
>        b"hex data" means to python.

That's the repr() of a Bytes string (as opposed to a Unicode string)
in Python 3. If that's your only issue, I'd say you have it working
fine under Python 3; if there are other problems, try running it under
Python 2.7.

ChrisA
0 new messages