old_contents: #!/usr/bin/env python
  import sys
  import subprocess
  import ConfigParser
  import os
  import traceback
  sys.path.append("../../")
  from TorCtl import TorUtil
  from TorCtl.TorUtil import plog
  from signal import signal, SIGTERM
  from sys import exit
  
  
  # exit code to indicate scan completion
  # make sure to update this in bwauthority_child.py as well
  STOP_PCT_REACHED = -9
  
  def main(argv):
    slice_num = 0 
    while True:
      plog('INFO', 'Beginning time loop')
      global p
      p = subprocess.Popen(["python", "bwauthority_child.py", argv[1], str(slice_num)])
      p.wait()
      if (p.returncode == 0):
        slice_num += 1
      elif (p.returncode == STOP_PCT_REACHED):
        plog('INFO', 'restarting from slice 0')
        slice_num = 0
      else:
        plog('WARN', 'Child process returned %s' % p.returncode)
  
  def sigterm_handler(signum, frame):
    if p:
      p.kill()
    exit()
  
  if __name__ == '__main__':
    signal(SIGTERM, sigterm_handler)
    try:
      main(sys.argv)
    except KeyboardInterrupt:
      p.kill()
      plog('INFO', "Ctrl + C was pressed. Exiting ... ")
      traceback.print_exc()
    except Exception, e:
      plog('ERROR', "An unexpected error occured.")
      traceback.print_exc()
  
new_contents: #!/usr/bin/env python
  from sys import argv as s_argv
  from sys import path
  from sys import exit
  from subprocess import Popen
  path.append("../../")
  from TorCtl.TorUtil import plog as plog
  from signal import signal, SIGTERM
  
  
  # exit code to indicate scan completion
  # make sure to update this in bwauthority_child.py as well
  STOP_PCT_REACHED = -9
  
  def main(argv):
    slice_num = 0 
    while True:
      plog('INFO', 'Beginning time loop')
      global p
      p = Popen(["python", "bwauthority_child.py", argv[1], str(slice_num)])
      p.wait()
      if (p.returncode == 0):
        slice_num += 1
      elif (p.returncode == STOP_PCT_REACHED):
        plog('INFO', 'restarting from slice 0')
        slice_num = 0
      else:
        plog('WARN', 'Child process returned %s' % p.returncode)
  
  def sigterm_handler(signum, frame):
    if p:
      p.kill()
    exit()
  
  if __name__ == '__main__':
    signal(SIGTERM, sigterm_handler)
    try:
      main(s_argv)
    except KeyboardInterrupt:
      p.kill()
      plog('INFO', "Ctrl + C was pressed. Exiting ... ")
    except Exception, e:
      plog('ERROR', "An unexpected error occured.")
  
subject: Clean up imports