(interface, ssid, security, index=-1, password=None,
                        sudo_password=None)
Adds |ssid| to the list of preferred networks on |interface|.

  If Python is not running as root and sudo_password is not supplied an
  authorization dialog will appear.

  Args:
    interface: the interface to add the preference to.
    ssid: the SSID of the network.
    security: the security type of the network, must be in _SECURITY_TYPES.
    index: optional, the index in the network list to store the network.
      Defaults to -1, which is the end of the list.
    password: an optional password for the network to store in the keychain.
    sudo_password: optional password to get sudo access.

  Raises:
    PreferenceAdditionError: preference could not be added. Exception message
      is the stderr.
    BadSecurityTypeError: specified security type is not valid.
Adds |ssid| to the list of preferred networks on |interface|.
Adds |ssid| to the list of preferred networks on |interface| .
def AddPreferredNetwork(interface, ssid, security, index=-1, password=None,
                        sudo_password=None):
  """Adds |ssid| to the list of preferred networks on |interface|.

  If Python is not running as root and sudo_password is not supplied an
  authorization dialog will appear.

  Args:
    interface: the interface to add the preference to.
    ssid: the SSID of the network.
    security: the security type of the network, must be in _SECURITY_TYPES.
    index: optional, the index in the network list to store the network.
      Defaults to -1, which is the end of the list.
    password: an optional password for the network to store in the keychain.
    sudo_password: optional password to get sudo access.

  Raises:
    PreferenceAdditionError: preference could not be added. Exception message
      is the stderr.
    BadSecurityTypeError: specified security type is not valid.
  """
  security = security.upper()
  if security not in _SECURITY_TYPES:
    raise BadSecurityTypeError

  args = [_NETWORK_SETUP, '-addpreferredwirelessnetworkatindex', interface,
          ssid, str(index), security]
  if password:
    args.append(password)

  _, stderr, rc = gmacpyutil.RunProcess(args, sudo=bool(sudo_password),
                                        sudo_password=sudo_password)
  if rc:
    raise PreferenceAdditionError(stderr)
def AddPreferredNetwork ( interface , ssid , security , index = - 1 , password = None , sudo_password = None ) : security = security . upper ( ) if security not in _SECURITY_TYPES : raise BadSecurityTypeError args = [ _NETWORK_SETUP , '-addpreferredwirelessnetworkatindex' , interface , ssid , str ( index ) , security ] if password : args . append ( password ) _ , stderr , rc = gmacpyutil . RunProcess ( args , sudo = bool ( sudo_password ) , sudo_password = sudo_password ) if rc : raise PreferenceAdditionError ( stderr )