# Path: classes/conf.py
# class Conf:
# 	def __init__(self):
# 		self.home = os.path.expanduser('~')
# 		if 'root' in self.home:
# 			self.home = '/home/'+os.path.expanduser(os.environ["SUDO_USER"])
# 		self.conf_folder = self.home+'/.openplotter'
# 		self.data_conf = ConfigParser.SafeConfigParser()
# 		self.read()
# 
# 	def read(self):
# 		self.data_conf.read(self.conf_folder+'/openplotter.conf')
# 
# 	def write(self):
# 		with open(self.conf_folder+'/openplotter.conf', 'wb') as configfile:
# 			self.data_conf.write(configfile)
# 
# 	def get(self, section, item):
# 		result = ''
# 		try:
# 			result = self.data_conf.get(section, item)
# 		except ConfigParser.NoSectionError:
# 			self.read()
# 			try:
# 				self.data_conf.add_section(section)
# 			except ConfigParser.DuplicateSectionError: pass
# 			self.data_conf.set(section, item, '')
# 			self.write()
# 		except ConfigParser.NoOptionError:
# 			self.set(section, item, '')
# 		return result
# 
# 	def set(self, section, item, value):
# 		self.read()
# 		try:
# 			self.data_conf.set(section, item, value)
# 		except ConfigParser.NoSectionError:
# 			self.data_conf.add_section(section)
# 			self.data_conf.set(section, item, value)
# 		self.write()
# 
# 	def has_option(self, section, item):
# 		return self.data_conf.has_option(section, item)
# 
# 	def has_section(self, section):
# 		return self.data_conf.has_section(section)
# 
# 	def add_section(self, section):
# 		return self.data_conf.add_section(section)


import os
import subprocess
import sys
import time
import fileinput
import string 
from classes.conf import Conf
				try:
					erg_ = subprocess.Popen('ifconfig',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
					erg = erg_.communicate()[0]
				except:
					pass
				i += 1
			time.sleep(1)
			output = subprocess.Popen('ifconfig eth0 down'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			i=0
			erg = 'eth0'
			while 'eth0' in erg and i<40:
				time.sleep(1)
				try:
					erg_ = subprocess.Popen('ifconfig',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
					erg = erg_.communicate()[0]
				except:
					pass
				i += 1
			
			output = subprocess.Popen(('ifconfig '+wlan+' up').split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			output = subprocess.Popen('ifconfig eth0 up'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			if bridge == '0':
				output = subprocess.Popen('service networking restart'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
				output.wait()
		msg1 = ''
		network_info = ''
		try:

# Path: classes/conf.py
# class Conf:
# 	def __init__(self):
# 		self.home = os.path.expanduser('~')
# 		if 'root' in self.home:
# 			self.home = '/home/'+os.path.expanduser(os.environ["SUDO_USER"])
# 		self.conf_folder = self.home+'/.openplotter'
# 		self.data_conf = ConfigParser.SafeConfigParser()
# 		self.read()
# 
# 	def read(self):
# 		self.data_conf.read(self.conf_folder+'/openplotter.conf')
# 
# 	def write(self):
# 		with open(self.conf_folder+'/openplotter.conf', 'wb') as configfile:
# 			self.data_conf.write(configfile)
# 
# 	def get(self, section, item):
# 		result = ''
# 		try:
# 			result = self.data_conf.get(section, item)
# 		except ConfigParser.NoSectionError:
# 			self.read()
# 			try:
# 				self.data_conf.add_section(section)
# 			except ConfigParser.DuplicateSectionError: pass
# 			self.data_conf.set(section, item, '')
# 			self.write()
# 		except ConfigParser.NoOptionError:
# 			self.set(section, item, '')
# 		return result
# 
# 	def set(self, section, item, value):
# 		self.read()
# 		try:
# 			self.data_conf.set(section, item, value)
# 		except ConfigParser.NoSectionError:
# 			self.data_conf.add_section(section)
# 			self.data_conf.set(section, item, value)
# 		self.write()
# 
# 	def has_option(self, section, item):
# 		return self.data_conf.has_option(section, item)
# 
# 	def has_section(self, section):
# 		return self.data_conf.has_section(section)
# 
# 	def add_section(self, section):
# 		return self.data_conf.add_section(section)


# Path: wifi_server.py
import os
import subprocess
import sys
import time
import fileinput
import string 
from classes.conf import Conf

				try:
					erg_ = subprocess.Popen('ifconfig',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
					erg = erg_.communicate()[0]
				except:
					pass
				i += 1
			time.sleep(1)
			output = subprocess.Popen('ifconfig eth0 down'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			i=0
			erg = 'eth0'
			while 'eth0' in erg and i<40:
				time.sleep(1)
				try:
					erg_ = subprocess.Popen('ifconfig',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
					erg = erg_.communicate()[0]
				except:
					pass
				i += 1
			
			output = subprocess.Popen(('ifconfig '+wlan+' up').split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			output = subprocess.Popen('ifconfig eth0 up'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
			output.wait()
			if bridge == '0':
				output = subprocess.Popen('service networking restart'.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
				output.wait()
		msg1 = ''
		network_info = ''
		try:

			network_info = subprocess.check_output('service dnsmasq status'.split())