Skip to content

Commit e1663e7

Browse files
committed
Refactor: SnapshotName
1 parent c926055 commit e1663e7

14 files changed

Lines changed: 270 additions & 56 deletions

File tree

.github/workflows/irc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push]
44

55
jobs:
66
notification:
7+
if: github.repository == 'moddevices/mod-ui'
78
runs-on: ubuntu-latest
89
name: IRC notification
910
steps:

.github/workflows/pylint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
pip3 install pylint
2020
- name: Run pylint
2121
run: |
22+
export MOD_DEV_HOST=1
23+
export MOD_DEV_ENVIRONMENT=0
24+
2225
virtualenv modui-env
2326
source modui-env/bin/activate
2427
pylint -E mod/*.py

.github/workflows/unittest.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: unittest
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
unittest:
7+
runs-on: ubuntu-22.04
8+
name: unittest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Install virtualenv
12+
run: |
13+
sudo apt install python3-virtualenv
14+
- name: Setup utils
15+
run: |
16+
sudo apt install python3-dev build-essential libasound2-dev libjack-jackd2-dev liblilv-dev libjpeg-dev zlib1g-dev
17+
make -C utils
18+
- name: Setup unittest
19+
run: |
20+
virtualenv modui-env
21+
source modui-env/bin/activate
22+
pip3 install -r requirements.txt
23+
# pytest
24+
pip3 install pytest pytest-cov
25+
sed -i -e 's/collections.MutableMapping/collections.abc.MutableMapping/' modui-env/lib/python3.10/site-packages/tornado/httputil.py
26+
# mod
27+
python3 setup.py develop
28+
- name: Run unittest
29+
run: |
30+
virtualenv modui-env
31+
source modui-env/bin/activate
32+
pytest --cov=mod --cov-report=html --cov-report=term --cov-report=xml
33+
- name: Archive coverage files
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: coverage
37+
path: |
38+
.coverage
39+
htmlcov/**
40+
cobertura.xml
41+
- name: Code Coverage Report
42+
uses: irongut/CodeCoverageSummary@v1.3.0
43+
with:
44+
filename: coverage.xml
45+
badge: true
46+
fail_below_min: true
47+
format: markdown
48+
hide_branch_rate: false
49+
hide_complexity: false
50+
indicators: true
51+
output: both
52+
thresholds: '15 30'
53+
- name: Add Coverage PR Comment
54+
uses: marocchino/sticky-pull-request-comment@v2
55+
if: github.event_name == 'pull_request'
56+
with:
57+
recreate: true
58+
path: code-coverage-results.md

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ utils/test
3737
*node_modules/
3838
.idea
3939
*.egg-info
40+
# Coverage
41+
.coverage
42+
coverage.xml
43+
htmlcov/

README.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,33 @@ And now you are ready to start the webserver::
5858

5959
Setting the environment variables is needed when developing on a PC.
6060
Open your browser and point to http://localhost:8888/.
61+
62+
Development
63+
-----------
64+
65+
The source code is expected to be ran on a Python 3.4 version.
66+
67+
The source code is organized with the following structure
68+
69+
* ``html``: Frontend source code
70+
* ``mod``: Backend source code
71+
* ``controller/``: Tornado related source code
72+
* ``rest/``: REST classes
73+
* ``websocket/``: web-socket classes
74+
* ``dto/``: Utility model representation
75+
* ``handler/``: Common tornado handlers
76+
* ``file_receiver/``: Common tornado file receivers
77+
* ``model/``: Model abstraction (snapshot, pedalboard, bank)
78+
* ``service/``: High level layer for ``mod-host`` usage
79+
* ``util/``: Common utility source code
80+
* ``settings.py``: Application parameters
81+
* ``host.py``: ``mod-host`` interface for communication with application
82+
* ``webserver.py``: Web-server initialization
83+
* ``modtools``:
84+
* ``test``: Python unit tests
85+
* ``utils``: C++ utility code
86+
87+
88+
Some IDEs can improve the code completion if you install mod-ui as an local packaged on virtualenv::
89+
90+
$ python3 setup.py develop

mod/controller/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
3+
# SPDX-License-Identifier: AGPL-3.0-or-later

mod/controller/handler/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
import json
5+
6+
from tornado.util import unicode_type
7+
8+
from mod.controller.handler.timeless_request_handler import TimelessRequestHandler
9+
10+
11+
class JsonRequestHandler(TimelessRequestHandler):
12+
def write(self, data):
13+
# FIXME: something is sending strings out, need to investigate what later..
14+
# it's likely something using write(json.dumps(...))
15+
# we want to prevent that as it causes issues under Mac OS
16+
17+
if isinstance(data, (bytes, unicode_type, dict)):
18+
TimelessRequestHandler.write(self, data)
19+
self.finish()
20+
return
21+
22+
elif data is True:
23+
data = "true"
24+
self.set_header("Content-Type", "application/json; charset=UTF-8")
25+
26+
elif data is False:
27+
data = "false"
28+
self.set_header("Content-Type", "application/json; charset=UTF-8")
29+
30+
# TESTING for data types, remove this later
31+
#elif not isinstance(data, list):
32+
#print("=== TESTING: Got new data type for RequestHandler.write():", type(data), "msg:", data)
33+
#data = json.dumps(data)
34+
#self.set_header('Content-type', 'application/json')
35+
36+
else:
37+
data = json.dumps(data)
38+
self.set_header("Content-Type", "application/json; charset=UTF-8")
39+
40+
TimelessRequestHandler.write(self, data)
41+
self.finish()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
from tornado import web
5+
6+
7+
class TimelessRequestHandler(web.RequestHandler):
8+
def compute_etag(self):
9+
return None
10+
11+
def set_default_headers(self):
12+
self._headers.pop("Date")
13+
14+
def should_return_304(self):
15+
return False

mod/controller/rest/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2012-2023 MOD Audio UG
3+
# SPDX-License-Identifier: AGPL-3.0-or-later

0 commit comments

Comments
 (0)