def get_protocolinfo(controller):
 try:
  protocolinfo_response = _msg(controller, 'PROTOCOLINFO 1')
 except:
  protocolinfo_response = None
 if ((not protocolinfo_response) or (str(protocolinfo_response) == 'Authentication required.')):
  controller.connect()
  try:
   protocolinfo_response = _msg(controller, 'PROTOCOLINFO 1')
  except stem.SocketClosed as exc:
   raise stem.SocketError(exc)
 stem.response.convert('PROTOCOLINFO', protocolinfo_response)
 if protocolinfo_response.cookie_path:
  _expand_cookie_path(protocolinfo_response, stem.util.system.pid_by_name, 'tor')
 if isinstance(controller, stem.socket.ControlSocket):
  control_socket = controller
 else:
  control_socket = controller.get_socket()
 if isinstance(control_socket, stem.socket.ControlPort):
  if (control_socket.get_address() == '127.0.0.1'):
   pid_method = stem.util.system.pid_by_port
   _expand_cookie_path(protocolinfo_response, pid_method, control_socket.get_port())
 elif isinstance(control_socket, stem.socket.ControlSocketFile):
  pid_method = stem.util.system.pid_by_open_file
  _expand_cookie_path(protocolinfo_response, pid_method, control_socket.get_socket_path())
 return protocolinfo_response

def get_protocolinfo ( controller ) : try : protocolinfo_response = _msg ( controller , 'PROTOCOLINFO 1' ) except : protocolinfo_response = None if ( ( not protocolinfo_response ) or ( str ( protocolinfo_response ) == 'Authentication required.' ) ) : controller . connect ( ) try : protocolinfo_response = _msg ( controller , 'PROTOCOLINFO 1' ) except stem . SocketClosed as exc : raise stem . SocketError ( exc ) stem . response . convert ( 'PROTOCOLINFO' , protocolinfo_response ) if protocolinfo_response . cookie_path : _expand_cookie_path ( protocolinfo_response , stem . util . system . pid_by_name , 'tor' ) if isinstance ( controller , stem . socket . ControlSocket ) : control_socket = controller else : control_socket = controller . get_socket ( ) if isinstance ( control_socket , stem . socket . ControlPort ) : if ( control_socket . get_address ( ) == '127.0.0.1' ) : pid_method = stem . util . system . pid_by_port _expand_cookie_path ( protocolinfo_response , pid_method , control_socket . get_port ( ) ) elif isinstance ( control_socket , stem . socket . ControlSocketFile ) : pid_method = stem . util . system . pid_by_open_file _expand_cookie_path ( protocolinfo_response , pid_method , control_socket . get_socket_path ( ) ) return protocolinfo_response
issues a protocolinfo query to a control socket .