@@ -191,15 +191,17 @@ def network_control(command, device="eth0", debug=False):
191
191
:type device:str
192
192
:param debug: flag for using debug mode
193
193
:type debug:bool
194
- :return: True in successful
194
+ :return: True in successful and False otherwise
195
195
"""
196
196
try :
197
197
cmd = "up"
198
198
if command == "down" :
199
199
cmd = "down"
200
- sub .Popen (["ifconfig" , device , cmd ],
200
+ output = sub .Popen (["ifconfig" , device , cmd ],
201
201
stderr = sub .PIPE , stdin = sub .PIPE , stdout = sub .PIPE )
202
- return True
202
+ if len (output [0 ]) == 0 and len (output [1 ]) == 0 :
203
+ return True
204
+ return False
203
205
except Exception as e :
204
206
if debug :
205
207
print (str (e ))
@@ -213,7 +215,7 @@ def network_enable(device="eth0", debug=False):
213
215
:type device:str
214
216
:param debug: flag for using debug mode
215
217
:type debug:bool
216
- :return: True in successful
218
+ :return: True in successful and False otherwise
217
219
"""
218
220
return network_control ("up" ,device = device ,debug = debug )
219
221
@@ -225,6 +227,6 @@ def network_disable(device="eth0", debug=False):
225
227
:type device:str
226
228
:param debug: flag for using debug mode
227
229
:type debug:bool
228
- :return: True in successful
230
+ :return: True in successful and False otherwise
229
231
"""
230
232
return network_control ("down" , device = device , debug = debug )
0 commit comments