@@ -49,40 +49,40 @@ def start_hostapd(cls):
4949 adapter = cls .get_adapter_type ()
5050 hostapd_type = cls .hostapds .get (adapter )
5151 try :
52- print "starting hostapd..."
52+ print ( "starting hostapd..." )
5353 out = os .system ("/usr/sbin/" + hostapd_type + " -B /etc/hostapd/" + hostapd_type + ".conf" )
54- print "hostapd out: " + str (out )
54+ print ( "hostapd out: " + str (out ) )
5555
5656 except subprocess .CalledProcessError as e :
57- print e .output
57+ print ( e .output )
5858
5959 @classmethod
6060 def start_dnsmasq (cls ):
6161 try :
62- print "starting dnsmasq..."
62+ print ( "starting dnsmasq..." )
6363 out = os .system ("systemctl start dnsmasq" )
64- print "dnsmasq out: " + str (out )
64+ print ( "dnsmasq out: " + str (out ) )
6565
6666 except subprocess .CalledProcessError as e :
67- print e .output
67+ print ( e .output )
6868
6969 @classmethod
7070 def stop_hostapd (cls ):
7171 try :
72- print "stopping hostapd..."
72+ print ( "stopping hostapd..." )
7373 out = subprocess .check_output (["sudo" , "pkill" , "-9" , "hostapd" ])
74- print "hostapd out: " + str (out )
74+ print ( "hostapd out: " + str (out ) )
7575 except subprocess .CalledProcessError as e :
76- print e .output
76+ print ( e .output )
7777
7878 @classmethod
7979 def stop_dnsmasq (cls ):
8080 try :
81- print "stopping dnsmasq..."
81+ print ( "stopping dnsmasq..." )
8282 out = subprocess .check_output (["systemctl" , "stop" , "dnsmasq" ])
83- print "dnsmasq out: " + str (out )
83+ print ( "dnsmasq out: " + str (out ) )
8484 except subprocess .CalledProcessError as e :
85- print e .output
85+ print ( e .output )
8686
8787 @classmethod
8888 def get_ipaddr (cls , ifname ):
@@ -112,7 +112,7 @@ def register_ipaddr(cls, bot_uid, bot_name, bot_ipaddr, user_email):
112112 if ret .getcode () != 200 :
113113 raise Exception ()
114114 except Exception as e :
115- print "except: " + str (e )
115+ print ( "except: " + str (e ) )
116116 raise
117117
118118 @classmethod
@@ -149,14 +149,14 @@ def start_as_client(cls):
149149 time .sleep (1.0 )
150150 out = os .system ("wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1" )
151151 out += os .system ("dhclient -1 wlan0" )
152- print out
152+ print ( out )
153153 try :
154154 cls .register_ipaddr (cls .get_macaddr ("wlan0" ), cls .get_config ().get ('bot_name' , 'CoderBot' ), cls .get_ipaddr ("wlan0" ), "roberto.previtera@gmail.com" )
155- print "registered bot, ip: " + str (cls .get_ipaddr ("wlan0" ) + " name: " + cls .get_config ().get ('bot_name' , 'CoderBot' ))
155+ print ( "registered bot, ip: " + str (cls .get_ipaddr ("wlan0" ) + " name: " + cls .get_config ().get ('bot_name' , 'CoderBot' ) ))
156156 except :
157157 pass
158158 except subprocess .CalledProcessError as e :
159- print e .output
159+ print ( e .output )
160160 raise
161161
162162 @classmethod
@@ -171,22 +171,22 @@ def start_as_ap(cls):
171171 out += subprocess .check_output (["ip" , "a" , "add" , "10.0.0.1/24" , "dev" , "wlan0" ])
172172 out += subprocess .check_output (["ip" , "link" , "set" , "dev" , "wlan0" , "up" ])
173173 out += subprocess .check_output (["ifconfig" ])
174- print out
174+ print ( out )
175175 cls .start_hostapd ()
176176 cls .start_dnsmasq ()
177177
178178 @classmethod
179179 def start_service (cls ):
180180 config = cls .load_config ()
181181 if config ["wifi_mode" ] == "ap" :
182- print "starting as ap..."
182+ print ( "starting as ap..." )
183183 cls .start_as_ap ()
184184 elif config ["wifi_mode" ] == "client" :
185- print "starting as client..."
185+ print ( "starting as client..." )
186186 try :
187187 cls .start_as_client ()
188188 except :
189- print "Unable to register ip, revert to ap mode"
189+ print ( "Unable to register ip, revert to ap mode" )
190190 cls .start_as_ap ()
191191
192192def main ():
0 commit comments