Skip to content

Commit 8fa46af

Browse files
author
IliaFeldgun
committed
RD-1601 py3 py2 agnostic
1 parent d08bdcc commit 8fa46af

24 files changed

Lines changed: 331 additions & 153 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
*.pyc
22
*.swp
33
.idea
4+
__pycache__
5+
dist
6+
build
7+
*.egg-info
8+
*.stratolog

Dockerfile.pycommonlog-build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM rackattack-nas.dc1:5000/ubuntu-dev-base:379308aa77bd0a19ebf12d868e7d19ee35a19d6c
2+
RUN apt-get install -y python2.7 python2.7-dev
3+
RUN curl 'https://bootstrap.pypa.io/pip/2.7/get-pip.py' | python2.7
4+
COPY requirements.txt /tmp/requirements.txt
5+
COPY dev-requirements.txt /tmp/dev-requirements.txt
6+
RUN python2.7 -m pip install -r /tmp/requirements.txt -r /tmp/dev-requirements.txt
7+
RUN python3 -m pip install -r /tmp/requirements.txt -r /tmp/dev-requirements.txt
8+
RUN rm /tmp/requirements.txt /tmp/dev-requirements.txt

Makefile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
all: test check_convention
1+
.PHONY: all test test_py2 test_py3 lint_py2 lint_py3 build
2+
all: lint test build
23

3-
test:
4-
PYTHONPATH=$(PWD)/py python py/strato/common/log/tests/test.py
4+
test: test_py2 test_py3
55

6-
check_convention:
7-
pep8 py --max-line-length=109
6+
test_py3:
7+
PYTHONPATH=$(PWD)/py python3 py/strato/common/log/tests/test.py
8+
9+
test_py2:
10+
PYTHONPATH=$(PWD)/py python2.7 py/strato/common/log/tests/test.py
11+
12+
lint: lint_py2 lint_py3
13+
14+
lint_py3:
15+
python3 -m pep8 py --max-line-length=120
16+
17+
lint_py2:
18+
python2.7 -m pep8 py --max-line-length=120
19+
20+
build: dist/pycommonlog-*.tar.gz
21+
22+
clean:
23+
find . -name *.pyc -delete
24+
find . -name __pycache__ -delete
25+
rm -rf dist */*.egg-info build *.stratolog
26+
27+
dist/pycommonlog-*.tar.gz:
28+
python3 -m build --wheel

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# pycommonlog
2+
3+
# Build
4+
```bash
5+
skipper make -i all
6+
```
7+
8+
# Demo
9+
10+
```python
11+
from strato.common.log import configurelogging
12+
configurelogging.configureLogging('test-strato-log', forceDirectory=".")
13+
import logging # noqa: E402
14+
logging.warning('Running test')
15+
logging.error('Running test')
16+
logging.progress('Running test')
17+
logging.step('Running test')
18+
logging.critical('Running test')
19+
logging.success('Running test')
20+
logging.debug('Running test')
21+
try:
22+
raise Exception('Test exception')
23+
except Exception:
24+
logging.exception('Running test')
25+
```

artifacts.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pips:
2+
- dist/strato_common_log-*-py2.py3-none-any.whl

dev-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
pep8
3+
ipdb

js/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import shutil
22
import argparse
33
import os
4-
import subprocess
54
import SimpleHTTPServer
65
import SocketServer
76
import socket
7+
try:
8+
import subprocess32 as subprocess
9+
except ImportError:
10+
import subprocess
811

9-
parser = argparse.ArgumentParser( description = 'Present summary of tests results in a webpage.' )
12+
parser = argparse.ArgumentParser(description='Present summary of tests results in a webpage.')
1013
parser.add_argument("--root", default="logs.racktest")
1114
parser.add_argument("--whiteboxRoot", action="store_true")
1215
parser.add_argument("--noBrowser", help="avoid openning the browser", action="store_true")

py/strato/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
import upseto.pythonnamespacejoin
2-
__path__.extend(upseto.pythonnamespacejoin.join(globals()))

py/strato/common/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
import upseto.pythonnamespacejoin
2-
__path__.extend(upseto.pythonnamespacejoin.join(globals()))

py/strato/common/log/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
"incremental": True
4040
}
4141

42-
exec os.environ.get("STRATO_CONFIG_LOGGING", "")
42+
exec(os.environ.get("STRATO_CONFIG_LOGGING", ""))

0 commit comments

Comments
 (0)