Skip to content

Commit 2550374

Browse files
author
khadijeh.alibabaei
committed
update the tox.ini
1 parent 85e0ad4 commit 2550374

File tree

11 files changed

+134
-188
lines changed

11 files changed

+134
-188
lines changed

bandit/index.html

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
6+
<meta charset="UTF-8">
7+
8+
<title>
9+
Bandit Report
10+
</title>
11+
12+
<style>
13+
14+
html * {
15+
font-family: "Arial", sans-serif;
16+
}
17+
18+
pre {
19+
font-family: "Monaco", monospace;
20+
}
21+
22+
.bordered-box {
23+
border: 1px solid black;
24+
padding-top:.5em;
25+
padding-bottom:.5em;
26+
padding-left:1em;
27+
}
28+
29+
.metrics-box {
30+
font-size: 1.1em;
31+
line-height: 130%;
32+
}
33+
34+
.metrics-title {
35+
font-size: 1.5em;
36+
font-weight: 500;
37+
margin-bottom: .25em;
38+
}
39+
40+
.issue-description {
41+
font-size: 1.3em;
42+
font-weight: 500;
43+
}
44+
45+
.candidate-issues {
46+
margin-left: 2em;
47+
border-left: solid 1px; LightGray;
48+
padding-left: 5%;
49+
margin-top: .2em;
50+
margin-bottom: .2em;
51+
}
52+
53+
.issue-block {
54+
border: 1px solid LightGray;
55+
padding-left: .5em;
56+
padding-top: .5em;
57+
padding-bottom: .5em;
58+
margin-bottom: .5em;
59+
}
60+
61+
.issue-sev-high {
62+
background-color: Pink;
63+
}
64+
65+
.issue-sev-medium {
66+
background-color: NavajoWhite;
67+
}
68+
69+
.issue-sev-low {
70+
background-color: LightCyan;
71+
}
72+
73+
</style>
74+
</head>
75+
76+
<body>
77+
78+
<div id="metrics">
79+
<div class="metrics-box bordered-box">
80+
<div class="metrics-title">
81+
Metrics:<br>
82+
</div>
83+
Total lines of code: <span id="loc">2061</span><br>
84+
Total lines skipped (#nosec): <span id="nosec">0</span>
85+
</div>
86+
</div>
87+
88+
89+
90+
91+
<br>
92+
<div id="results">
93+
94+
</div>
95+
96+
</body>
97+
</html>

posenetclas/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def catch_url_error(url_list):
4949
): # don't do the checks for base64 encoded images
5050
# Error catch: Inexistent url
5151
try:
52-
url_type = requests.head(i).headers.get(
52+
url_type = requests.head(i, timeout=20).headers.get(
5353
"content-type"
5454
)
5555
except Exception:
@@ -118,6 +118,7 @@ def predict_url(args):
118118
filepaths = []
119119
for url in args["urls"]:
120120
tmp_path = os.path.join(dir_path, os.path.basename(url))
121+
121122
urllib.request.urlretrieve(url, tmp_path)
122123
filepaths.append(tmp_path)
123124

posenetclas/converter/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
def load_config(config_name="config.yaml"):
88
cfg_f = open(os.path.join(BASE_DIR, config_name), "r+")
9-
cfg = yaml.load(cfg_f, Loader=yaml.FullLoader)
9+
cfg = yaml.safe_load(cfg_f, Loader=yaml.FullLoader)
1010
return cfg

posenetclas/tests/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_curl_load():
9191

9292
r = subprocess.run(
9393
'curl -X GET "http://0.0.0.0:5000/v2/models/" -H "accept: application/json"',
94-
shell=True,
94+
shell=False,
9595
check=True,
9696
stdout=subprocess.PIPE,
9797
).stdout
@@ -108,7 +108,7 @@ def test_curl_metadata():
108108
'curl -X GET "http://0.0.0.0:5000/v2/models/{}/" -H "accept: application/json"'.format(
109109
module_name
110110
),
111-
shell=True,
111+
shell=False,
112112
check=True,
113113
stdout=subprocess.PIPE,
114114
).stdout
@@ -131,7 +131,7 @@ def test_curl_predict_url():
131131
'curl -X POST "http://0.0.0.0:5000/v2/models/{}/predict/?urls={}" -H "accept: {}"'.format(
132132
module_name, quote_plus(test_url), content_type
133133
),
134-
shell=True,
134+
shell=False,
135135
check=True,
136136
stdout=subprocess.PIPE,
137137
).stdout
@@ -164,5 +164,5 @@ def test_curl_predict_url():
164164
test_curl_predict_url()
165165
r = subprocess.run(
166166
"kill $(ps aux | grep 'deepaas-run' | awk '{print $2}')",
167-
shell=True,
167+
shell=False,
168168
) # kill deepaas

posenetclas/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
import cv2
66
import numpy as np
7+
import tempfile
8+
79

810
from posenetclas.constants import CONNECTED_PART_INDICES
911

1012

1113
def create_tmp_folder(name=None):
1214
if name is None:
1315
name = datetime.now().strftime("%Y-%m-%d %H:%M:%S-%f")
14-
dir_path = os.path.join("/tmp", name)
16+
dir_path = os.path.join(tempfile.gettempdir(), name)
1517

1618
if os.path.isdir(dir_path):
1719
shutil.rmtree(dir_path)

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pytest-mock
55
pytest-env
66
flake8
77
bandit
8+
tensorflow==1.14

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
import pytest
1515

16-
import api
17-
16+
from posenetclas import api
1817

1918
@pytest.fixture(scope="session", autouse=True)
2019
def original_datapath():

tests/test_predictions/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def my_fixture2(request):
4141
import pytest
4242
from deepaas.model.v2.wrapper import UploadedFile
4343

44-
import api
44+
from posenetclas import api
4545

4646

4747
@pytest.fixture(scope="module", params=["t100-images.npy"])

tests/test_training/conftest.py

Lines changed: 0 additions & 75 deletions
This file was deleted.

tests/test_training/test_requirements.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)