Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print('[cefhello] architecture=%s-bit' % (8 * struct.calcsize("P")))
print('[cefhello] wx.version=%s' % wx.version())
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
sys.excepthook = ExceptHook
# Application settings
g_applicationSettings = {
# Disk cache
# "cache_path": "webcache/",
# CEF Python debug messages in console and in log_file
"debug": True,
# Set it to LOGSEVERITY_VERBOSE for more details
"log_severity": cefpython.LOGSEVERITY_INFO,
# Set to "" to disable logging to a file
"log_file": GetApplicationPath("debug.log"),
# This should be enabled only when debugging
"release_dcheck_enabled": True,
# These directories must be set on Linux
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",
"resources_dir_path": cefpython.GetModuleDirectory(),
# The "subprocess" executable that launches the Renderer
# and GPU processes among others. You may rename that
# executable if you like.
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess"),
}
def OnExit(self, widget, data=None):
self.exiting = True
gtk.main_quit()
if __name__ == '__main__':
version = '.'.join(map(str, list(gtk.gtk_version)))
print('[pygtk_.py] GTK version: %s' % version)
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
sys.excepthook = ExceptHook
# Application settings
settings = {
"debug": True, # cefpython debug messages in console and in log_file
"log_severity": cefpython.LOGSEVERITY_INFO, # LOGSEVERITY_VERBOSE
"log_file": GetApplicationPath("debug.log"), # Set to "" to disable
# This directories must be set on Linux
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",
"resources_dir_path": cefpython.GetModuleDirectory(),
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess"),
}
cefpython.Initialize(settings)
cefpython.WindowUtils.InstallX11ErrorHandlers()
gobject.threads_init() # Timer for the message loop
PyGTKExample()
gtk.main()
cefpython.Shutdown()
# should not happen anymore.
self.timer.stop()
if __name__ == '__main__':
print("[pyqt.py] PyQt version: %s" % QtCore.PYQT_VERSION_STR)
print("[pyqt.py] QtCore version: %s" % QtCore.qVersion())
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
sys.excepthook = ExceptHook
# Application settings
settings = {
# "cache_path": "webcache/", # Disk cache
"debug": True, # cefpython debug messages in console and in log_file
"log_severity": cefpython.LOGSEVERITY_INFO, # LOGSEVERITY_VERBOSE
"log_file": GetApplicationPath("debug.log"), # Set to "" to disable.
"release_dcheck_enabled": True, # Enable only when debugging.
# This directories must be set on Linux
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",
"resources_dir_path": cefpython.GetModuleDirectory(),
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess")
}
# Command line switches set programmatically
switches = {
# "proxy-server": "socks5://127.0.0.1:8888",
# "enable-media-stream": "",
# "--invalid-switch": "" -> Invalid switch name
}
def Initialize(settings=None, debug=False):
"""Initializes CEF, We should do it before initializing wx
If no settings passed a default is used
"""
switches = {}
global g_settings
if not settings:
settings = {}
if not "log_severity" in settings:
settings["log_severity"] = cefpython.LOGSEVERITY_INFO
if not "log_file" in settings:
settings["log_file"] = ""
if platform.system() == "Linux":
# On Linux we need to set locales and resources directories.
if not "locales_dir_path" in settings:
settings["locales_dir_path"] = \
cefpython.GetModuleDirectory() + "/locales"
if not "resources_dir_path" in settings:
settings["resources_dir_path"] = cefpython.GetModuleDirectory()
elif platform.system() == "Darwin":
# On Mac we need to set the resoures dir and the locale_pak switch
if not "resources_dir_path" in settings:
settings["resources_dir_path"] = (cefpython.GetModuleDirectory()
+ "/Resources")
locale_pak = (cefpython.GetModuleDirectory()
print('[wxpython.py] architecture=%s-bit' % (8 * struct.calcsize("P")))
print('[wxpython.py] wx.version=%s' % wx.version())
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
sys.excepthook = ExceptHook
# Application settings
g_applicationSettings = {
# Disk cache
# "cache_path": "webcache/",
# CEF Python debug messages in console and in log_file
"debug": True,
# Set it to LOGSEVERITY_VERBOSE for more details
"log_severity": cefpython.LOGSEVERITY_INFO,
# Set to "" to disable logging to a file
"log_file": GetApplicationPath("debug.log"),
# This should be enabled only when debugging
"release_dcheck_enabled": True,
# "resources_dir_path" must be set on Mac, "locales_dir_path" not.
# You must also set "locale_pak" using command line switch.
"resources_dir_path": cefpython.GetModuleDirectory()+"/Resources",
# The "subprocess" executable that launches the Renderer
# and GPU processes among others. You may rename that
# executable if you like.
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess"),
# This option is required for the GetCookieManager callback
# to work. It affects renderer processes, when this option
def CefAdvanced():
sys.excepthook = ExceptHook
appSettings = dict()
# appSettings["cache_path"] = "webcache/" # Disk cache
if DEBUG:
# cefpython debug messages in console and in log_file
appSettings["debug"] = True
cefwindow.g_debug = True
appSettings["log_file"] = GetApplicationPath("debug.log")
appSettings["log_severity"] = cefpython.LOGSEVERITY_INFO
appSettings["browser_subprocess_path"] = "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess")
cefpython.Initialize(appSettings)
wndproc = {
win32con.WM_CLOSE: CloseWindow,
win32con.WM_DESTROY: QuitApplication,
win32con.WM_SIZE: cefpython.WindowUtils.OnSize,
win32con.WM_SETFOCUS: cefpython.WindowUtils.OnSetFocus,
win32con.WM_ERASEBKGND: cefpython.WindowUtils.OnEraseBackground
}
browserSettings = dict()
browserSettings["universal_access_from_file_urls_allowed"] = True
browserSettings["file_access_from_file_urls_allowed"] = True
def Initialize(settings=None, debug=False):
"""Initializes CEF, We should do it before initializing wx
If no settings passed a default is used
"""
switches = {}
global g_settings
if not settings:
settings = {}
if not "log_severity" in settings:
settings["log_severity"] = cefpython.LOGSEVERITY_INFO
if not "log_file" in settings:
settings["log_file"] = ""
if platform.system() == "Linux":
# On Linux we need to set locales and resources directories.
if not "locales_dir_path" in settings:
settings["locales_dir_path"] = \
cefpython.GetModuleDirectory() + "/locales"
if not "resources_dir_path" in settings:
settings["resources_dir_path"] = cefpython.GetModuleDirectory()
elif platform.system() == "Darwin":
# On Mac we need to set the resoures dir and the locale_pak switch
if not "resources_dir_path" in settings:
settings["resources_dir_path"] = (cefpython.GetModuleDirectory()
+ "/Resources")
locale_pak = (cefpython.GetModuleDirectory()
global connector
connector = None
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
# sys.excepthook = ExceptHook
# Application settings
g_applicationSettings = {
# Disk cache
# "cache_path": "webcache/",
# CEF Python debug messages in console and in log_file
"debug": True,
# Set it to LOGSEVERITY_VERBOSE for more details
"log_severity": cefpython.LOGSEVERITY_INFO,
# Set to "" to disable logging to a file
"log_file": GetLogPath("debug.log"),
# This should be enabled only when debugging
"release_dcheck_enabled": True,
# These directories must be set on Linux
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",
"resources_dir_path": cefpython.GetModuleDirectory(),
# The "subprocess" executable that launches the Renderer
# and GPU processes among others. You may rename that
# executable if you like.
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess"),
# This option is required for the GetCookieManager callback
# to work. It affects renderer processes, when this option
pass
return sources
if __name__ == '__main__':
print('[wxpython.py] wx.version=%s' % wx.version())
# Intercept python exceptions. Exit app immediately when exception
# happens on any of the threads.
sys.excepthook = ExceptHook
# Application settings
settings = {
# CEF Python debug messages in console and in log_file
"debug": True,
# Set it to LOGSEVERITY_VERBOSE for more details
"log_severity": cefpython.LOGSEVERITY_INFO,
# Set to "" to disable logging to a file
"log_file": GetApplicationPath("debug.log"),
# These directories must be set on Linux
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",
"resources_dir_path": cefpython.GetModuleDirectory(),
# The "subprocess" executable that launches the Renderer
# and GPU processes among others. You may rename that
# executable if you like.
"browser_subprocess_path": "%s/%s" % (
cefpython.GetModuleDirectory(), "subprocess"),
# This option is required for the GetCookieManager callback
# to work. It affects renderer processes, when this option
# is set to True. It will force a separate renderer process
# for each browser created using CreateBrowserSync.
"unique_request_context_per_browser": True,
# Downloads are handled automatically. A default SaveAs file
md = cefpython.GetModuleDirectory()
# Determine if default resources dir should be used or a custom
if self.resources_dir:
resources = self.resources_dir
else:
resources = md
def cef_loop(*largs):
cefpython.MessageLoopWork()
Clock.schedule_interval(cef_loop, 0)
settings = {
#"debug": True,
"log_severity": cefpython.LOGSEVERITY_INFO,
#"log_file": "debug.log",
"persist_session_cookies": True,
"release_dcheck_enabled": True, # Enable only when debugging.
"locales_dir_path": os.path.join(md, "locales"),
"browser_subprocess_path": "%s/%s" % (cefpython.GetModuleDirectory(), "subprocess")
}
cefpython.Initialize(settings, switches)
windowInfo = cefpython.WindowInfo()
windowInfo.SetAsOffscreen(0)
cefpython.SetGlobalClientCallback("OnCertificateError", self.OnCertificateError)
self.browser = cefpython.CreateBrowserSync(windowInfo, {}, navigateUrl=self.url)
# Set cookie manager
cookie_manager = cefpython.CookieManager.GetGlobalManager()
cookie_path = os.path.join(resources, "cookies")