def deactivate(self):
		""" Deactivates this config. """

		pid = self.get_pid()
		if pid is None:
			return
		subprocess.check_call(["kill", pid])
Example #2
0
 def activate(self):
     """
     Connects to the network as configured in this scheme.
     """
     if platform.system() == "Darwin":
         net_ssid = ""
         net_pass = ""
         if "wireless-essid" in self.options.keys():
             net_ssid = self.options['wireless-essid']
         elif "wpa-ssid" in self.options.keys():
             net_pass = self.options['password']
             net_ssid = self.options['wpa-ssid']
         else:
             net_pass = self.options['password']
             net_ssid = self.options['ssid']
     
         response = ""
         response = subprocess.check_output(['networksetup','-setairportnetwork','en0',net_ssid, net_pass])
         if "Failed to join network" in response:
             print("Could not connect to Wi-Fi network!")
         else:
             print("Wi-Fi Connection established!")
     else:
         if self.encryption_type == 'wpa2-eap':
             response = subprocess.check_output(['wpa_supplicant', '-B', '-i', self.interface, '-Dwext', '-c', '/etc/wpa_supplicant_enterprise.conf'])
             if ("Authentication succeeded" in response) or ("EAP authentication completed successfully" in response):
                 print('Wi-Fi Connection established!')
             else:
                 print('Could not connect to Wi-Fi network!')
         else:
             subprocess.check_call(['/sbin/ifdown', self.interface])
             subprocess.check_call(['/sbin/ifup'] + self.as_args())
Example #3
0
 def activate(self):
     """
     Connects to the network as configured in this scheme.
     """
     if self.encryption_type == 'wpa2-eap':
         response = subprocess.check_output(['wpa_supplicant', '-B', '-i', self.interface, '-Dwext', '-c', '/etc/wpa_supplicant_enterprise.conf'])
         if ("Authentication succeeded" in response) or ("EAP authentication completed successfully" in response):
             print 'Wi-Fi Connection established!'
         else:
             print 'Could not connect to Wi-Fi network!'
     else:
         subprocess.check_call(['/sbin/ifdown', self.interface])
         subprocess.check_call(['/sbin/ifup'] + self.as_args())
Example #4
0
    def activate(self):
        """
        Connects to the network as configured in this scheme.
        """

        self.deactivate()
        subprocess.check_call(['/sbin/wpa_cli', '-i', 'wlan0', 'reconfigure'],
                              stderr=subprocess.STDOUT)
        try:
            ifup_output = subprocess.check_output(
                ['sudo', '/sbin/ifconfig', 'wlan0', 'up'],
                stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            self.logger.exception("Error while trying to connect to %s" %
                                  self.iface)
            self.logger.error("Output: %s" % e.output)
            raise InterfaceError("Failed to connect to %r: %s" %
                                 (self, e.message))
        ifup_output = ifup_output.decode('utf-8')

        return self.parse_ifup_output(ifup_output)
Example #5
0
    def activate(self):
        """
        Connects to the network as configured in this scheme.
        """
        if platform.system() == "Darwin":
            net_ssid = ""
            net_pass = ""
            if "wireless-essid" in self.options.keys():
                net_ssid = self.options['wireless-essid']
            elif "wpa-ssid" in self.options.keys():
                net_pass = self.options['password']
                net_ssid = self.options['wpa-ssid']
            else:
                net_pass = self.options['password']
                net_ssid = self.options['ssid']

            response = ""
            response = subprocess.check_output([
                'networksetup', '-setairportnetwork', 'en0', net_ssid, net_pass
            ])
            if "Failed to join network" in response:
                print("Could not connect to Wi-Fi network!")
            else:
                print("Wi-Fi Connection established!")
        else:
            if self.encryption_type == 'wpa2-eap':
                response = subprocess.check_output([
                    'wpa_supplicant', '-B', '-i', self.interface, '-Dwext',
                    '-c', '/etc/wpa_supplicant_enterprise.conf'
                ])
                if ("Authentication succeeded" in response) or (
                        "EAP authentication completed successfully"
                        in response):
                    print('Wi-Fi Connection established!')
                else:
                    print('Could not connect to Wi-Fi network!')
            else:
                subprocess.check_call(['/sbin/ifdown', self.interface])
                subprocess.check_call(['/sbin/ifup'] + self.as_args())
Example #6
0
 def activate(self):
     """
     Connects to the network as configured in this scheme.
     """
     subprocess.check_call(['/sbin/ifdown', self.interface])
     subprocess.check_call(['/sbin/ifup'] + self.as_args())
	def activate(self):
		""" Activates this config. """

		subprocess.check_call([self.__class__.dnsmasq, "--conf-file={file}".format(file=self.configfile)])
	def deactivate(self):
		pid = self.get_pid()
		if pid is None:
			return
		subprocess.check_call(["kill", pid])
	def activate(self):
		subprocess.check_call([self.__class__.hostapd, "-dd", "-B", self.configfile], stderr=subprocess.STDOUT)
		return True