All pastes #565670 Raw Edit

Chaos

public python v1 · immutable
·published 2007-06-14 02:50 UTC
rendered paste body
import os, sys, timewarntime = 7 * (24*60*60) # Daysnow = time.time()nextweek = now + warntimefor file in os.listdir(sys.argv[1]):  if file[-3:] != "crt":    continue  crt = open(os.path.join(sys.argv[1], file), "r")  for line in crt.readlines():    if line.find("Not After") != -1:      tokens = line.strip().split(": ")      expire = time.mktime(time.strptime(tokens[1], "%b %d %H:%M:%S %Y %Z"))      if (expire <= now):        print "%s has expired" % file      elif (expire <= nextweek):        print "%s is going to expire in %d days" % (file, int((now-expire)/24*60*60))      else:        print "%s hasn't expired" % file