mirror of
https://github.com/Screenly/Anthias.git
synced 2026-05-07 06:45:23 -04:00
some fixes for stuck when alert
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
set show_status = 0
|
||||
set ssl_verify = 1
|
||||
set ssl_verify = 1
|
||||
set on_event = request ON_EVENT
|
||||
|
||||
@on_event LOAD_START js alert=function(e){return true};confirm=function(e){return true};prompt=function(e){return true};
|
||||
@on_event LOAD_COMMIT js alert=function(e){return true};confirm=function(e){return true};prompt=function(e){return true};
|
||||
|
||||
24
viewer.py
24
viewer.py
@@ -44,6 +44,7 @@ INTRO = '/screenly/intro-template.html'
|
||||
|
||||
current_browser_url = None
|
||||
browser = None
|
||||
browser_focus_lost = False
|
||||
|
||||
VIDEO_TIMEOUT = 20 # secs
|
||||
|
||||
@@ -175,13 +176,14 @@ class Scheduler(object):
|
||||
# Try to keep the same position in the play list. E.g. if a new asset is added to the end of the list, we
|
||||
# don't want to start over from the beginning.
|
||||
self.index = self.index % len(self.assets) if self.assets else 0
|
||||
logging.debug('update_playlist done, count %s, counter %s, index %s, deadline %s', len(self.assets), self.counter, self.index, self.deadline)
|
||||
logging.debug('update_playlist done, count %s, counter %s, index %s, deadline %s', len(self.assets),
|
||||
self.counter, self.index, self.deadline)
|
||||
|
||||
def get_db_mtime(self):
|
||||
# get database file last modification time
|
||||
try:
|
||||
return path.getmtime(settings['database'])
|
||||
except:
|
||||
except (OSError, TypeError):
|
||||
return 0
|
||||
|
||||
|
||||
@@ -240,13 +242,21 @@ def load_browser(url=None):
|
||||
|
||||
|
||||
def browser_send(command, cb=lambda _: True):
|
||||
global browser_focus_lost
|
||||
if not (browser is None) and browser.process.alive:
|
||||
while not browser.process._pipe_queue.empty(): # flush stdout
|
||||
browser.next()
|
||||
|
||||
browser.process.stdin.put(command + '\n')
|
||||
while True: # loop until cb returns True
|
||||
if cb(browser.next()):
|
||||
try:
|
||||
event = browser.next()
|
||||
except StopIteration:
|
||||
break
|
||||
if 'FOCUS_LOST' in event:
|
||||
browser_focus_lost = True
|
||||
break
|
||||
if cb(event):
|
||||
break
|
||||
else:
|
||||
logging.info('browser found dead, restarting')
|
||||
@@ -374,6 +384,7 @@ def load_settings():
|
||||
|
||||
|
||||
def asset_loop(scheduler):
|
||||
global browser_focus_lost
|
||||
disable_update_check = getenv("DISABLE_UPDATE_CHECK", False)
|
||||
if not disable_update_check:
|
||||
check_update()
|
||||
@@ -395,7 +406,7 @@ def asset_loop(scheduler):
|
||||
elif 'web' in mime:
|
||||
# FIXME If we want to force periodic reloads of repeated web assets, force=True could be used here.
|
||||
# See e38e6fef3a70906e7f8739294ffd523af6ce66be.
|
||||
browser_url(uri)
|
||||
browser_url(uri, cb=lambda b: 'LOAD_FINISH' in b)
|
||||
elif 'video' or 'streaming' in mime:
|
||||
view_video(uri, asset['duration'])
|
||||
else:
|
||||
@@ -405,6 +416,9 @@ def asset_loop(scheduler):
|
||||
duration = int(asset['duration'])
|
||||
logging.info('Sleeping for %s', duration)
|
||||
sleep(duration)
|
||||
if browser_focus_lost:
|
||||
browser_focus_lost = False
|
||||
browser_send('exit')
|
||||
else:
|
||||
logging.info('Asset %s at %s is not available, skipping.', asset['name'], asset['uri'])
|
||||
sleep(0.5)
|
||||
@@ -458,6 +472,6 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
except Exception:
|
||||
logging.exception("Viewer crashed.")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user