def read_pid_file(filename):
 try:
  (pid, port) = open(filename, 'r').readlines()
  (pid, port) = (int(pid), int(port))
 except ValueError:
  try:
   (pid, port) = (int(open(filename, 'r').read()), None)
  except ValueError:
   (pid, port) = (None, None)
 return (pid, port)

def read_pid_file ( filename ) : try : ( pid , port ) = open ( filename , 'r' ) . readlines ( ) ( pid , port ) = ( int ( pid ) , int ( port ) ) except ValueError : try : ( pid , port ) = ( int ( open ( filename , 'r' ) . read ( ) ) , None ) except ValueError : ( pid , port ) = ( None , None ) return ( pid , port )
reads a pid file and returns the contents .