nacika

Untitled

Feb 29th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import os
  2. import datetime
  3. import time
  4. import string
  5. import os
  6.  
  7. def get_epoctime_from_date(date):
  8.     #date='2007-09-01'
  9.     year=int(date.split('-')[0])
  10.     month=int(date.split('-')[1])
  11.     day=int(date.split('-')[2])
  12.     date_tap=datetime.date(year,month,day).timetuple ()
  13.     #print date_tap
  14.     epoc_time=time.mktime(date_tap)
  15.     #print epoc_time
  16.     return epoc_time
  17.    
  18.  
  19. total = {}
  20. for i in range(int((time.time()-1309359600)/86400)):
  21.     t = 1309359600+86400*i
  22.     tl = time.gmtime(t)
  23.     ts = "%d-%d-%d" % (tl[0], tl[1], tl[2])
  24.     total[ts] = 0
  25.  
  26. for searchpath, dirs, files in os.walk('/Volumes/Users/hoge/Downloads/[email protected]/stream'):
  27.     for i in files:
  28.         t = os.path.getmtime("/Volumes/Users/hoge/Downloads/[email protected]/stream/"+i)
  29.         tl = time.gmtime(t)
  30.         ts = "%d-%d-%d" % (tl[0], tl[1], tl[2])
  31.         total.setdefault(ts, 0)
  32.         total[ts] = str(int(total[ts])+1)
  33.  
  34. for i in total:
  35.     print "%s\t%s" % (i, total[i])
  36.     pass
Advertisement
Add Comment
Please, Sign In to add comment