From 857743aacdbaff8f751b5be75ed68e4ef13c0e14 Mon Sep 17 00:00:00 2001 From: Artem Lavrenov Date: Sun, 28 Jun 2020 15:26:10 +0300 Subject: [PATCH] fix webserver bug --- .gitignore | 2 +- {otherjsmp => ordinaryjsmb}/SipNet.jsmb | 0 {otherjsmp => ordinaryjsmb}/StrelkaCard_Ru.jsmb | 0 {otherjsmp => ordinaryjsmb}/avtodor-tr.jsmb | 0 {otherjsmp => ordinaryjsmb}/beeline.jsmb | 0 {otherjsmp => ordinaryjsmb}/megafon.jsmb | 0 .../mts_20200229-used.jsmb | 0 {otherjsmp => ordinaryjsmb}/readme.md | 0 {otherjsmp => ordinaryjsmb}/smile-net.jsmb | 0 {otherjsmp => ordinaryjsmb}/tele2-api.jsmb | 0 plugin/dbengine.py | 2 ++ plugin/httpserver_mobile.py | 15 ++++++++++++--- 12 files changed, 15 insertions(+), 4 deletions(-) rename {otherjsmp => ordinaryjsmb}/SipNet.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/StrelkaCard_Ru.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/avtodor-tr.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/beeline.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/megafon.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/mts_20200229-used.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/readme.md (100%) rename {otherjsmp => ordinaryjsmb}/smile-net.jsmb (100%) rename {otherjsmp => ordinaryjsmb}/tele2-api.jsmb (100%) diff --git a/.gitignore b/.gitignore index 4a3568e..c495372 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ BalanceHistory.sqlite balance.html plugin/personalsetting.py mbplugin*.zip -python-3.8.3-embed-win32_TKINTER.zip +python-*.zip dllplugin jsmblhplugin httpserver diff --git a/otherjsmp/SipNet.jsmb b/ordinaryjsmb/SipNet.jsmb similarity index 100% rename from otherjsmp/SipNet.jsmb rename to ordinaryjsmb/SipNet.jsmb diff --git a/otherjsmp/StrelkaCard_Ru.jsmb b/ordinaryjsmb/StrelkaCard_Ru.jsmb similarity index 100% rename from otherjsmp/StrelkaCard_Ru.jsmb rename to ordinaryjsmb/StrelkaCard_Ru.jsmb diff --git a/otherjsmp/avtodor-tr.jsmb b/ordinaryjsmb/avtodor-tr.jsmb similarity index 100% rename from otherjsmp/avtodor-tr.jsmb rename to ordinaryjsmb/avtodor-tr.jsmb diff --git a/otherjsmp/beeline.jsmb b/ordinaryjsmb/beeline.jsmb similarity index 100% rename from otherjsmp/beeline.jsmb rename to ordinaryjsmb/beeline.jsmb diff --git a/otherjsmp/megafon.jsmb b/ordinaryjsmb/megafon.jsmb similarity index 100% rename from otherjsmp/megafon.jsmb rename to ordinaryjsmb/megafon.jsmb diff --git a/otherjsmp/mts_20200229-used.jsmb b/ordinaryjsmb/mts_20200229-used.jsmb similarity index 100% rename from otherjsmp/mts_20200229-used.jsmb rename to ordinaryjsmb/mts_20200229-used.jsmb diff --git a/otherjsmp/readme.md b/ordinaryjsmb/readme.md similarity index 100% rename from otherjsmp/readme.md rename to ordinaryjsmb/readme.md diff --git a/otherjsmp/smile-net.jsmb b/ordinaryjsmb/smile-net.jsmb similarity index 100% rename from otherjsmp/smile-net.jsmb rename to ordinaryjsmb/smile-net.jsmb diff --git a/otherjsmp/tele2-api.jsmb b/ordinaryjsmb/tele2-api.jsmb similarity index 100% rename from otherjsmp/tele2-api.jsmb rename to ordinaryjsmb/tele2-api.jsmb diff --git a/plugin/dbengine.py b/plugin/dbengine.py index 4beb7e4..a768b26 100644 --- a/plugin/dbengine.py +++ b/plugin/dbengine.py @@ -187,6 +187,8 @@ def report(self,fields): rows = self.cur.execute(reportsql) headers = list(zip(*rows.description))[0] data = rows.fetchall() + # округляем float до 2х знаков + data = [tuple([(round(i, 2) if type(i) == float else i) for i in line]) for line in data] return headers,data def check_and_add_addition(self): diff --git a/plugin/httpserver_mobile.py b/plugin/httpserver_mobile.py index d982d94..4286528 100644 --- a/plugin/httpserver_mobile.py +++ b/plugin/httpserver_mobile.py @@ -10,6 +10,12 @@ lang='p' # Для плагинов на python преффикс lang всегда 'p' +HTML_NO_REPORT = '''Для того чтобы были доступны отчеты необходимо в mbplugin.ini включить запись результатов в sqlite базу
+sqlitestore = 1
Также можно настроить импорт из базы BalanceHistory.mdb включив
+createhtmlreport = 1
+После включения, запустите mbplugin\setup_and_check.bat +''' + def find_ini_up(fn): allroot = [os.getcwd().rsplit('\\',i)[0] for i in range(len(os.getcwd().split('\\')))] all_ini = [i for i in allroot if os.path.exists(os.path.join(i,fn))] @@ -125,8 +131,7 @@ def getreport(param=[]): el = '' if he != 'Balance' and (el == 0.0 or el == 0): el = '' - html_line.append( - f'<{"th" if he=="NN" else "td"} id="{he}"{mark}>{el}') + html_line.append(f'<{"th" if he=="NN" else "td"} id="{he}"{mark}>{el}') html_table.append(f'{"".join(html_line)}') res = template.format(style=style, html_header=html_header, html_table='\n'.join(html_table)) return 'text/html', [res] @@ -287,7 +292,11 @@ def simple_app(self,environ, start_response): if cmd.lower() == 'getbalance': ct, text = getbalance(param) # TODO !!! Но правильно все-таки через POST if cmd == '' or cmd == 'report': # report - ct, text = getreport(param) + options = store.read_ini()['Options'] + if options['sqlitestore'] == '1': + ct, text = getreport(param) + else: + ct, text = 'text/html', HTML_NO_REPORT if cmd == 'exit': # exit cmd self.cmdqueue.put('STOP') text = ['exit']