-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ingest vsc-base & vsc-install #2708
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
eee183a
don't install vsc-base as dep in Travis config
boegel 5ac43c1
ingest vsc-base into easybuild.base namespace + remove unused functio…
boegel 7701708
bump version in bootstrap script
boegel 510d865
remove vsc-install and vsc-base dependencies from setup.py
boegel 4fb27ce
revert changes to bootstrap script which still installs EasyBuild v3.x
boegel 05cf287
strip down easybuild.base.affinity
boegel 67db46e
merge required functionality of easybuild.base.affinity into easybuil…
boegel 7993e14
drop support for date/datetime-typed options in GeneralOption
boegel d120141
remove unused PassThroughOptionParser from easybuild.base.generaloption
boegel 9adc790
merge mk_rst_table function into easybuild.tools.docs
boegel f168225
use own implementation of shell_quote rather than the implementation …
boegel 382805f
collapse functions from easybuild.base.missing into easybuild.tools.u…
boegel f85cd00
fix broken test_setvar
boegel 8a39261
merge Singleton class into easybuild.tools.config
boegel 37af92f
fix cyclic import by moving GENERAL_CLASS constant to easybuild.tools…
boegel 8662e71
fix import for Singleton in test/framework/utilities.py
boegel 5d0f18d
fix import for GENERAL_CLASS constant in test/framework/utilities.py
boegel a79de84
strip down easybuild.base.testing
boegel 4fc59e8
fix trivial style issues
boegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# | ||
# Copyright 2015-2018 Ghent University | ||
# | ||
# This file is part of EasyBuild, | ||
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
# with support of Ghent University (http://ugent.be/hpc), | ||
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), | ||
# Flemish Research Foundation (FWO) (http://www.fwo.be/en) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# https://github.com/easybuilders/easybuild | ||
# | ||
# EasyBuild is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation v2. | ||
# | ||
# EasyBuild is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
""" | ||
Module providing custom exceptions. | ||
|
||
:author: Kenneth Hoste (Ghent University) | ||
:author: Riccardo Murri (University of Zurich) | ||
""" | ||
import inspect | ||
import logging | ||
import os | ||
|
||
from easybuild.base import fancylogger | ||
|
||
|
||
def get_callers_logger(): | ||
""" | ||
Get logger defined in caller's environment | ||
:return: logger instance (or None if none was found) | ||
""" | ||
logger_cls = logging.getLoggerClass() | ||
if __debug__: | ||
frame = inspect.currentframe() | ||
else: | ||
frame = None | ||
logger = None | ||
|
||
# frame may be None, see https://docs.python.org/2/library/inspect.html#inspect.currentframe | ||
if frame is not None: | ||
try: | ||
# consider calling stack in reverse order, i.e. most inner frame (closest to caller) first | ||
for frameinfo in inspect.getouterframes(frame)[::-1]: | ||
bindings = inspect.getargvalues(frameinfo[0]).locals | ||
for val in bindings.values(): | ||
if isinstance(val, logger_cls): | ||
logger = val | ||
break | ||
finally: | ||
# make very sure that reference to frame object is removed, to avoid reference cycles | ||
# see https://docs.python.org/2/library/inspect.html#the-interpreter-stack | ||
del frame | ||
|
||
return logger | ||
|
||
|
||
class LoggedException(Exception): | ||
"""Exception that logs it's message when it is created.""" | ||
|
||
# logger module to use (must provide getLogger() function) | ||
LOGGER_MODULE = fancylogger | ||
# name of logging method to use | ||
# must accept an argument of type string, i.e. the log message, and an optional list of formatting arguments | ||
LOGGING_METHOD_NAME = 'error' | ||
# list of top-level package names to use to format location info; None implies not to include location info | ||
LOC_INFO_TOP_PKG_NAMES = [] | ||
# include location where error was raised from (enabled by default under 'python', disabled under 'python -O') | ||
INCLUDE_LOCATION = __debug__ | ||
|
||
def __init__(self, msg, *args, **kwargs): | ||
""" | ||
Constructor. | ||
:param msg: exception message | ||
:param *args: list of formatting arguments for exception message | ||
:param logger: logger to use | ||
""" | ||
# format message with (optional) list of formatting arguments | ||
if args: | ||
msg = msg % args | ||
|
||
if self.LOC_INFO_TOP_PKG_NAMES is not None: | ||
# determine correct frame to fetch location information from | ||
frames_up = 1 | ||
if self.__class__ != LoggedException: | ||
# move a level up when this instance is derived from LoggedException | ||
frames_up += 1 | ||
|
||
if self.INCLUDE_LOCATION: | ||
# figure out where error was raised from | ||
# current frame: this constructor, one frame above: location where LoggedException was created/raised | ||
frameinfo = inspect.getouterframes(inspect.currentframe())[frames_up] | ||
|
||
# determine short location of Python module where error was raised from, | ||
# i.e. starting with an entry from LOC_INFO_TOP_PKG_NAMES | ||
path_parts = frameinfo[1].split(os.path.sep) | ||
if path_parts[0] == '': | ||
path_parts[0] = os.path.sep | ||
top_indices = [path_parts.index(n) for n in self.LOC_INFO_TOP_PKG_NAMES if n in path_parts] | ||
relpath = os.path.join(*path_parts[max(top_indices or [0]):]) | ||
|
||
# include location info at the end of the message | ||
# for example: "Nope, giving up (at easybuild/tools/somemodule.py:123 in some_function)" | ||
msg = "%s (at %s:%s in %s)" % (msg, relpath, frameinfo[2], frameinfo[3]) | ||
|
||
logger = kwargs.get('logger', None) | ||
# try to use logger defined in caller's environment | ||
if logger is None: | ||
logger = get_callers_logger() | ||
# search can fail, use root logger as a fallback | ||
if logger is None: | ||
logger = self.LOGGER_MODULE.getLogger() | ||
|
||
getattr(logger, self.LOGGING_METHOD_NAME)(msg) | ||
|
||
super(LoggedException, self).__init__(msg) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its