Skip to content

Commit 8403842

Browse files
authored
Merge pull request #55 from hANSIc99/dev
v1.10 ready
2 parents 9db64ca + bbb182b commit 8403842

31 files changed

+674
-222
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
.pyc
22
setup.cfg
3+
4+
src/Pythonic/PythonicRPI.egg-info
5+
src/PythonicRPI.egg-info
6+
src/Pythonic.egg-info
7+
src/Pythonic/Pythonic.egg-info
8+
src/Pythonic/.vscode
9+
src/code-server/*.vsix
10+
src/code-server/*.rpm

CHANGES.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
1.10
2+
3+
SQLite element added
4+
Logging optimized
5+
Exception handling optimized
6+
17
1.9
28

39
EMail element added
4-
GUI now indicates if an element threw an exception
10+
GUI now indicates if an element threw an exception
11+
512

613
1.8
714

Containerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ RUN /usr/bin/python3 -m pip install pylint==2.7.4
7777
###################################
7878

7979

80-
COPY dist/Pythonic-1.9.tar.gz /
80+
COPY dist/Pythonic-1.10.tar.gz /
8181

82-
RUN /usr/bin/python3 -m pip install /Pythonic-1.9.tar.gz
82+
RUN /usr/bin/python3 -m pip install /Pythonic-1.10.tar.gz
8383

84-
RUN rm Pythonic-1.9.tar.gz
84+
RUN rm Pythonic-1.10.tar.gz
8585

8686
###################################
8787
# #

DOKU.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
1-
## Documentation
2-
1+
# Documentation
2+
3+
## General
4+
5+
### Terms
6+
7+
- Element
8+
- A logical, independent unit of executable code
9+
- Visualized on the GUI
10+
- Can be connected with other elements
11+
- Configuration Data
12+
- Element parameters passed over the GUI by the user
13+
- Input Data
14+
- Data which is forwarded from other elements (left connection)
15+
- Output Data
16+
- Data which is forwarded to other elements (right connection)
17+
18+
### Logging
19+
20+
The execution of elements is logged in a file that changes daily.
21+
The log files are archived under `~/Pythonic/log (Linux)` or `%HOMEPATH%\Pythonic\log` (Windows).
22+
Pythonic's web service provides an overview of available log files at **http://\<address-info>:7000/log**. Single log files can be accessed witch the following scheme: **http://\<address-info>:7000/\<year>_\<month>_\<day>.txt**.
23+
24+
- INFO
25+
- Ordinary debug trace messages
26+
- Can be switched on or off by the user (checkbox in element configuration)
27+
- Implementation in own code is optional
28+
- WARNING
29+
- Signalize a failed execution
30+
- Can be switched on or off by the user (checkbox in element configuration)
31+
- A log entry of this type is created when the element returns data of type PythonicError
32+
- Implementation in own code is optional
33+
- ERROR (Unhandled exception):
34+
- Caused by an unhandles exception
35+
- Is signalized in the GUI ("Exception occured, open log for details")
36+
- Is always active (implementation not optional)
37+
38+
### Exception handling
39+
40+
1. Elements should throw an exception when configuration data is missing or cannot be processed.
41+
2. Elements should try to handle all possible exceptions internally and only throw critical exceptions.
42+
3. The result of a operation (if successfull or not (see #2)) should always be forwarded to subsequent elements in order to react to a possible failed call. If the result of a failed call could be processed by an subsequent element, it should be wrapped in the `PythonicError` type.
43+
4. In case of a failed call, a meaningful message or the exception text should returned (`PythonicError` as data parameter in returned `Record` type)
44+
5. Don't to use `logging.error` or `logging.warning` as it has no effect if used in combination with multiprocessing.
45+
46+
## Elements
347

448
### Basic Elements
549

TODOS

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
1-
General:
2-
3-
Documentation:
4-
When an element returns None, subsequent
5-
elements are still triggered
6-
7-
Exceptions:
8-
Elements should throw an exception when configuration
9-
data is missing or cannot be processed
10-
11-
Elements should try to handle all possible exceptions internally
12-
and only throw unhandled exceptions
13-
14-
The result of a operation (if successfull or not) should
15-
be forwarded to subsequent elements in order to react to
16-
a possible unsuccesfull operation
17-
18-
When input data is required to perform some task and it
19-
is missing, elements should pass this information to subsequent elements
20-
and not throw an exception.d
21-
22-
23-
CCXT Method: Remove large if-else areas for parsing config
1+
CCXT Method: Try to optimize large if-else areas for parsing config
242

253
Python: Add type hints
264

275
Check if the 'inline'-keyword can be applied to some loops
286
(page 146 C++ Der Programmierer)
297

8+
Telegram: Return error element when chat id is removed?
309

3110
Elementeditor:
3211
Add the possibility to pass arbitrary number of keyword arguments or
3312
to build a dictionary from within the editor
3413

35-
14+
Testing:
15+
Create Unit test for every element
16+
Create test project

dist/Pythonic-1.10.tar.gz

5.14 MB
Binary file not shown.

dist/PythonicRPI-1.10.tar.gz

5.14 MB
Binary file not shown.

examples/generic_pipe_0e7b8360.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import time, queue
2+
from random import randrange
3+
try:
4+
from element_types import Record, Function, ProcCMD, GuiCMD
5+
except ImportError:
6+
from Pythonic.element_types import Record, Function, ProcCMD, GuiCMD
7+
8+
class Element(Function):
9+
10+
def __init__(self, id, config, inputData, return_queue, cmd_queue):
11+
super().__init__(id, config, inputData, return_queue, cmd_queue)
12+
13+
14+
def execute(self):
15+
16+
17+
#####################################
18+
# #
19+
# REFERENCE IMPLEMENTATION #
20+
# #
21+
#####################################
22+
23+
24+
# list all tables
25+
# SELECT name FROM sqlite_master WHERE type='table'
26+
27+
# create table of not exist
28+
# CREATE TABLE IF NOT EXISTS my_table (timestamp INTEGER PRIMARY KEY NOT NULL, value UNSIGNED BIG INT);
29+
30+
# insert into table
31+
# INSERT INTO my_table VALUES (?, ?)
32+
#
33+
# epoch in seconds: int(timer.time())
34+
# random int: randrange(999)
35+
36+
# Read from table several rows
37+
# SELECT * FROM my_table WHERE timestamp BETWEEN {} AND {}'.format( int(time.time())-12000, int(time.time()) )
38+
39+
# Sumup severals rows
40+
# SELECT SUM(value) FROM mytable WHERE timestamp BETWEEN {} AND {}
41+
42+
output = 'SELECT SUM(value) FROM my_table WHERE timestamp BETWEEN {} AND {}'.format(int(time.time())-12000, int(time.time()))
43+
44+
45+
46+
#########################################
47+
# #
48+
# The execution exits immediately #
49+
# after providing output data #
50+
# #
51+
#########################################
52+
53+
recordDone = Record(output, 'Sending value of cnt: {}'.format(output))
54+
self.return_queue.put(recordDone)

setup_rpi.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ install_requires =
77
debugpy==1.3.0
88
python-telegram-bot==13.4.1
99
ccxt>=1.37.59
10+
openpyxl>=3.0.9
1011
gpiozero>=1.6.2

setup_rpi.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
setuptools.setup(
8-
version = '1.09',
8+
version = '1.10',
99
author = 'Stephan Avenwedde',
1010
author_email = '[email protected]',
1111
license = 'GPLv3',
@@ -30,6 +30,7 @@
3030
'public_html/static/Email.png',
3131
'public_html/static/CCXT.png',
3232
'public_html/static/CCXT_Method.png',
33+
'public_html/static/SQLite.png',
3334
'public_html/static/python.ico',
3435
'public_html/static/qtlogo.svg',
3536
'public_html/static/qtloader.js',
@@ -38,7 +39,12 @@
3839
'public_html/static/*.data',
3940
'public_html/templates/*.html',
4041
'public_html/config/Toolbox/0Basic/*',
41-
'public_html/config/Toolbox/1IO/*',
42+
'public_html/config/Toolbox/1IO/1GPIO_Write.json',
43+
'public_html/config/Toolbox/1IO/GPIO_Write.editor',
44+
'public_html/config/Toolbox/1IO/0GPIO_Read.json',
45+
'public_html/config/Toolbox/1IO/GPIO_Read.editor',
46+
'public_html/config/Toolbox/1IO/2SQLite.json',
47+
'public_html/config/Toolbox/1IO/SQLite.editor',
4248
'public_html/config/Toolbox/2Connectivity/Telegram.editor',
4349
'public_html/config/Toolbox/2Connectivity/0Telegram.json',
4450
'public_html/config/Toolbox/2Connectivity/EMail.editor',

0 commit comments

Comments
 (0)