コード例 #1
0
 def start(self, network):
     self.stop()
     profile = network.profile
     if not 'encryption_type' in network.profile:
         raise WicdError('Network profile does not specify encryption type')
     encryption_type = network.profile['encryption_type']
     template_class = self.template_manager.get_template(encryption_type)
     if not template_class:
         raise WicdError('Template type %s does not exist' % encryption_type)
     values = {}
     for requirement in template_class.require:
         if requirement.name in profile:
             values[requirement.name] = str(profile[requirement.name])
         else:
             raise WicdError('Missing required value %s' % requirement.name)
     values['essid'] = network.essid
     values['scan'] = 0
     log('wpa_supplicant values', values)
     wpa_conf_name = network.bssid.replace(':', '').lower()
     wpa_conf_name += 'vpb'
     self.create_configuration_file(wpa_conf_name, template_class, values)
     pathname = os.path.join(wpath.networks, wpa_conf_name)
     self.wpa_supplicant = misc.run([
         misc.find_program_in_path('wpa_supplicant'), '-i', 
         self.interface_name, '-D', 'wext', '-c', pathname
     ], return_fileobject=True)
コード例 #2
0
 def start(self):
     self.stop()
     cmd = '%s -1 %s' % (misc.find_program_in_path('dhclient'),
                         self.interface_name)
     self.dhclient = misc.run(cmd,
                             include_stderr=True,
                             return_fileobject=True)
コード例 #3
0
 def get_ip(self):
     """ Get the IP address of the interface.
     Returns:
     The IP address of the interface in dotted quad form.
     """
     cmd = "%s %s" % (misc.find_program_in_path("ifconfig"), self.interface_name)
     output = misc.run(cmd)
     return misc.run_regex(InterfaceRegexPatterns.ip, output)
コード例 #4
0
 def _slow_is_up(self, ifconfig=None):
     """ Determine if an interface is up using ifconfig. """
     cmd = [misc.find_program_in_path("ifconfig"), self.interface_name]
     output = misc.run(cmd)
     lines = output.split('\n')
     if len(lines) < 5:
         return False
     for line in lines[1:4]:
         if line.strip().startswith('UP'):
             return True   
     return False
コード例 #5
0
 def _do_scan(self):
     self.up()
     cmd = [misc.find_program_in_path("iwlist"), self.interface_name, "scan"]
     results = misc.run(cmd)
     networks = results.split("   Cell ")
     access_points = []
     for cell in networks:
         if "ESSID:" in cell:
             entry = self._parse_access_point(cell)
             if entry is not None:
                 access_points.append(entry)
     return access_points
コード例 #6
0
 def _find_dhclient_binary():
     return misc.find_program_in_path('dhclient')
コード例 #7
0
 def up(self):
     ''' Put the interface up. '''
     cmd = [misc.find_program_in_path('ifconfig'), self.interface_name, 'up']
     misc.run(cmd)
コード例 #8
0
 def set_gateway(self, new_ip):
     ''' Sets the netmask of the current network interface. '''
     cmd = '%s add default gateway %s %s' % (misc.find_program_in_path('route'), 
                         new_ip, self.interface_name)
     misc.run(cmd)
コード例 #9
0
 def set_netmask(self, new_ip):
     ''' Sets the netmask of the current network interface. '''
     cmd = '%s %s netmask %s' % (misc.find_program_in_path('ifconfig'), 
                         self.interface_name, new_ip)
     misc.run(cmd)
コード例 #10
0
 def down(self):
     ''' Put the interface down. '''
     cmd = [misc.find_program_in_path('ifconfig'), 
            self.interface_name, 'down']
     misc.run(cmd)
コード例 #11
0
 def down(self):
     """ Put the interface down. """
     cmd = [misc.find_program_in_path("ifconfig"), self.interface_name, "down"]
     misc.run(cmd)
コード例 #12
0
 def up(self):
     """ Put the interface up. """
     cmd = [misc.find_program_in_path("ifconfig"), self.interface_name, "up"]
     misc.run(cmd)
コード例 #13
0
 def set_gateway(self, new_ip):
     """ Sets the netmask of the current network interface. """
     cmd = "%s add default gateway %s %s" % (misc.find_program_in_path("route"), new_ip, self.interface_name)
     misc.run(cmd)
コード例 #14
0
 def set_netmask(self, new_ip):
     """ Sets the netmask of the current network interface. """
     cmd = "%s %s netmask %s" % (misc.find_program_in_path("ifconfig"), self.interface_name, new_ip)
     misc.run(cmd)