code: def td_is_finished(tomodir):
      if not is_tomodir(tomodir):
          raise Exception('Supplied directory is not a tomodir!')
      if(os.path.isfile(tomodir + os.sep + 'config/config.dat') and
         os.path.isfile(tomodir + os.sep + 'rho/rho.dat') and
         os.path.isfile(tomodir + os.sep + 'grid/elem.dat') and
         os.path.isfile(tomodir + os.sep + 'grid/elec.dat') and
         os.path.isfile(tomodir + os.sep + 'exe/crmod.cfg') and
         os.path.isfile(tomodir + os.sep + 'mod/volt.dat')):
          crmod_is_finished = True
      else:
          crmod_is_finished = False
      if(os.path.isfile(tomodir + os.sep + 'grid/elem.dat') and
         os.path.isfile(tomodir + os.sep + 'grid/elec.dat') and
         os.path.isfile(tomodir + os.sep + 'exe/crtomo.cfg') and
         os.path.isfile(tomodir + os.sep + 'inv/inv.ctr') and
         os.path.isfile(tomodir + os.sep + 'inv/run.ctr') and
         os.path.isfile(tomodir + os.sep + 'mod/volt.dat')):
          with open(tomodir + os.sep + 'inv/run.ctr', 'r') as fid:
              lines = fid.readlines()
              crtomo_is_finished = False
              for line in lines[-5:]:
                  test_line = line.strip()
                  regex = re.compile('CPU')
                  result = regex.match(test_line)
                  if result is not None:
                      crtomo_is_finished = True
      else:
          crtomo_is_finished = False
      return crmod_is_finished, crtomo_is_finished