Merge release-0.28.17 from 'tools/mic'
[platform/upstream/mic.git] / mic / utils / proxy.py
index 438f529..ca884a2 100644 (file)
@@ -25,7 +25,6 @@ _my_noproxy = None
 _my_noproxy_list = []
 
 def set_proxy_environ():
-    global _my_noproxy, _my_proxies
     if not _my_proxies:
         return
     for key in _my_proxies.keys():
@@ -78,6 +77,8 @@ def _ip_to_int(ip):
     ipint = 0
     shift = 24
     for dec in ip.split("."):
+        if not dec.isdigit():
+            continue
         ipint |= int(dec) << shift
         shift -= 8
     return ipint
@@ -118,7 +119,7 @@ def _set_noproxy_list():
             c_result = os.popen(cmd).readlines()
             if len(c_result) == 0:
                 continue
-        except Exception,e:
+        except Exception as e:
             msger.warning(str(e))
             continue
         to_list = c_result[0].strip("\n").split(",")
@@ -152,6 +153,8 @@ def _set_noproxy_list():
                 shift = 24
                 netmask = 0
                 for dec in mask.split("."):
+                    if not dec.isdigit():
+                        continue
                     netmask |= int(dec) << shift
                     shift -= 8
                 ip &= netmask