Exemple #1
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, "slug")

            if game_data and "slug" in game_data:
                # Game data already exist locally.
                game = Game(game_data["id"])
            else:
                # Try to load game data from remote.
                games = api.get_api_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        "name": remote_game["name"],
                        "slug": remote_game["slug"],
                        "year": remote_game["year"],
                        "updated": remote_game["updated"],
                        "steamid": remote_game["steamid"],
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None
            AddGameDialog(self.parent, game=game)
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
Exemple #2
0
 def run_no_installer_dialog(self):
     """Open dialog for 'no script available' situation."""
     dlg = NoInstallerDialog(self)
     if dlg.result == dlg.MANUAL_CONF:
         self.manually_configure_game()
     elif dlg.result == dlg.NEW_INSTALLER:
         webbrowser.open(settings.GAME_URL % self.game_slug)
Exemple #3
0
    def run_no_installer_dialog(self):
        """Open dialog for 'no script available' situation."""
        dlg = NoInstallerDialog(self)
        if dlg.result == dlg.MANUAL_CONF:
            game_data = pga.get_game_by_field(self.game_slug, 'slug')

            if game_data and 'slug' in game_data:
                # Game data already exist locally.
                game = Game(game_data['id'])
            else:
                # Try to load game data from remote.
                games = api.get_games([self.game_slug])

                if games and len(games) >= 1:
                    remote_game = games[0]
                    game_data = {
                        'name': remote_game['name'],
                        'slug': remote_game['slug'],
                        'year': remote_game['year'],
                        'updated': remote_game['updated'],
                        'steamid': remote_game['steamid']
                    }
                    game = Game(pga.add_game(**game_data))
                else:
                    game = None

            AddGameDialog(
                self.parent,
                game=game,
                callback=lambda: self.notify_install_success(game_data['id']))
        elif dlg.result == dlg.NEW_INSTALLER:
            webbrowser.open(settings.GAME_URL % self.game_slug)
 def run_no_installer_dialog(self):
     """Open dialog for 'no script available' situation."""
     dlg = NoInstallerDialog(self)
     if dlg.result == dlg.MANUAL_CONF:
         game_data = pga.get_game_by_field(self.game_slug, 'slug')
         game = Game(game_data['id'])
         AddGameDialog(
             self.parent,
             game=game,
             callback=lambda: self.notify_install_success(game_data['id']))
     elif dlg.result == dlg.NEW_INSTALLER:
         webbrowser.open(settings.GAME_URL % self.game_slug)
Exemple #5
0
def fetch_script(window, game_ref):
    """Downloads install script(s) for matching game_ref"""
    request = urllib2.Request(url=settings.INSTALLER_URL % game_ref)
    try:
        request = urllib2.urlopen(request)
        script_contents = request.read()
    except IOError:
        dlg = NoInstallerDialog(window)
        if dlg.result == 1:
            game = Game(game_ref)
            game_dialog = AddGameDialog(window, game)
            game_dialog.run()
            if game_dialog.installed:
                window.notify_install_success()
        elif dlg.result == 2:
            installer_url = settings.SITE_URL + "games/%s/" % game_ref
            webbrowser.open(installer_url)
        return
    # Data should be JSON here, but JSON is also valid YAML.
    # At some point we will be dropping the YAML parser and load installer
    # data with json.loads
    return yaml.safe_load(script_contents)