def cycle_logfile(logfile):
 logfile_old = (logfile + '.old')
 if os.path.exists(logfile):
  if os.path.exists(logfile_old):
   os.remove(logfile_old)
  os.rename(logfile, logfile_old)

def cycle_logfile ( logfile ) : logfile_old = ( logfile + '.old' ) if os . path . exists ( logfile ) : if os . path . exists ( logfile_old ) : os . remove ( logfile_old ) os . rename ( logfile , logfile_old )
rotate the old log files to <filename> .