ajout mode "wfile.py" si appel via wfile.py : cherche qui tait l l'heure de modif
d'un fichier donn. darcs-hash:20000530223704-92525-08a8935cf85366105a6af41eb2b7caa9f2d57c1c.gz
This commit is contained in:
parent
23c52d5101
commit
56fb023099
1 changed files with 15 additions and 6 deletions
21
wwho.py
21
wwho.py
|
@ -1,10 +1,10 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# when-who, Sam K (2000)
|
|
||||||
|
|
||||||
import os,string,getopt,time,sys,struct
|
import os,string,getopt,time,sys,struct
|
||||||
""" usage : wwho [date] [-b secs (backwards)] [-p precision (sec/m/h/d)] [-l (last)]
|
""" usage : wwho [date] [-b secs (backwards)] [-p precision (sec/m/h/d)] [-l (last)]
|
||||||
[-a (all last msgs)] [-f wtmp_file] [-d (debug)]
|
[-a (all last msgs)] [-f wtmp_file] [-d (debug)]
|
||||||
DATE (2000 May 22 06:12:08)
|
DATE (2000 May 22 06:12:08)
|
||||||
|
|
||||||
|
wfile : idem, except : [-a (access)] FILE
|
||||||
"""
|
"""
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], "adlb:p:f:")
|
optlist, args = getopt.getopt(sys.argv[1:], "adlb:p:f:")
|
||||||
|
|
||||||
|
@ -26,12 +26,21 @@ for i in optlist :
|
||||||
if i[0] =='-p' : precision=float(i[1])
|
if i[0] =='-p' : precision=float(i[1])
|
||||||
if i[0] =='-f' : utmpF=i[1]
|
if i[0] =='-f' : utmpF=i[1]
|
||||||
if debug : print "Option found : "+repr(i)
|
if debug : print "Option found : "+repr(i)
|
||||||
|
|
||||||
|
if debug : print " argv[0] : %s" % sys.argv[0]
|
||||||
|
|
||||||
if not datesec :
|
if not datesec :
|
||||||
if date :
|
if date :
|
||||||
t=time.strptime(date,"%Y %b %d %H:%M:%S")
|
if string.lower(os.path.basename(sys.argv[0]))=="wfile.py" :
|
||||||
#we still have to guess the DaylightSsavingTime flag -> -1
|
datesec=os.path.getmtime(date) #modif time
|
||||||
t2=[ t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],-1]
|
if all_last : datesec=os.path.getatime(date) #access time
|
||||||
datesec = time.mktime(t2)
|
print " Chosen file Time : %s" \
|
||||||
|
%time.ctime(datesec)
|
||||||
|
else :
|
||||||
|
t=time.strptime(date,"%Y %b %d %H:%M:%S")
|
||||||
|
#we still have to guess the DaylightSsavingTime flag -> -1
|
||||||
|
t2=[ t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],-1]
|
||||||
|
datesec = time.mktime(t2)
|
||||||
else : datesec =time.time()
|
else : datesec =time.time()
|
||||||
|
|
||||||
def unpackstr(s, i=0):
|
def unpackstr(s, i=0):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue