@@ -49,40 +49,40 @@ def start_hostapd(cls):
49
49
adapter = cls .get_adapter_type ()
50
50
hostapd_type = cls .hostapds .get (adapter )
51
51
try :
52
- print "starting hostapd..."
52
+ print ( "starting hostapd..." )
53
53
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 ) )
55
55
56
56
except subprocess .CalledProcessError as e :
57
- print e .output
57
+ print ( e .output )
58
58
59
59
@classmethod
60
60
def start_dnsmasq (cls ):
61
61
try :
62
- print "starting dnsmasq..."
62
+ print ( "starting dnsmasq..." )
63
63
out = os .system ("systemctl start dnsmasq" )
64
- print "dnsmasq out: " + str (out )
64
+ print ( "dnsmasq out: " + str (out ) )
65
65
66
66
except subprocess .CalledProcessError as e :
67
- print e .output
67
+ print ( e .output )
68
68
69
69
@classmethod
70
70
def stop_hostapd (cls ):
71
71
try :
72
- print "stopping hostapd..."
72
+ print ( "stopping hostapd..." )
73
73
out = subprocess .check_output (["sudo" , "pkill" , "-9" , "hostapd" ])
74
- print "hostapd out: " + str (out )
74
+ print ( "hostapd out: " + str (out ) )
75
75
except subprocess .CalledProcessError as e :
76
- print e .output
76
+ print ( e .output )
77
77
78
78
@classmethod
79
79
def stop_dnsmasq (cls ):
80
80
try :
81
- print "stopping dnsmasq..."
81
+ print ( "stopping dnsmasq..." )
82
82
out = subprocess .check_output (["systemctl" , "stop" , "dnsmasq" ])
83
- print "dnsmasq out: " + str (out )
83
+ print ( "dnsmasq out: " + str (out ) )
84
84
except subprocess .CalledProcessError as e :
85
- print e .output
85
+ print ( e .output )
86
86
87
87
@classmethod
88
88
def get_ipaddr (cls , ifname ):
@@ -112,7 +112,7 @@ def register_ipaddr(cls, bot_uid, bot_name, bot_ipaddr, user_email):
112
112
if ret .getcode () != 200 :
113
113
raise Exception ()
114
114
except Exception as e :
115
- print "except: " + str (e )
115
+ print ( "except: " + str (e ) )
116
116
raise
117
117
118
118
@classmethod
@@ -149,14 +149,14 @@ def start_as_client(cls):
149
149
time .sleep (1.0 )
150
150
out = os .system ("wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1" )
151
151
out += os .system ("dhclient -1 wlan0" )
152
- print out
152
+ print ( out )
153
153
try :
154
154
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' ) ))
156
156
except :
157
157
pass
158
158
except subprocess .CalledProcessError as e :
159
- print e .output
159
+ print ( e .output )
160
160
raise
161
161
162
162
@classmethod
@@ -171,22 +171,22 @@ def start_as_ap(cls):
171
171
out += subprocess .check_output (["ip" , "a" , "add" , "10.0.0.1/24" , "dev" , "wlan0" ])
172
172
out += subprocess .check_output (["ip" , "link" , "set" , "dev" , "wlan0" , "up" ])
173
173
out += subprocess .check_output (["ifconfig" ])
174
- print out
174
+ print ( out )
175
175
cls .start_hostapd ()
176
176
cls .start_dnsmasq ()
177
177
178
178
@classmethod
179
179
def start_service (cls ):
180
180
config = cls .load_config ()
181
181
if config ["wifi_mode" ] == "ap" :
182
- print "starting as ap..."
182
+ print ( "starting as ap..." )
183
183
cls .start_as_ap ()
184
184
elif config ["wifi_mode" ] == "client" :
185
- print "starting as client..."
185
+ print ( "starting as client..." )
186
186
try :
187
187
cls .start_as_client ()
188
188
except :
189
- print "Unable to register ip, revert to ap mode"
189
+ print ( "Unable to register ip, revert to ap mode" )
190
190
cls .start_as_ap ()
191
191
192
192
def main ():
0 commit comments