Exemple #1
0
def get_resources_dir():
    rsc = None
    try:
        import gtkosx_application        #@UnresolvedImport
        try:
            rsc = gtkosx_application.gtkosx_application_get_resource_path()
            if rsc:
                RESOURCES = "/Resources/"
                i = rsc.rfind(RESOURCES)
                if i>0:
                    rsc = rsc[:i+len(RESOURCES)]
        except:
            #maybe we're not running from an app bundle?
            pass
    except:
        print("ERROR: gtkosx_application module is missing - trying to continue anyway")
    if not rsc:
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
    if rsc:
        #when we run from a jhbuild installation,
        #~/gtk/inst/bin/xpra is the binary
        #so rsc=~/gtk/inst/bin
        #and we want to find ~/gtk/inst/share with get_icon_dir()
        #so let's try to look for that
        #(there is no /bin/ in the regular application bundle path)
        head, tail = os.path.split(rsc)
        if tail=="bin":
            return head
    return rsc
Exemple #2
0
def get_CUDA_function(device_id, function_name):
    """
        Returns the compiled kernel for the given device
        and kernel key.
    """
    global KERNELS
    data = KERNELS.get(function_name)
    if data is None:
        from xpra.platform.paths import default_get_app_dir
        from xpra.os_util import load_binary_file
        cubin_file = os.path.join(default_get_app_dir(), "cuda",
                                  "%s.fatbin" % function_name)
        log("get_CUDA_function(%s, %s) cubin file=%s", device_id,
            function_name, cubin_file)
        data = load_binary_file(cubin_file)
        if not data:
            log.error("failed to load CUDA bin file %s", cubin_file)
            return None
        log(" loaded %s bytes", len(data))
        KERNELS[function_name] = data
    #now load from cubin:
    start = time.time()
    mod = driver.module_from_buffer(data)
    log("get_CUDA_function(%s, %s) module=%s", device_id, function_name, mod)
    try:
        CUDA_function = mod.get_function(function_name)
    except driver.LogicError as e:
        raise Exception("failed to load '%s' from %s: %s" %
                        (function_name, mod, e))
    end = time.time()
    log("loading function %s from pre-compiled cubin took %.1fms",
        function_name, 1000.0 * (end - start))
    return CUDA_function
Exemple #3
0
def do_get_resources_dir():
    rsc = None
    RESOURCES = "/Resources/"
    #FUGLY warning: importing gtkosx_application causes the dock to appear,
    #and in some cases we don't want that.. so use the env var XPRA_SKIP_UI as workaround for such cases:
    if not envbool("XPRA_SKIP_UI", False):
        from xpra.platform.darwin import get_OSXApplication
        macapp = get_OSXApplication()
        try:
            rsc = macapp.get_resource_path()
            debug("get_resources_dir() %s.get_resource_path=%s", macapp, rsc)
        except Exception:
            global _gtkosx_warning_
            if _gtkosx_warning_ is False:
                _gtkosx_warning_ = True
                #delayed import to prevent cycles:
                get_util_logger().error(
                    "Error: gtkosx_application module is missing - trying to continue anyway"
                )
    else:
        debug("XPRA_SKIP_UI is set, not importing gtkosx_application")
    if rsc is None:
        #try using the path to this file to find the resource path:
        rsc = __file__
    i = rsc.rfind(RESOURCES)
    if i <= 0:
        #last fallback: try the default app dir
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
        debug("get_resources_dir() default_get_app_dir()=%s", rsc)
    i = rsc.rfind(RESOURCES)
    if i > 0:
        rsc = rsc[:i + len(RESOURCES)]
    debug("get_resources_dir()=%s", rsc)
    return rsc
Exemple #4
0
def get_resources_dir():
    rsc = None
    RESOURCES = "/Resources/"
    try:
        import gtkosx_application        #@UnresolvedImport
        try:
            rsc = gtkosx_application.gtkosx_application_get_resource_path()
            debug("get_resources_dir() gtkosx_application_get_resource_path=%s", rsc)
            if rsc:
                i = rsc.rfind(RESOURCES)
                if i<=0:
                    rsc = None
        except:
            #maybe we're not running from an app bundle?
            pass
    except:
        print("ERROR: gtkosx_application module is missing - trying to continue anyway")
    if not rsc:
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
        debug("get_resources_dir() default_get_app_dir()=%s", rsc)
    i = rsc.rfind(RESOURCES)
    if i>0:
        rsc = rsc[:i+len(RESOURCES)]
    else:
        rsc = None
    debug("get_resources_dir()=%s", rsc)
    return rsc
Exemple #5
0
def do_get_resources_dir():
    rsc = None
    RESOURCES = "/Resources/"
    #FUGLY warning: importing gtkosx_application causes the dock to appear,
    #and in some cases we don't want that.. so use the env var XPRA_SKIP_UI as workaround for such cases:
    if os.environ.get("XPRA_SKIP_UI", "0")=="0":
        try:
            import gtkosx_application        #@UnresolvedImport
            try:
                rsc = gtkosx_application.gtkosx_application_get_resource_path()
                debug("get_resources_dir() gtkosx_application_get_resource_path=%s", rsc)
            except:
                #maybe we're not running from an app bundle?
                pass
        except:
            #delayed import to prevent cycles:
            from xpra.log import Logger
            log = Logger("util")
            log.error("ERROR: gtkosx_application module is missing - trying to continue anyway")
    else:
        debug("XPRA_SKIP_UI is set, not importing gtkosx_application")
    if rsc is None:
        #try using the path to this file to find the resource path:
        rsc = __file__
    i = rsc.rfind(RESOURCES)
    if i<=0:
        #last fallback: try the default app dir
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
        debug("get_resources_dir() default_get_app_dir()=%s", rsc)
    i = rsc.rfind(RESOURCES)
    if i>0:
        rsc = rsc[:i+len(RESOURCES)]
    debug("get_resources_dir()=%s", rsc)
    return rsc
