Skip to content

Commit 2ec622c

Browse files
authored
Merge pull request #53 from hANSIc99/dev
v1.9 ready
2 parents 8b4e933 + a7ee8cb commit 2ec622c

27 files changed

+419
-339
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.9
2+
3+
4+
15
1.8
26

37
CCXT: Fixed bug querying OHLCV data

Containerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Full multi-processing and multi-threading capable.
1010
#
1111
#
12-
#CreationDate: 05.04.2021
12+
#CreationDate: 10.11.2021
1313
#Creator: Stephan Avenwedde
1414
#
1515
#
@@ -77,11 +77,11 @@ RUN /usr/bin/python3 -m pip install pylint==2.7.4
7777
###################################
7878

7979

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

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

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

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

TODOS

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
General:
22

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+
323
CCXT Method: Remove large if-else areas for parsing config
424

525
Python: Add type hints
626

727
Check if the 'inline'-keyword can be applied to some loops
828
(page 146 C++ Der Programmierer)
929

10-
Use dispatch tables instead of switch-case / if elif pattern
1130

1231
Elementeditor:
1332
Add the possibility to pass arbitrary number of keyword arguments or
1433
to build a dictionary from within the editor
1534

1635

17-
element_types.py
18-
execute_ex() :
19-
- Signaliye an exception in the GUI
20-
- Remove return value as it is not processed
21-

build_rpi.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
# BUILD WASM FRONTEND
4+
5+
#src/Pythonic/build.sh
6+
7+
8+
# BUILD PIP PACKAGE RPI
9+
cp setup_rpi.py setup.py
10+
cp setup_rpi.cfg setup.cfg
11+
python3 setup.py sdist
12+
13+
# DOWNLOAD CODE SERVER EXTENSIONS
14+
#src/code-server/download.sh
15+
16+
# BUILD CONTAINER IMAGE
17+
#podman build -t pythonicautomation/pythonic:1.7 .

build.sh renamed to build_x86.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ cp setup_x86.py setup.py
99
cp setup_x86.cfg setup.cfg
1010
python3 setup.py sdist
1111

12-
# BUILD PIP PACKAGE x86
13-
cp setup_rpi.py setup.py
14-
cp setup_rpi.cfg setup.cfg
15-
python3 setup.py sdist
1612

1713
# DOWNLOAD CODE SERVER EXTENSIONS
1814
#src/code-server/download.sh

dist/Pythonic-1.9.tar.gz

5.15 MB
Binary file not shown.

dist/PythonicRPI-1.9.tar.gz

5.14 MB
Binary file not shown.

setup.py

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

66

77
setuptools.setup(
8-
version = '1.06',
8+
version = '1.09',
99
author = 'Stephan Avenwedde',
1010
author_email = '[email protected]',
1111
license = 'GPLv3',
@@ -24,6 +24,8 @@
2424
'public_html/static/GenericPipe.png',
2525
'public_html/static/GenericProcess.png',
2626
'public_html/static/ProcessPipe.png',
27+
'public_html/static/GPIO_Read.png',
28+
'public_html/static/GPIO_Write.png',
2729
'public_html/static/Telegram.png',
2830
'public_html/static/CCXT.png',
2931
'public_html/static/CCXT_Method.png',
@@ -35,6 +37,7 @@
3537
'public_html/static/*.data',
3638
'public_html/templates/*.html',
3739
'public_html/config/Toolbox/0Basic/*',
40+
'public_html/config/Toolbox/1IO/*',
3841
'public_html/config/Toolbox/2Connectivity/Telegram.editor',
3942
'public_html/config/Toolbox/2Connectivity/0Telegram.json',
4043
'public_html/config/Toolbox/3Trading/*'
@@ -61,4 +64,4 @@
6164
'Natural Language :: English',
6265
'Topic :: Software Development'
6366
],
64-
)
67+
)

setup_rpi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
setuptools.setup(
8-
version = '1.08',
8+
version = '1.09',
99
author = 'Stephan Avenwedde',
1010
author_email = '[email protected]',
1111
license = 'GPLv3',
@@ -27,6 +27,7 @@
2727
'public_html/static/GPIO_Read.png',
2828
'public_html/static/GPIO_Write.png',
2929
'public_html/static/Telegram.png',
30+
'public_html/static/Email.png',
3031
'public_html/static/CCXT.png',
3132
'public_html/static/CCXT_Method.png',
3233
'public_html/static/python.ico',
@@ -40,6 +41,8 @@
4041
'public_html/config/Toolbox/1IO/*',
4142
'public_html/config/Toolbox/2Connectivity/Telegram.editor',
4243
'public_html/config/Toolbox/2Connectivity/0Telegram.json',
44+
'public_html/config/Toolbox/2Connectivity/EMail.editor',
45+
'public_html/config/Toolbox/2Connectivity/1EMail.json',
4346
'public_html/config/Toolbox/3Trading/*'
4447
]
4548
},

