catdatefile.py 300 Bytes
Newer Older
Antoine Catton's avatar
Antoine Catton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import os
import sys
import time
def catdatefile(args):
  directory = args[0]
  try:
    suffix = args[1]
  except IndexError:
    suffix = '.log'
  f = open(os.path.join(directory,
    time.strftime('%Y-%m-%d.%H:%M.%s') + suffix), 'aw')
  for line in sys.stdin.read():
    f.write(line)
  f.close()