Exemple #6
0
def get_CUDA_function(device_id, function_name):
    """
        Returns the compiled kernel for the given device
        and kernel key.
    """
    global KERNELS
    data = KERNELS.get(function_name)
    if data is None:
        from xpra.platform.paths import default_get_app_dir
        from xpra.os_util import load_binary_file
        cubin_file = os.path.join(default_get_app_dir(), "cuda", "%s.fatbin" % function_name)
        log("get_CUDA_function(%s, %s) cubin file=%s", device_id, function_name, cubin_file)
        data = load_binary_file(cubin_file)
        if not data:
            log.error("failed to load CUDA bin file %s", cubin_file)
            return None
        log(" loaded %s bytes", len(data))
        KERNELS[function_name] = data
    #now load from cubin:
    start = time.time()
    mod = driver.module_from_buffer(data)
    log("get_CUDA_function(%s, %s) module=%s", device_id, function_name, mod)
    try:
        CUDA_function = mod.get_function(function_name)
    except driver.LogicError as e:
        raise Exception("failed to load '%s' from %s: %s" % (function_name, mod, e))
    end = time.time()
    log("loading function %s from pre-compiled cubin took %.1fms", function_name, 1000.0*(end-start))
    return CUDA_function
Exemple #7
0
def get_resources_dir():
    rsc = None
    try:
        import gtkosx_application  #@UnresolvedImport
        try:
            rsc = gtkosx_application.gtkosx_application_get_resource_path()
            if rsc:
                RESOURCES = "/Resources/"
                i = rsc.rfind(RESOURCES)
                if i > 0:
                    rsc = rsc[:i + len(RESOURCES)]
        except:
            #maybe we're not running from an app bundle?
            pass
    except:
        print(
            "ERROR: gtkosx_application module is missing - trying to continue anyway"
        )
    if not rsc:
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
    if rsc:
        #when we run from a jhbuild installation,
        #~/gtk/inst/bin/xpra is the binary
        #so rsc=~/gtk/inst/bin
        #and we want to find ~/gtk/inst/share with get_icon_dir()
        #so let's try to look for that
        #(there is no /bin/ in the regular application bundle path)
        head, tail = os.path.split(rsc)
        if tail == "bin":
            return head
    return rsc
Exemple #8
0
def get_resources_dir():
    rsc = None
    RESOURCES = "/Resources/"
    try:
        import gtkosx_application  #@UnresolvedImport
        try:
            rsc = gtkosx_application.gtkosx_application_get_resource_path()
            debug(
                "get_resources_dir() gtkosx_application_get_resource_path=%s",
                rsc)
            if rsc:
                i = rsc.rfind(RESOURCES)
                if i <= 0:
                    rsc = None
        except:
            #maybe we're not running from an app bundle?
            pass
    except:
        print(
            "ERROR: gtkosx_application module is missing - trying to continue anyway"
        )
    if not rsc:
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
        debug("get_resources_dir() default_get_app_dir()=%s", rsc)
    i = rsc.rfind(RESOURCES)
    if i > 0:
        rsc = rsc[:i + len(RESOURCES)]
    else:
        rsc = None
    debug("get_resources_dir()=%s", rsc)
    return rsc
Exemple #9
0
def get_app_dir():
    global APP_DIR
    if APP_DIR is not None:
        return APP_DIR
    from xpra.platform.paths import default_get_app_dir  # imported here to prevent import loop

    return default_get_app_dir()
Exemple #10
0
def do_get_resources_dir():
    rsc = None
    RESOURCES = "/Resources/"
    #FUGLY warning: importing gtkosx_application causes the dock to appear,
    #and in some cases we don't want that.. so use the env var XPRA_SKIP_UI as workaround for such cases:
    if not envbool("XPRA_SKIP_UI", False):
        try:
            import gtkosx_application  #@UnresolvedImport
            try:
                rsc = gtkosx_application.gtkosx_application_get_resource_path()
                debug(
                    "get_resources_dir() gtkosx_application_get_resource_path=%s",
                    rsc)
            except:
                #maybe we're not running from an app bundle?
                pass
        except:
            global _gtkosx_warning_
            if _gtkosx_warning_ is False:
                _gtkosx_warning_ = True
                #delayed import to prevent cycles:
                from xpra.log import Logger
                log = Logger("util")
                log.error(
                    "ERROR: gtkosx_application module is missing - trying to continue anyway"
                )
    else:
        debug("XPRA_SKIP_UI is set, not importing gtkosx_application")
    if rsc is None:
        #try using the path to this file to find the resource path:
        rsc = __file__
    i = rsc.rfind(RESOURCES)
    if i <= 0:
        #last fallback: try the default app dir
        from xpra.platform.paths import default_get_app_dir
        rsc = default_get_app_dir()
        debug("get_resources_dir() default_get_app_dir()=%s", rsc)
    i = rsc.rfind(RESOURCES)
    if i > 0:
        rsc = rsc[:i + len(RESOURCES)]
    debug("get_resources_dir()=%s", rsc)
    return rsc
Exemple #11
0
def do_get_app_dir():
    global APP_DIR
    if APP_DIR is not None:
        return APP_DIR
    from xpra.platform.paths import default_get_app_dir  #imported here to prevent import loop
    return default_get_app_dir()
Exemple #12
0
def get_app_dir():
    if getattr(sys, 'frozen', ''):
        return os.path.dirname(os.path.abspath(sys.executable))
    from xpra.platform.paths import default_get_app_dir  #imported here to prevent import loop
    return default_get_app_dir()