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:
krempp 2000-05-31 00:37:04 +02:00
parent 23c52d5101
commit 56fb023099

21
wwho.py
View file

@ -1,10 +1,10 @@
#! /usr/bin/env python
# when-who, Sam K (2000)
import os,string,getopt,time,sys,struct
""" usage : wwho [date] [-b secs (backwards)] [-p precision (sec/m/h/d)] [-l (last)]
[-a (all last msgs)] [-f wtmp_file] [-d (debug)]
DATE (2000 May 22 06:12:08)
wfile : idem, except : [-a (access)] FILE
"""
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] =='-f' : utmpF=i[1]
if debug : print "Option found : "+repr(i)
if debug : print " argv[0] : %s" % sys.argv[0]
if not datesec :
if date :
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)
if string.lower(os.path.basename(sys.argv[0]))=="wfile.py" :
datesec=os.path.getmtime(date) #modif time
if all_last : datesec=os.path.getatime(date) #access time
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()
def unpackstr(s, i=0):