setup_x86.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
setuptools.setup(
8-
version = '1.08',
8+
version = '1.09',
99
author = 'Stephan Avenwedde',
1010
author_email = '[email protected]',
1111
license = 'GPLv3',
@@ -25,6 +25,7 @@
2525
'public_html/static/GenericProcess.png',
2626
'public_html/static/ProcessPipe.png',
2727
'public_html/static/Telegram.png',
28+
'public_html/static/Email.png',
2829
'public_html/static/CCXT.png',
2930
'public_html/static/CCXT_Method.png',
3031
'public_html/static/python.ico',
@@ -37,6 +38,8 @@
3738
'public_html/config/Toolbox/0Basic/*',
3839
'public_html/config/Toolbox/2Connectivity/Telegram.editor',
3940
'public_html/config/Toolbox/2Connectivity/0Telegram.json',
41+
'public_html/config/Toolbox/2Connectivity/EMail.editor',
42+
'public_html/config/Toolbox/2Connectivity/1EMail.json',
4043
'public_html/config/Toolbox/3Trading/*'
4144
]
4245
},

src/Pythonic/element_types.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def execute_ex(self):
3131
try:
3232
result = self.execute()
3333
except Exception as e:
34-
self.logger.error(e)
34+
guiexc = GuiException()
35+
self.return_queue.put(guiexc)
36+
self.logger.error(repr(e))
3537
# signalize exception on GUI
36-
result = e
3738

38-
return result
3939

4040
class Record():
4141

@@ -64,6 +64,8 @@ def __setstate__(self, state):
6464
def __getstate__(self):
6565
return(self.text)
6666

67+
class GuiException:
68+
pass
6769

6870
class ProcCMD:
6971

src/Pythonic/elementeditor.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,14 @@ void Elementeditor::loadEditorConfig(const QJsonArray config)
191191
}
192192

193193
case ElementEditorTypes::LineEdit2: {
194-
addLineEdit2(unit);
194+
addLineEdit2(unit, false);
195195
break;
196196
}
197+
case ElementEditorTypes::PwEdit2: {
198+
addLineEdit2(unit, true);
199+
break;
200+
}
201+
197202
case ElementEditorTypes::CheckBox: {
198203
addCheckBox(unit);
199204
break;
@@ -238,6 +243,7 @@ ElementEditorTypes::Type Elementeditor::hashType(const QString &inString)
238243
if(inString == QStringLiteral("ComboBox")) return ElementEditorTypes::ComboBox;
239244
if(inString == QStringLiteral("LineEdit")) return ElementEditorTypes::LineEdit;
240245
if(inString == QStringLiteral("LineEdit2")) return ElementEditorTypes::LineEdit2;
246+
if(inString == QStringLiteral("PwEdit2")) return ElementEditorTypes::PwEdit2;
241247
if(inString == QStringLiteral("CheckBox")) return ElementEditorTypes::CheckBox;
242248
if(inString == QStringLiteral("Text")) return ElementEditorTypes::Text;
243249
if(inString == QStringLiteral("HelpText")) return ElementEditorTypes::HelpText;
@@ -651,7 +657,7 @@ void Elementeditor::addLineEdit(const QJsonObject &lineeditJSON)
651657
addRules(lineeditJSON.value(QStringLiteral("Dependency")), qobject_cast<QWidget*>(lineedit));
652658
}
653659

654-
void Elementeditor::addLineEdit2(const QJsonObject &lineeditJSON)
660+
void Elementeditor::addLineEdit2(const QJsonObject &lineeditJSON, bool pw)
655661
{
656662
qCInfo(logC, "called %s", parent()->objectName().toStdString().c_str());
657663

@@ -675,6 +681,12 @@ void Elementeditor::addLineEdit2(const QJsonObject &lineeditJSON)
675681
lineedit->m_lineedit.setText(defaultText);
676682
}
677683

684+
/* Enabling echo mode for passwords */
685+
if(pw){
686+
lineedit->m_lineedit.setEchoMode(QLineEdit::Password);
687+
}
688+
689+
678690
/* Adding RegExp (if given) */
679691

680692
QString regExpString = lineeditJSON[QStringLiteral("RegExp")].toString();

