Exemplo n.º 1
0
 def set_default_installer(self):
     if self.game and self.game.steam_support():
         installer_data = {'game': {'appid': self.game.steamid}}
         self.version = 'Steam'
     else:
         installer_data = DEFAULT_INSTALLER
     self.content = dump_yaml(installer_data)
Exemplo n.º 2
0
 def clean_content(self):
     """Verify that the content field is valid yaml"""
     yaml_data = self.cleaned_data["content"]
     try:
         yaml_data = load_yaml(yaml_data)
     except yaml.error.MarkedYAMLError as ex:
         raise forms.ValidationError(
             "Invalid YAML, problem at line %s, %s" %
             (ex.problem_mark.line, ex.problem))
     return dump_yaml(yaml_data)
Exemplo n.º 3
0
    def set_default_installer(self):
        """Creates the default content for installer when they are first created.

        This method should load from installer templates once they are implemented.
        """
        if self.game and self.game.steam_support():
            installer_data = {"game": {"appid": self.game.steamid}}
            self.version = "Steam"
        else:
            installer_data = DEFAULT_INSTALLER
        self.content = dump_yaml(installer_data)
Exemplo n.º 4
0
 def clean_content(self):
     """Verify that the content field is valid yaml"""
     yaml_data = self.cleaned_data["content"]
     try:
         yaml_data = load_yaml(yaml_data)
     except yaml.error.MarkedYAMLError as ex:
         raise forms.ValidationError(
             "Invalid YAML, problem at line %s, %s"
             % (ex.problem_mark.line, ex.problem)
         )
     return dump_yaml(yaml_data)
Exemplo n.º 5
0
    def set_default_installer(self):
        """Creates the default content for installer when they are first created.

        This method should load from installer templates once they are implemented.
        """
        if self.game and self.game.steam_support():
            installer_data = {"game": {"appid": self.game.steamid}}
            self.version = "Steam"
        else:
            installer_data = DEFAULT_INSTALLER
        self.content = dump_yaml(installer_data)
Exemplo n.º 6
0
    def add_arch_to_non_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        for step in [step for step in script["installer"] if "task" in step]:
            task = step["task"]
            if task["name"] == "wine.wineexec" and "arch" not in task:
                step["task"]["arch"] = "win32"
                script_updated = True

        if script_updated:
            installer.content = dump_yaml(script)
        return script_updated
Exemplo n.º 7
0
    def add_arch_to_non_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        for step in [step for step in script["installer"] if "task" in step]:
            task = step["task"]
            if task["name"] == "wine.wineexec" and "arch" not in task:
                step["task"]["arch"] = "win32"
                script_updated = True

        if script_updated:
            installer.content = dump_yaml(script)
        return script_updated
Exemplo n.º 8
0
    def add_arch_to_non_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        for step in [step for step in script['installer'] if 'task' in step]:
            task = step['task']
            if task['name'] == 'wine.wineexec' and 'arch' not in task:
                step['task']['arch'] = 'win32'
                script_updated = True

        if script_updated:
            installer.content = dump_yaml(script)
        return script_updated
Exemplo n.º 9
0
    def add_arch_to_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        try:
            game_config = script.get("game", {})
        except AttributeError:
            LOGGER.error("The script %s is invalid", installer.slug)
            return False

        # Intaller ahs arch, we're good
        if game_config.get("arch") in ("win32", "win64"):
            # Game has architecture already set
            return False
        if game_config.get("arch"):
            raise ValueError("Weird value for arch: %s", game_config["arch"])

        # Set a prefix so the game doesn't use ~/.wine
        if "prefix" not in game_config:
            LOGGER.warning("No prefix found for %s", installer.slug)
            detected_prefix = None
            for task in [
                    step for step in script.get("installer", [])
                    if "task" in step
            ]:
                if "prefix" in task:
                    if detected_prefix and detected_prefix != task["prefix"]:
                        raise ValueError("Different values of prefixes found")
                    detected_prefix = task["prefix"]
            if not detected_prefix:
                detected_prefix = "$GAMEDIR"
            LOGGER.info("Setting prefix to %s", detected_prefix)
            game_config["prefix"] = detected_prefix
            script_updated = True

        if "Program Files (x86)" in installer.content:
            LOGGER.info("%s is a 64bit game?", installer.slug)
            detected_arch = "win64"
        else:
            detected_arch = "win32"
        LOGGER.info("Setting arch for %s to %s", installer.slug, detected_arch)
        game_config["arch"] = detected_arch
        script_updated = True

        if script_updated:
            script["game"] = game_config
            installer.content = dump_yaml(script)
        return True
