-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from dandi/enh-ls
ENH: rudimentary ls and validate commands
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.eggs | ||
.idea | ||
.*.swp | ||
*.egg-info/ | ||
dist/ | ||
pip-wheel-metadata/ | ||
sandbox/ | ||
venvs/ | ||
|
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 |
---|---|---|
@@ -1,3 +1,25 @@ | ||
import logging | ||
|
||
from . import _version | ||
|
||
__version__ = _version.get_versions()['version'] | ||
|
||
|
||
# | ||
# Basic logger configuration | ||
# | ||
|
||
|
||
def get_logger(name=None): | ||
"""Return a logger to use | ||
""" | ||
return logging.getLogger('dandi' + ('.%s' % name if name else '')) | ||
|
||
|
||
_DEFAULT_LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | ||
|
||
lgr = get_logger() | ||
# Basic settings for output, for now just basic | ||
lgr.setLevel(logging.INFO) | ||
FORMAT = '%(asctime)-15s [%(levelname)8s] %(message)s' | ||
logging.basicConfig(format=FORMAT) |
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,37 @@ | ||
import sys | ||
|
||
# | ||
# Additional handlers | ||
# | ||
_sys_excepthook = sys.excepthook # Just in case we ever need original one | ||
|
||
|
||
def is_interactive(): | ||
"""Return True if all in/outs are tty""" | ||
# TODO: check on windows if hasattr check would work correctly and add value: | ||
# | ||
return sys.stdin.isatty() and sys.stdout.isatty() and sys.stderr.isatty() | ||
|
||
|
||
def setup_exceptionhook(ipython=False): | ||
"""Overloads default sys.excepthook with our exceptionhook handler. | ||
If interactive, our exceptionhook handler will invoke | ||
pdb.post_mortem; if not interactive, then invokes default handler. | ||
""" | ||
|
||
def _pdb_excepthook(type, value, tb): | ||
import traceback | ||
traceback.print_exception(type, value, tb) | ||
print() | ||
if is_interactive(): | ||
import pdb | ||
pdb.post_mortem(tb) | ||
|
||
if ipython: | ||
from IPython.core import ultratb | ||
sys.excepthook = ultratb.FormattedTB(mode='Verbose', | ||
# color_scheme='Linux', | ||
call_pdb=is_interactive()) | ||
else: | ||
sys.excepthook = _pdb_excepthook |
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