@@ -191,15 +191,17 @@ def network_control(command, device="eth0", debug=False):
191191 :type device:str
192192 :param debug: flag for using debug mode
193193 :type debug:bool
194- :return: True in successful
194+ :return: True in successful and False otherwise
195195 """
196196 try :
197197 cmd = "up"
198198 if command == "down" :
199199 cmd = "down"
200- sub .Popen (["ifconfig" , device , cmd ],
200+ output = sub .Popen (["ifconfig" , device , cmd ],
201201 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
203205 except Exception as e :
204206 if debug :
205207 print (str (e ))
@@ -213,7 +215,7 @@ def network_enable(device="eth0", debug=False):
213215 :type device:str
214216 :param debug: flag for using debug mode
215217 :type debug:bool
216- :return: True in successful
218+ :return: True in successful and False otherwise
217219 """
218220 return network_control ("up" ,device = device ,debug = debug )
219221
@@ -225,6 +227,6 @@ def network_disable(device="eth0", debug=False):
225227 :type device:str
226228 :param debug: flag for using debug mode
227229 :type debug:bool
228- :return: True in successful
230+ :return: True in successful and False otherwise
229231 """
230232 return network_control ("down" , device = device , debug = debug )
0 commit comments