Exemplo n.º 10
0
    def add_arch_to_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        try:
            game_config = script.get("game", {})
        except AttributeError:
            LOGGER.error("The script %s is invalid", installer.slug)
            return False

        # Intaller ahs arch, we're good
        if game_config.get("arch") in ("win32", "win64"):
            # Game has architecture already set
            return False
        if game_config.get("arch"):
            raise ValueError("Weird value for arch: %s", game_config["arch"])

        # Set a prefix so the game doesn't use ~/.wine
        if "prefix" not in game_config:
            LOGGER.warning("No prefix found for %s", installer.slug)
            detected_prefix = None
            for task in [
                step for step in script.get("installer", []) if "task" in step
            ]:
                if "prefix" in task:
                    if detected_prefix and detected_prefix != task["prefix"]:
                        raise ValueError("Different values of prefixes found")
                    detected_prefix = task["prefix"]
            if not detected_prefix:
                detected_prefix = "$GAMEDIR"
            LOGGER.info("Setting prefix to %s", detected_prefix)
            game_config["prefix"] = detected_prefix
            script_updated = True

        if "Program Files (x86)" in installer.content:
            LOGGER.info("%s is a 64bit game?", installer.slug)
            detected_arch = "win64"
        else:
            detected_arch = "win32"
        LOGGER.info("Setting arch for %s to %s", installer.slug, detected_arch)
        game_config["arch"] = detected_arch
        script_updated = True

        if script_updated:
            script["game"] = game_config
            installer.content = dump_yaml(script)
        return True
Exemplo n.º 11
0
    def add_arch_to_wine_installers(self, installer):
        script_updated = False
        script = load_yaml(installer.content)
        try:
            game_config = script.get('game', {})
        except AttributeError:
            LOGGER.error("The script %s is invalid", installer.slug)
            return False

        # Intaller ahs arch, we're good
        if game_config.get('arch') in ('win32', 'win64'):
            # Game has architecture already set
            return False
        if game_config.get('arch'):
            raise ValueError("Weird value for arch: %s", game_config['arch'])

        # Set a prefix so the game doesn't use ~/.wine
        if 'prefix' not in game_config:
            LOGGER.warning("No prefix found for %s", installer.slug)
            detected_prefix = None
            for task in [step for step in script.get('installer', []) if 'task' in step]:
                if 'prefix' in task:
                    if detected_prefix and detected_prefix != task['prefix']:
                        raise ValueError("Different values of prefixes found")
                    detected_prefix = task['prefix']
            if not detected_prefix:
                detected_prefix = '$GAMEDIR'
            LOGGER.info("Setting prefix to %s", detected_prefix)
            game_config['prefix'] = detected_prefix
            script_updated = True

        if 'Program Files (x86)' in installer.content:
            LOGGER.info("%s is a 64bit game?", installer.slug)
            detected_arch = 'win64'
        else:
            detected_arch = 'win32'
        LOGGER.info("Setting arch for %s to %s", installer.slug, detected_arch)
        game_config['arch'] = detected_arch
        script_updated = True

        if script_updated:
            script['game'] = game_config
            installer.content = dump_yaml(script)
        return True
Exemplo n.º 12
0
    def handle(self, *args, **options):
        """Enables DXVK where D9VK was active before and removes
        all D9VK attributes and dxvk_version from installers."""

        dry_run = options.get('dry_run')

        installers = Installer.objects.filter(
            Q(content__icontains="d9vk")
            | Q(content__icontains="dxvk_version"))
        for installer in installers:
            script = load_yaml(installer.content)
            changed = Command.clean_up_dxvk_d9vk(script, installer.slug)
            if not changed:
                continue
            installer.content = dump_yaml(script)
            if dry_run:
                LOGGER.info("Dry run only, not saving installer %s", installer)
            else:
                LOGGER.info("Saving installer %s", installer)
                installer.save()
Exemplo n.º 13
0
    def handle(self, *args, **options):
        """Removes specified Wine versions from all installers."""
        dry_run = options.get('dry_run')

        # Search for installers that have a Wine version specified.
        installers = Installer.objects.filter(
            (Q(content__contains="\nwine:")
             | Q(content__contains="\nwinesteam:"))
            & Q(content__contains="  version: "))
        for installer in installers:
            script = load_yaml(installer.content)
            changed = self.remove_wine_version(
                script,
                installer.slug,
            )
            if not changed:
                continue
            installer.content = dump_yaml(script)
            if dry_run:
                LOGGER.info("Not saving installer %s, dry run only", installer)
            else:
                LOGGER.info("Updating installer %s", installer)
                installer.save()
Exemplo n.º 14
0
 def as_cleaned_yaml(self):
     """Return the YAML installer without the metadata"""
     return dump_yaml(self.as_dict(with_metadata=False))
Exemplo n.º 15
0
 def as_yaml(self):
     """Return the installer as a YAML document"""
     return dump_yaml(self.as_dict())
Exemplo n.º 16
0
 def as_cleaned_yaml(self):
     """Return the YAML installer without the metadata"""
     return dump_yaml(self.as_dict(with_metadata=False))
Exemplo n.º 17
0
 def as_yaml(self):
     return dump_yaml(self.as_dict())