Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > problem with running os.path.walk()

Reply
Thread Tools

problem with running os.path.walk()

 
 
MalC0de
Guest
Posts: n/a
 
      10-13-2009
heya there,
where's the problem with the following code ? I couldn't see any
result while running as a script :


#!/usr/bin/python
import time
import os
def walker2(arg,dirname,filenames):
cutoff = time.time() - (arg * 24 * 60 * 60)
for filename in filenames :
stats = os.stat(dirname + os.sep + filename)
modified = stats[8]
if modified >= cutoff :
print dirname + os.sep + filename

os.path.walk('C:\\windows\\system',walker2,30)



if I have problem with it then let me know and if is possible please
fix it up .
thnx .
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      10-13-2009
En Tue, 13 Oct 2009 16:32:07 -0300, MalC0de <>
escribió:

> where's the problem with the following code ? I couldn't see any
> result while running as a script :
>
>
> #!/usr/bin/python
> import time
> import os
> def walker2(arg,dirname,filenames):
> cutoff = time.time() - (arg * 24 * 60 * 60)
> for filename in filenames :
> stats = os.stat(dirname + os.sep + filename)
> modified = stats[8]
> if modified >= cutoff :
> print dirname + os.sep + filename
>
> os.path.walk('C:\\windows\\system',walker2,30)
>
> if I have problem with it then let me know and if is possible please
> fix it up .


Because all files in your c:\windows\system directory are older than one
month?
os.walk is simpler to use; stats.st_mtime is less "magical" than stats[8];
and I'd use os.path.join(dirname, filename) instead of +os.sep+

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running,Running! audit2 Firefox 1 02-01-2008 09:27 PM
Running into MTU issues with VPN running on Cisco 7206VXR amit1017 Cisco 1 10-18-2007 01:03 PM
Problem Running Application on NetBeans 5.5 Problem!! ajaywadhwani@gmail.com Java 2 12-28-2006 05:02 PM
modify a long-running python script while it is running? Benjamin Rutt Python 2 12-20-2005 01:42 PM
I'm trying to network a deasktop running 98SE and a laptop running XP. Marc Computer Support 8 11-19-2003 03:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57