This commit is contained in:
yumoqing 2022-09-13 15:50:26 +08:00
parent 35c5cd3452
commit dad54583e7
2 changed files with 24 additions and 0 deletions

View File

@ -26,12 +26,14 @@ from .register import *
from .threadcall import HttpClient,Workers
from .utils import *
from .widget_css import register_css
from .version import __version__
if platform == 'android':
from jnius import autoclass
from .android_rotation import get_rotation
Logger.info(f'KivyBlocks:version={__version__}')
def signal_handler(signal, frame):
app = App.get_running_app()
if app is None:
@ -42,6 +44,7 @@ def signal_handler(signal, frame):
signal.signal(signal.SIGINT, signal_handler)
class BlocksApp(App):
def get_rotation(self):
return get_rotation()

View File

@ -1,3 +1,4 @@
import os
import traceback
try:
import ujson as json
@ -10,6 +11,9 @@ from appPublic.myTE import MyTemplateEngine
from appPublic.Singleton import SingletonDecorator
from appPublic.dictObject import DictObject
from kivy.logger import Logger
from kivy.utils import platform
@SingletonDecorator
class ScriptEnv(DictObject):
pass
@ -32,6 +36,20 @@ class Script:
url = url[7:]
return join(self.root, *url.split('/'))
def show_info(self, env):
workdir = env['workdir']
sfile = env['filepath']
url = env['url']
Logger.info(f'script:workdir={workdir}')
Logger.info(f'script:script_file={sfile}')
Logger.info(f'script:url={url}')
sdir = os.path.join(workdir, 'scripts')
sf_exists = os.path.isdir(sdir)
conf_f = os.path.join(workdir, 'conf', 'config.json')
conf_exists = os.path.isfile(conf_f)
Logger.info(f'script:script exists {sf_exists}')
Logger.info(f'script:config.json exists {conf_exists}')
def dispatch(self, url, **kw):
filepath = self.url2filepath(url)
for suffix, handler in self.handlers.items():
@ -42,6 +60,9 @@ class Script:
env['root_path'] = self.root
env['url'] = url
env['filepath'] = filepath
# if platform == 'android':
self.show_info(env)
h = handler(env)
d = h.render()
try: