Esempio n. 1
0
def _init_plugins():
    global _enable_default_log
    global _plugin_init
    if not _plugin_init:
        # The first call to BNInitCorePlugins returns True for successful initialization and True in this context indicates headless operation.
        is_headless = not core.BNIsUIEnabled()
        min_level = Settings().get_string("python.log.minLevel")
        if _enable_default_log and is_headless and min_level in LogLevel.__members__ and not core_ui_enabled(
        ) and sys.stderr.isatty():
            log_to_stderr(LogLevel[min_level])
        core.BNInitPlugins(not os.environ.get('BN_DISABLE_USER_PLUGINS'))
        core.BNInitRepoPlugins()
    if core.BNIsLicenseValidated():
        _plugin_init = True
    else:
        raise RuntimeError(
            "License is not valid. Please supply a valid license.")
Esempio n. 2
0

_destruct_callbacks = _DestructionCallbackHandler()

bundled_plugin_path = core.BNGetBundledPluginDirectory()
user_plugin_path = core.BNGetUserPluginDirectory()

core_version = core.BNGetVersionString()
'''Core version'''

core_build_id = core.BNGetBuildId()
'''Build ID'''

core_serial = core.BNGetSerialNumber()
'''Serial Number'''

core_expires = gmtime(core.BNGetLicenseExpirationTime())
'''License Expiration'''

core_product = core.BNGetProduct()
'''Product string from the license file'''

core_product_type = core.BNGetProductType()
'''Product type from the license file'''

core_license_count = core.BNGetLicenseCount()
'''License count from the license file'''

core_ui_enabled = core.BNIsUIEnabled()
'''Indicates that a UI exists and the UI has invoked BNInitUI'''
Esempio n. 3
0
def core_ui_enabled():
	'''Indicates that a UI exists and the UI has invoked BNInitUI'''
	return core.BNIsUIEnabled()
        result = core.BNCreateDownloadProviderInstance(self.handle)
        if result is None:
            return None
        return DownloadInstance(self, handle=result)


_loaded = False

try:
    import requests
    if sys.platform != "win32":
        try:
            from requests import pyopenssl  # type: ignore
        except:
            pass
    elif core.BNIsUIEnabled():
        try:
            # since requests will use urllib behind the scenes, which will use
            # the openssl statically linked into _ssl.pyd, the first connection made
            # will attempt to walk the entire process heap on windows using Heap32First
            # and Heap32Next, which is O(n^2) in heap allocations. by doing this now,
            # earlier and before threads are started, hopefully we dodge some of the impact.
            # this should also help with some issues where when Heap32First fails to walk the
            # heap and causes an exception, and because openssl 1.0.2q's RAND_poll implementation
            # wraps this all in a __try block and silently eats said exception, when the windows
            # segment heap is explicitly turned on this leaves the heap in a locked state resulting
            # in process deadlock as other threads attempt to allocate or free memory.
            #
            # as an additional *delightful* addendum, it turns out that when the windows segment
            # heap is manually flipped on, Heap32First/Heap32Next being called while another
            # thread is interacting with the allocator can deadlock (or outright crash) the entire