Skip to content

Commit

Permalink
Merge pull request #26 from JarryShaw/test/rc/protocols
Browse files Browse the repository at this point in the history
 New distribution [0.14.1]

* add PCAPKIT_DEVMODE environ
* revised Makefile
  • Loading branch information
JarryShaw authored Mar 7, 2019
2 parents 8030c53 + 3d9bd8f commit 0a4770a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 54 deletions.
28 changes: 8 additions & 20 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,17 @@ about: Create a report to help us improve
**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**System information**
A clear and concise description of your system information.
- OS Version: [e.g. macOS Mojave 10.14.4]
- Python Version: [e.g 3.7, 3.6, 3.5, 3.4]
- Python Implementation: [e.g. CPython, PyPy]

**Traceback stack**
Run program again with `PCAPKIT_DEVMODE=true` set to provide the traceback stack.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
38 changes: 19 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ update-pipenv:
update-const:
set -ex
for file in src/vendor/*/*.py ; do \
pipenv run python3 $${file} ; \
pipenv run python3 $${file} ; \
done

# update maintenance information
Expand Down Expand Up @@ -120,16 +120,16 @@ dist-upload:
dist-prep:
mkdir -p release
rm -rf release/src \
release/pcapkit
release/pcapkit
cp -r .gitattributes \
.gitignore \
LICENSE \
MANIFEST.in \
README.md \
docker \
src \
setup.py \
setup.cfg release/
.gitignore \
LICENSE \
MANIFEST.in \
README.md \
docker \
src \
setup.py \
setup.cfg release/
mv release/src release/pcapkit

# add tag
Expand All @@ -147,9 +147,9 @@ git-upload:
git pull
git add .
if [[ -z "$(message)" ]] ; then \
git commit -a -S ; \
git commit -a -S ; \
else \
git commit -a -S -m "$(message)" ; \
git commit -a -S -m "$(message)" ; \
fi
git push

Expand All @@ -163,21 +163,21 @@ git-aftermath:
# file new release on master
release-master:
go run github.com/aktau/github-release release \
--user JarryShaw \
--repo PyPCAPKit \
--tag "v$(version)" \
--name "PyPCAPKit v$(version)" \
--description "$(message)"
--user JarryShaw \
--repo PyPCAPKit \
--tag "v$(version)" \
--name "PyPCAPKit v$(version)" \
--description "$(message)"

# run pre-distribution process
dist-pre: update

# run post-distribution process
dist-post:
$(MAKE) message="$(message)" DIR=release \
clean dist git-tag git-upload
clean dist git-tag git-upload
$(MAKE) message="$(message)" \
git-upload release update-maintainer git-aftermath
git-upload release update-maintainer git-aftermath

# run full distribution process
dist-all: dist-pre dist-prep dist-post
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# basic info
FROM library/ubuntu
LABEL version 2019.03.02
LABEL version 2019.03.07
LABEL description "Ubuntu Environment"

# prepare environment
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from distutils.core import setup

# version string
__version__ = '0.14.0'
__version__ = '0.14.1'

# README
with open('README.md', encoding='utf-8') as file:
Expand Down
16 changes: 11 additions & 5 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@
dump utilities for `pcapkit` implementation
"""
# set up sys.excepthook
import os
import warnings

import tbtrim

from pcapkit.utilities.exceptions import BaseError
from pcapkit.utilities.exceptions import DEVMODE, BaseError

ROOT = os.path.dirname(os.path.relpath(__file__))
tbtrim.set_trim_rule(lambda filename: ROOT in os.path.realpath(filename),
exception=BaseError, strict=False)
# set up sys.excepthook
if DEVMODE:
warnings.showwarning('development mode enabled', RuntimeWarning,
filename=__file__, lineno=0,
line=f"PCAPKIT_DEVMODE={os.environ['PCAPKIT_DEVMODE']}")
else:
ROOT = os.path.dirname(os.path.relpath(__file__))
tbtrim.set_trim_rule(lambda filename: ROOT in os.path.realpath(filename),
exception=BaseError, strict=False)

# All Reference
import pcapkit.__all__ as all # pylint: disable
Expand Down
26 changes: 18 additions & 8 deletions src/utilities/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
'ModuleNotFound', # ModuleNotFoundError
]

# boolean mappings
BOOLEAN_STATES = {'1': True, '0': False,
'yes': True, 'no': False,
'true': True, 'false': False,
'on': True, 'off': False}

# DEVMODE flag
DEVMODE = BOOLEAN_STATES.get(os.environ.get('PCAPKIT_DEVMODE', '').lower(), False)


def stacklevel():
"""Fetch current stack level."""
Expand Down Expand Up @@ -62,14 +71,15 @@ class BaseError(Exception):
"""
def __init__(self, *args, **kwargs):
index = stacklevel()
quiet = kwargs.pop('quiet', False)
if not quiet and index:
fmt_exc = traceback.format_exc(limit=-index)
if len(fmt_exc.splitlines(True)) > 1:
print(fmt_exc, file=sys.stderr)

sys.tracebacklimit = 0
if DEVMODE:
index = stacklevel()
quiet = kwargs.pop('quiet', False)
if not quiet and index:
fmt_exc = traceback.format_exc(limit=-index)
if len(fmt_exc.splitlines(True)) > 1:
print(fmt_exc, file=sys.stderr)
else:
sys.tracebacklimit = 0
super().__init__(*args, **kwargs)


Expand Down

0 comments on commit 0a4770a

Please sign in to comment.