[saltstack/salt#31194] Make the code simple because IndexError exception has very rare chance to be raised at 'os.path.abspath(__file__).rsplit('/')[-2]', advised by @whiteinge.

This commit is contained in:
kstreee 2016-02-21 15:59:59 +09:00
parent f56a551a22
commit cfab276324
2 changed files with 2 additions and 9 deletions

View File

@ -20,11 +20,7 @@ try:
except ImportError as exc: except ImportError as exc:
cpy_error = exc cpy_error = exc
__virtualname__ = os.path.abspath(__file__).rsplit('/')[-2] or 'rest_cherrypy'
try:
__virtualname__ = os.path.abspath(__file__).rsplit('/')[-2]
except IndexError:
__virtualname__ = 'rest_cherrypy'
logger = logging.getLogger(__virtualname__) logger = logging.getLogger(__virtualname__)
cpy_min = '3.2.2' cpy_min = '3.2.2'

View File

@ -6,10 +6,7 @@ import logging
import os import os
import distutils.version # pylint: disable=no-name-in-module import distutils.version # pylint: disable=no-name-in-module
try: __virtualname__ = os.path.abspath(__file__).rsplit('/')[-2] or 'rest_cherrypy'
__virtualname__ = os.path.abspath(__file__).rsplit('/')[-2]
except IndexError:
__virtualname__ = 'rest_tornado'
logger = logging.getLogger(__virtualname__) logger = logging.getLogger(__virtualname__)