src/Pythonic/elementeditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ namespace ElementEditorTypes {
6363
ComboBox,
6464
LineEdit,
6565
LineEdit2,
66+
PwEdit2,
6667
CheckBox,
6768
Text,
6869
HelpText,
@@ -281,7 +282,7 @@ public slots:
281282

282283
void addLineEdit(const QJsonObject &lineeditJSON);
283284

284-
void addLineEdit2(const QJsonObject &lineeditJSON);
285+
void addLineEdit2(const QJsonObject &lineeditJSON, bool pw);
285286

286287
void addCheckBox(const QJsonObject &checkboxJSON);
287288

src/Pythonic/elementmaster.cpp

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ ElementMaster::ElementMaster(const QJsonObject configuration,
5555

5656
/* Create the basic data */
5757

58-
//m_hasSocket = m_config[QStringLiteral("Socket")].toBool();
59-
6058
/* Create default general config if not defined */
6159

6260
QJsonValue generalConfig = m_config.value(QStringLiteral("Config"));
@@ -303,7 +301,6 @@ void ElementMaster::fwrdWsCtrl(const QJsonObject cmd)
303301
};
304302
newCmd["address"] = address;
305303

306-
307304
emit wsCtrl(newCmd);
308305
}
309306

@@ -312,17 +309,46 @@ ElementMasterCmd::Command ElementMaster::hashCmd(const QString &inString)
312309
if(inString == QStringLiteral("ElementEditorConfig")) return ElementMasterCmd::ElementEditorConfig;
313310
if(inString == QStringLiteral("UpdateElementStatus")) return ElementMasterCmd::UpdateElementStatus;
314311
if(inString == QStringLiteral("ElementText")) return ElementMasterCmd::ElementText;
312+
if(inString == QStringLiteral("ElementException")) return ElementMasterCmd::ElementException;
315313
if(inString == QStringLiteral("Test")) return ElementMasterCmd::Test;
316314
return ElementMasterCmd::NoCmd;
317315
}
318316

317+
void ElementMaster::ShowText(const QString &inString)
318+
{
319+
if(!m_hasException){
320+
m_textLabel.setStyleSheet(QStringLiteral("background-color: #ffffca; border: 1px solid black;"));
321+
m_text.setVisible(true);
322+
m_textLabel.setText(inString);
323+
}
324+
}
325+
326+
void ElementMaster::HideText()
327+
{
328+
if(!m_hasException){
329+
m_text.setVisible(false);
330+
}
331+
}
332+
333+
void ElementMaster::ShowException(const QString &ts)
334+
{
335+
m_text.setVisible(true);
336+
m_textLabel.setStyleSheet(QStringLiteral("background-color: #ff0000; color: #ffffff; border: 1px solid black;"));
337+
m_textLabel.setText(ts + QStringLiteral("\nExecption occured, open log for details"));
338+
m_hasException = true;
339+
}
340+
341+
void ElementMaster::HideException()
342+
{
343+
m_hasException = false;
344+
m_text.setVisible(false);
345+
}
346+
319347
void ElementMaster::fwrdWsRcv(const QJsonObject cmd)
320348
{
321349
qCInfo(logC, "called %s", objectName().toStdString().c_str());
322350

323351
QJsonObject address = cmd[QStringLiteral("address")].toObject();
324-
//QLatin1String strCmd( cmd[QStringLiteral("cmd")].toString().toLatin1(),
325-
// cmd[QStringLiteral("cmd")].toString().size());
326352

327353
switch (hashCmd(cmd[QStringLiteral("cmd")].toString())) {
328354

@@ -342,8 +368,12 @@ void ElementMaster::fwrdWsRcv(const QJsonObject cmd)
342368
}
343369
case ElementMasterCmd::ElementText: {
344370
QString text = cmd[QStringLiteral("data")].toString();
345-
m_text.setVisible(true);
346-
m_textLabel.setText(text);
371+
ShowText(text);
372+
break;
373+
}
374+
case ElementMasterCmd::ElementException: {
375+
QString ts = cmd[QStringLiteral("TS")].toString();
376+
ShowException(ts);
347377
break;
348378
}
349379

@@ -357,9 +387,11 @@ void ElementMaster::fwrdWsRcv(const QJsonObject cmd)
357387
void ElementMaster::openEditor()
358388
{
359389
qCInfo(logC, "called %s", objectName().toStdString().c_str());
390+
HideException();
360391
/* A default general config is created in the constructor */
361392
/* The specific config contains nothing when this is called the first time */
362393
m_editor->openEditor(m_customConfig);
394+
363395
}
364396

365397
void ElementMaster::switchRunState(bool state)
@@ -372,7 +404,7 @@ void ElementMaster::switchRunState(bool state)
372404
} else {
373405
m_symbol.setStyleSheet(styleSheet());
374406
m_startBtn.togggleRunning(false);
375-
m_text.setVisible(false);
407+
HideText();
376408
}
377409

378410
/* Element has a start button instead of a socket */

0 commit comments

Comments
 (0)