bugfix
This commit is contained in:
parent
c493ab6a0f
commit
e51ef48a30
@ -409,7 +409,7 @@ class Blocks:
|
|||||||
desc, parenturl = self.getUrlData(opts,parenturl)
|
desc, parenturl = self.getUrlData(opts,parenturl)
|
||||||
if not isinstance(desc,dict):
|
if not isinstance(desc,dict):
|
||||||
print("getUrlData() return error data",opts,parenturl)
|
print("getUrlData() return error data",opts,parenturl)
|
||||||
alert(str(dict) + 'format error')
|
# alert(str(desc) + 'format error',title='widgetBuild()')
|
||||||
return None
|
return None
|
||||||
desc = self.valueExpr(desc)
|
desc = self.valueExpr(desc)
|
||||||
desc['parenturl'] = parenturl
|
desc['parenturl'] = parenturl
|
||||||
|
@ -37,30 +37,24 @@ def signal_handler(signal, frame):
|
|||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
|
||||||
class BlocksApp(App):
|
class BlocksApp(App):
|
||||||
def build(self):
|
def build(self):
|
||||||
x = PageContainer()
|
config = getConfig()
|
||||||
|
self.config = config
|
||||||
self.userinfo = {}
|
self.userinfo = {}
|
||||||
self.title = 'Test Title'
|
self.title = 'Test Title'
|
||||||
self.blocks = Blocks()
|
self.blocks = Blocks()
|
||||||
config = getConfig()
|
|
||||||
self.config = config
|
|
||||||
self.workers = Workers(maxworkers=config.maxworkers or 80)
|
self.workers = Workers(maxworkers=config.maxworkers or 80)
|
||||||
Window.bind(on_request_close=self.on_close)
|
Window.bind(on_request_close=self.on_close)
|
||||||
self.workers.start()
|
self.workers.start()
|
||||||
self.hc = HttpClient()
|
self.hc = HttpClient()
|
||||||
WindowBase.softinput_mode='below_target'
|
WindowBase.softinput_mode='below_target'
|
||||||
|
x = PageContainer()
|
||||||
Clock.schedule_once(self.build1)
|
Clock.schedule_once(self.build1)
|
||||||
print('build() called......')
|
print('build() called......')
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def setUserInfo(self,uinfo):
|
|
||||||
d = {}
|
|
||||||
d['userid'] = uinfo['userid']
|
|
||||||
d['password'] = uinfo.get('password','')
|
|
||||||
d['authcode'] = uinfo.get('authcode','')
|
|
||||||
self.userinfo = d
|
|
||||||
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
print('on_start() called ...')
|
print('on_start() called ...')
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class Form(BoxLayout):
|
|||||||
self.options = options
|
self.options = options
|
||||||
BoxLayout.__init__(self, orientation='vertical')
|
BoxLayout.__init__(self, orientation='vertical')
|
||||||
self.widget_ids = {}
|
self.widget_ids = {}
|
||||||
self.cols = self.options_cols = self.options['cols']
|
self.cols = self.options_cols = self.options.get('cols',1)
|
||||||
if isHandHold() and Window.width < Window.height:
|
if isHandHold() and Window.width < Window.height:
|
||||||
self.cols = 1
|
self.cols = 1
|
||||||
self.inputwidth = Window.width / self.cols
|
self.inputwidth = Window.width / self.cols
|
||||||
@ -217,8 +217,11 @@ class Form(BoxLayout):
|
|||||||
if self.initflag:
|
if self.initflag:
|
||||||
return
|
return
|
||||||
self.toolbar = Toolbar(ancestor=self,**self.options.get('toolbar',defaultToolbar()))
|
self.toolbar = Toolbar(ancestor=self,**self.options.get('toolbar',defaultToolbar()))
|
||||||
self.fsc = VResponsiveLayout(cols=self.cols,
|
self.fsc = VResponsiveLayout(
|
||||||
box_width=self.inputwidth)
|
self.inputwidth,
|
||||||
|
self.cols
|
||||||
|
)
|
||||||
|
print('box_width=%d,cols=%d' % (self.inputwidth, self.cols))
|
||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar)
|
||||||
self.add_widget(self.fsc)
|
self.add_widget(self.fsc)
|
||||||
self.register_event_type('on_submit')
|
self.register_event_type('on_submit')
|
||||||
|
@ -1,7 +1,27 @@
|
|||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
|
from kivy.core.window import Window
|
||||||
from kivy.uix.popup import Popup
|
from kivy.uix.popup import Popup
|
||||||
from appPublic.Singleton import SingletonDecorator
|
from appPublic.Singleton import SingletonDecorator
|
||||||
from appPublic.registerfunction import RegisterFunction
|
from appPublic.registerfunction import RegisterFunction
|
||||||
|
from appPublic.rsa import RSA
|
||||||
|
# from .form import Form
|
||||||
|
|
||||||
|
class ServerInfo:
|
||||||
|
def __init__(self):
|
||||||
|
self.rsaEngine = RSA()
|
||||||
|
config = getConfig()
|
||||||
|
url = '%s%s' % (config.uihome, config.publickey_url)
|
||||||
|
hc = App.get_running_app().hc
|
||||||
|
d = hc.get(url)
|
||||||
|
self.publickey = self.rsaEngine. publickeyFromText(d)
|
||||||
|
|
||||||
|
def encode(self,uinfo):
|
||||||
|
if uinfo['authmethod'] == 'password':
|
||||||
|
authinfo = '%s::%s::%s' % (uinfo['authmethod'], uinfo['userid'], uinfo['password'])
|
||||||
|
txt = self.serverinfo.encode(authinfo)
|
||||||
|
x = self.rsaEngine.encode(self.publickey, txt)
|
||||||
|
return x
|
||||||
|
return None
|
||||||
|
|
||||||
logformdesc = {
|
logformdesc = {
|
||||||
"widgettype":"Form",
|
"widgettype":"Form",
|
||||||
@ -39,39 +59,45 @@ logformdesc = {
|
|||||||
@SingletonDecorator
|
@SingletonDecorator
|
||||||
class LoginForm(Popup):
|
class LoginForm(Popup):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__(size_hint=(0.8,0.8))
|
||||||
|
|
||||||
app = App.get_running_app()
|
app = App.get_running_app()
|
||||||
|
print('here ..1............')
|
||||||
self.content = app.blocks.widgetBuild(logformdesc)
|
self.content = app.blocks.widgetBuild(logformdesc)
|
||||||
|
# self.content.bind(on_submit=setipUserInfo)
|
||||||
|
print('here ..2............',self.content)
|
||||||
self.title = 'login'
|
self.title = 'login'
|
||||||
self.blockCalls = []
|
self.blockCalls = []
|
||||||
self.open_status = False
|
self.open_status = False
|
||||||
|
print('here ..3............')
|
||||||
self.content.bind(on_submit=self.on_submit)
|
self.content.bind(on_submit=self.on_submit)
|
||||||
|
self.content.bind(on_cancel=self.on_submit)
|
||||||
def needlogin(self, url,method,params,headers,callback=None,errback=None):
|
print('here ..4............')
|
||||||
self.blockCalls.append([url, method, params,headers,callback,errback])
|
|
||||||
if self.open_status:
|
|
||||||
return
|
|
||||||
self.open_status = True
|
|
||||||
self.open()
|
self.open()
|
||||||
|
|
||||||
def recall(self):
|
|
||||||
app = App.get_running_app()
|
|
||||||
for url, method, params, headers,callback, errback in self.blockCalls:
|
|
||||||
app.hc(url, method=pethod,params=params,headers=headers,
|
|
||||||
callback=callback,errback=errback)
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.open_status = False
|
self.open_status = False
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
|
|
||||||
def on_submit(self,o,v):
|
def on_submit(self,o,v):
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
|
|
||||||
|
def on_cancel(self,o,v):
|
||||||
|
self.dismiss()
|
||||||
|
|
||||||
def setupUserInfo(userinfo):
|
def setupUserInfo(obj, userinfo):
|
||||||
app = App.get_running_app()
|
app = App.get_running_app()
|
||||||
app.setUserInfo(userinfo)
|
if not hasattr(app, 'serverinfo'):
|
||||||
lf = LoginForm()
|
app.serverinfo = ServerInfo()
|
||||||
lf.recall()
|
|
||||||
|
if userinfo.get('password',False):
|
||||||
|
userinfo['authmethod'] = 'password'
|
||||||
|
authinfo = app.serverinfo.encode(userinfo)
|
||||||
|
headers = {
|
||||||
|
"authorization":authinfo
|
||||||
|
}
|
||||||
|
login_url = '%s%s' % (app.config.uihome, app.config.login_url)
|
||||||
|
app.hc.get(login_url,headers=headers)
|
||||||
|
|
||||||
rf = RegisterFunction()
|
rf = RegisterFunction()
|
||||||
rf.register('setupUserInfo',setupUserInfo)
|
rf.register('setupUserInfo',setupUserInfo)
|
||||||
|
@ -53,7 +53,9 @@ class PageContainer(FloatLayout):
|
|||||||
return
|
return
|
||||||
w = self.pageWidgets[-1]
|
w = self.pageWidgets[-1]
|
||||||
try:
|
try:
|
||||||
w.beforeDestroy()
|
print(' ******* del last widget begin******')
|
||||||
|
del w
|
||||||
|
print(' ******* del last widget end ******')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.pageWidgets = self.pageWidgets[:-1]
|
self.pageWidgets = self.pageWidgets[:-1]
|
||||||
|
@ -14,6 +14,7 @@ class VResponsiveLayout(ScrollView):
|
|||||||
self.box_cols = cols
|
self.box_cols = cols
|
||||||
super(VResponsiveLayout, self).__init__(**kw)
|
super(VResponsiveLayout, self).__init__(**kw)
|
||||||
self.options = kw
|
self.options = kw
|
||||||
|
print('VResponsiveLayout():cols=',self.org_cols,'box_width=',self.box_width)
|
||||||
self._inner = GridLayout(cols=self.org_cols, padding=2,
|
self._inner = GridLayout(cols=self.org_cols, padding=2,
|
||||||
spacing=2,size_hint=(1,None))
|
spacing=2,size_hint=(1,None))
|
||||||
super(VResponsiveLayout,self).add_widget(self._inner)
|
super(VResponsiveLayout,self).add_widget(self._inner)
|
||||||
|
@ -123,7 +123,7 @@ class HttpClient:
|
|||||||
return cb(None,resp)
|
return cb(None,resp)
|
||||||
except NeedLogin as e:
|
except NeedLogin as e:
|
||||||
lf = LoginForm()
|
lf = LoginForm()
|
||||||
lf.needlogin(url,method,params,files,headers,callback,errback)
|
lf.open()
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if errback is not None:
|
if errback is not None:
|
||||||
|
@ -101,7 +101,7 @@ class Toolbar(GridLayout):
|
|||||||
opt.img_size = self.opts.img_size
|
opt.img_size = self.opts.img_size
|
||||||
opt.text_size = self.opts.text_size
|
opt.text_size = self.opts.text_size
|
||||||
purl = None
|
purl = None
|
||||||
if ancestor:
|
if ancestor and hasattr(ancestor, 'parenturl'):
|
||||||
purl = ancestor.parenturl
|
purl = ancestor.parenturl
|
||||||
opt.img_src = absurl(opt.img_src,purl)
|
opt.img_src = absurl(opt.img_src,purl)
|
||||||
tool = Tool(ancestor=ancestor, **opt)
|
tool = Tool(ancestor=ancestor, **opt)
|
||||||
|
@ -49,7 +49,7 @@ class VPlayer(FloatLayout):
|
|||||||
can_changevolume=True
|
can_changevolume=True
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.allow_screensaver = False
|
Window.allow_screensaver = False
|
||||||
print(self,vfile)
|
print(self,vfile)
|
||||||
self._video = Video(allow_stretch=True,pos_hint={'x': 0, 'y': 0},size_hint=(1,1))
|
self._video = Video(allow_stretch=True,pos_hint={'x': 0, 'y': 0},size_hint=(1,1))
|
||||||
self.add_widget(self._video)
|
self.add_widget(self._video)
|
||||||
@ -92,6 +92,16 @@ class VPlayer(FloatLayout):
|
|||||||
self._video.bind(on_touch_down=self.show_hide_menu)
|
self._video.bind(on_touch_down=self.show_hide_menu)
|
||||||
self.register_event_type('on_playend')
|
self.register_event_type('on_playend')
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
print('********** delete VPlayer instance ********')
|
||||||
|
self._video.state = 'stop'
|
||||||
|
if self.update_task:
|
||||||
|
self.update_task.cancel()
|
||||||
|
self.update_task = None
|
||||||
|
Window.allow_screensaver = True
|
||||||
|
del self._video
|
||||||
|
self._video = None
|
||||||
|
|
||||||
def play(self,o=None,v=None):
|
def play(self,o=None,v=None):
|
||||||
if self.curplay >= 0:
|
if self.curplay >= 0:
|
||||||
self._video.source = self.playlist[self.curplay]
|
self._video.source = self.playlist[self.curplay]
|
||||||
@ -168,11 +178,7 @@ class VPlayer(FloatLayout):
|
|||||||
|
|
||||||
def beforeDestroy(self):
|
def beforeDestroy(self):
|
||||||
try:
|
try:
|
||||||
self.pause()
|
del self
|
||||||
if self.update_task:
|
|
||||||
self.update_task.cancel()
|
|
||||||
self.update_task = None
|
|
||||||
del self._video
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
},
|
},
|
||||||
"font_name":"normal",
|
"font_name":"normal",
|
||||||
"uihome":"http://www.bsppo.com:10080",
|
"uihome":"http://www.bsppo.com:10080",
|
||||||
|
"i18n_url":"/public/i18n",
|
||||||
|
"publickey_url":"/public/publickey",
|
||||||
|
"login_url":"/public/publickey",
|
||||||
"udws":[
|
"udws":[
|
||||||
"/udw/udws.uidesc"
|
"/udw/udws.uidesc"
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user