Пример #1
0
    def __read_repository(self):
        root = ConnectRegistry(None, HKEY_CLASSES_ROOT)
        base_key = OpenKeyEx(root, WindowsStore.REPOSITORY_PATH)
        idx = 0
        games = []

        for sub_key_name in iter(RegKeyIter(base_key)):
            try:
                sub_key = OpenKeyEx(base_key, sub_key_name)
                idx += 1
                name = QueryValueEx(sub_key, "DisplayName")[0]
                if name.startswith("@{"):
                    # if it doesn't have a name we don't care for it
                    continue
                root_path = QueryValueEx(sub_key, "PackageRootFolder")[0]

                doc = minidom.parse(os.path.join(root_path,
                                                 "appxmanifest.xml"))

                apps = doc.getElementsByTagName("Application")
                if apps.length == 0:
                    continue
                app = apps[0]

                exeid = app.getAttribute("Id")
                exe_path = app.getAttribute("Executable")

                logo_path = None
                try:
                    visuals = app.getElementsByTagName("uap:VisualElements")[0]
                    logo_path = visuals.getAttribute("Square150x150Logo")
                except Exception as e:
                    self.__context.warn("failed to get logo", exeid, e)

                id_parts = sub_key_name.split("_")
                games.append({
                    "appid": id_parts[0],
                    "publisher": id_parts[-1],
                    "name": name,
                    "exeid": exeid,
                    "root_path": root_path,
                    "exe_path": exe_path,
                    "logo_path": logo_path
                })
            except Exception as e:
                # This may be an error but most likely it's simply not a "proper" application we
                # could start. May be a service or something
                self.__context.dbg("manifest not parsed", e)

        return games
Пример #2
0
def find_msys2_cairo(cairo):
    swpath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
    for root in [HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE]:
        with OpenKey(root, swpath) as swkey:
            keys, _, _ = QueryInfoKey(swkey)
            for i in range(0, keys):
                subpath = EnumKey(swkey, i)
                with OpenKey(root, swpath + "\\" + subpath) as subkey:
                    try:
                        name, _ = QueryValueEx(subkey, 'DisplayName')
                        loc, _ = QueryValueEx(subkey, 'InstallLocation')
                        if name.startswith('MSYS2'):
                            dirs = [
                                d for d in listdir(loc) if isdir(join(loc, d))
                            ]
                            for d in dirs:
                                libdir = join(loc, d, 'bin')
                                if exists(join(libdir, cairo)):
                                    return libdir
                    except:
                        pass
    return False