summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/launcher.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-25 18:00:12 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-27 19:33:28 +0200
commit9f95446a55533c8cdceec7c4430be5cad752ecb1 (patch)
tree4265c127ee9b2c5f1e038836ad2e7b92ea0cad80 /src/leap/bitmask/vpn/launcher.py
parent9a1548aa01996ce93febe0272f1f8e4dd5e130ff (diff)
[bug] unify logging style using class attr
I changed most of the logger statements to use a class attribute, in this way it's easier to identify which class it's logging them. in some cases I leave a module-level logger, when we're either using functions or when the module it's too small. at the same time I did a general review and cleanup of the logging statements.
Diffstat (limited to 'src/leap/bitmask/vpn/launcher.py')
-rw-r--r--src/leap/bitmask/vpn/launcher.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/leap/bitmask/vpn/launcher.py b/src/leap/bitmask/vpn/launcher.py
index 3006d6d..fa9923a 100644
--- a/src/leap/bitmask/vpn/launcher.py
+++ b/src/leap/bitmask/vpn/launcher.py
@@ -33,7 +33,7 @@ from leap.bitmask.vpn.constants import IS_LINUX
from leap.bitmask.vpn.utils import force_eval
-logger = Logger()
+log = Logger()
flags_STANDALONE = False
@@ -62,18 +62,18 @@ def _has_updown_scripts(path, warn=True):
"""
is_file = os.path.isfile(path)
if warn and not is_file:
- logger.error("Could not find up/down script %s. "
- "Might produce DNS leaks." % (path,))
+ log.error('Could not find up/down script %s. '
+ 'Might produce DNS leaks.' % (path,))
# XXX check if applies in win
is_exe = False
try:
is_exe = (stat.S_IXUSR & os.stat(path)[stat.ST_MODE] != 0)
except OSError as e:
- logger.warn("%s" % (e,))
+ log.warn("%s" % (e,))
if warn and not is_exe:
- logger.error("Up/down script %s is not executable. "
- "Might produce DNS leaks." % (path,))
+ log.error('Up/down script %s is not executable. '
+ 'Might produce DNS leaks.' % (path,))
return is_file and is_exe
@@ -91,8 +91,8 @@ def _has_other_files(path, warn=True):
"""
is_file = os.path.isfile(path)
if warn and not is_file:
- logger.warning("Could not find file during checks: %s. " % (
- path,))
+ log.warn('Could not find file during checks: %s. ' % (
+ path,))
return is_file
@@ -109,6 +109,7 @@ class VPNLauncher(object):
PREFERRED_PORTS = ("443", "80", "53", "1194")
+ # FIXME -- dead code?
@classmethod
@abstractmethod
def get_gateways(kls, vpnconfig, providerconfig):
@@ -138,7 +139,7 @@ class VPNLauncher(object):
gws = [gateway_conf]
if not gws:
- logger.error('No gateway was found!')
+ log.error('No gateway was found!')
raise VPNLauncherException('No gateway was found!')
for idx, gw in enumerate(gws):
@@ -156,7 +157,7 @@ class VPNLauncher(object):
gateways.append((gw, the_port))
- logger.debug("Using gateways (ip, port): {0!r}".format(gateways))
+ log.debug('Using gateways (ip, port): {0!r}'.format(gateways))
return gateways
@classmethod
@@ -198,8 +199,8 @@ class VPNLauncher(object):
openvpn_path = force_eval(kls.OPENVPN_BIN_PATH)
if not os.path.isfile(openvpn_path):
- logger.warning("Could not find openvpn bin in path %s" % (
- openvpn_path))
+ log.warn('Could not find openvpn bin in path %s' % (
+ openvpn_path))
raise OpenVPNNotFoundException()
args = []
@@ -321,11 +322,6 @@ class VPNLauncher(object):
:rtype: list
"""
- # leap_assert(kls.OTHER_FILES is not None,
- # "Need to define OTHER_FILES for this particular "
- # "auncher before calling this method")
-
- # TODO assert vs except?
if kls.OTHER_FILES is None:
raise Exception(
"Need to define OTHER_FILES for this particular "