Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
errorMsg = errorMsg.decode(encoding=appEncoding, errors="replace")
try:
with codecs.open(errorFile, mode="a", encoding=appEncoding) as fp:
fp.write("\n[%s] %s\n" % (
time.strftime("%Y-%m-%d %H:%M:%S"), errorMsg))
except:
print("[cefhello] WARNING: failed writing to error file: %s" % (
errorFile))
# Convert error message to ascii before printing, otherwise
# you may get error like this:
# | UnicodeEncodeError: 'charmap' codec can't encode characters
errorMsg = errorMsg.encode("ascii", errors="replace")
errorMsg = errorMsg.decode("ascii", errors="replace")
print("\n"+errorMsg+"\n")
cefpython.QuitMessageLoop()
cefpython.Shutdown()
os._exit(1)
errorMsg = errorMsg.decode(encoding=appEncoding, errors="replace")
try:
with codecs.open(errorFile, mode="a", encoding=appEncoding) as fp:
fp.write("\n[%s] %s\n" % (
time.strftime("%Y-%m-%d %H:%M:%S"), errorMsg))
except:
print("[wxpython.py] WARNING: failed writing to error file: %s" % (
errorFile))
# Convert error message to ascii before printing, otherwise
# you may get error like this:
# | UnicodeEncodeError: 'charmap' codec can't encode characters
errorMsg = errorMsg.encode("ascii", errors="replace")
errorMsg = errorMsg.decode("ascii", errors="replace")
print("\n"+errorMsg+"\n")
cefpython.QuitMessageLoop()
cefpython.Shutdown()
os._exit(1)
def init_browser(server_port):
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
cef.Initialize()
cef.CreateBrowserSync(url="http://localhost:{0}?user=admin&pwd=admin".format(str(server_port)),window_title="OmniDB")
cef.MessageLoop()
cef.Shutdown()
cherrypy.engine.exit()
errorMsg = errorMsg.decode(encoding=appEncoding, errors="replace")
try:
with codecs.open(errorFile, mode="a", encoding=appEncoding) as fp:
fp.write("\n[%s] %s\n" % (
time.strftime("%Y-%m-%d %H:%M:%S"), errorMsg))
except:
print("[pyqt.py] WARNING: failed writing to error file: %s" % (
errorFile))
# Convert error message to ascii before printing, otherwise
# you may get error like this:
# | UnicodeEncodeError: 'charmap' codec can't encode characters
errorMsg = errorMsg.encode("ascii", errors="replace")
errorMsg = errorMsg.decode("ascii", errors="replace")
print("\n"+errorMsg+"\n")
cefpython.QuitMessageLoop()
cefpython.Shutdown()
os._exit(1)
def Shutdown():
"""Shuts down CEF, should be called by app exiting code"""
DestroyMessageLoopTimer()
cefpython.Shutdown()
cef.g_commandLineSwitches = {'enable-media-stream': '','allow-universal-access-from-files':''}
cef.Initialize(settings={})
browser = cef.CreateBrowserSync(url='file:///'+os.path.join(oa.cur_dir,'part/display/index.html'),
window_title="Tutorial")
set_javascript_bindings(browser)
while oa.alive:
pars=get(timeout=.01)
cef.SingleMessageLoop()
yield ''
if pars is None:
continue
if isinstance(pars,str):
browser.ExecuteFunction('oa_msg',str(pars))
if isinstance(pars,(tuple,list)):
browser.ExecuteFunction(*pars)
cef.Shutdown()
if MAC:
# Issue #442 requires enabling message pump on Mac
# and calling message loop work in a timer both at
# the same time. This is an incorrect approach
# and only a temporary fix.
settings["external_message_pump"] = True
if WINDOWS:
# noinspection PyUnresolvedReferences, PyArgumentList
cef.DpiAware.EnableHighDpiSupport()
cef.Initialize(settings=settings)
app = CefApp(False)
app.MainLoop()
del app # Must destroy before calling Shutdown
if not MAC:
# On Mac shutdown is called in OnClose
cef.Shutdown()
def run_cef_gui(url_target, title):
check_versions()
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
cef.Initialize()
cef.CreateBrowserSync(url=url_target,
window_title=title)
cef.MessageLoop()
cef.Shutdown()
def shutdown_cef(self):
self.cefstream.get_logger().info("Shutting down CEF")
self.shutdown()
cef.Shutdown()