示例#1
0
def lookup_emulator(console):
    try:
        emulator_name = settings.consoles()[console.fullname]['emulator']
    except KeyError as e:
        log_file("No emulator supplied for %s" % (console.shortname))
        return None
    if emulator_name not in custom_emulators():
        log_file("Emulator '%s' not found for %s. Ignoring" % (emulator_name, console.fullname))
        return None
    return custom_emulators()[emulator_name]
示例#2
0
def lookup_emulator(platform,console):
    emulators_key = platform + ' Emulators' # ex: "Windows Emulators"
    console_key = console.shortname.lower()

    try:
        user_supplied_name = settings.config()[emulators_key][console_key]
    except KeyError as e:
        log_file("Configuration missing key for %s on %s" % (console.shortname, platform))
        return None

    if not user_supplied_name:
        log_file("No user supplied name for %s" % console.shortname)
        return None

    name = emulator_platform_prefix(platform) + user_supplied_name
    try:
        return emulator_from_name(name)(console.shortname)
    except (KeyError, AttributeError) as e:
        message = "Could not load emulator. Check your spelling, and make sure the emulator is supported for your console"
        raise ConfigError(emulators_key, console.shortname, message)
示例#3
0
 def update_user_images(self, user_id, roms):
     """
     Sets a suitable grid image for every rom in 'roms' for the user defined
     by 'user_id'
     """
     grid = steam_grid.SteamGrid(
         steam_user_manager.userdata_directory_for_user_id(user_id))
     for rom in roms:
         shortcut = rom.to_shortcut()
         if not grid.existing_image_for_filename(
                 grid.filename_for_shortcut(shortcut.appname,
                                            shortcut.exe)):
             image = self.find_image_for_rom(rom)
             # Game not found
             if image is None:
                 log_file("No game found for %s on %s" %
                          (rom.name(), rom.console.fullname))
                 log_user(
                     "The image provider has no game called %s for %s. Try going to the provider and submittng the game yourself"
                     % (rom.name(), rom.console.fullname))
             # Game found, but there is no picture
             elif image == "":
                 log_file(
                     "No image found for %s. The URL checked was '%s'" %
                     (rom.name(), self.url_for_rom(rom)))
                 log_user(
                     "We couldn't find an image for %s. If you find one you like, upload it to %s, and next time Ice runs it will use it"
                     % (rom.name(), self.host_for_image_source()))
             # Game found, AND there is a picture there
             else:
                 log_file("Setting custom image for %s" % rom.name())
                 image_path = self.download_image(image)
                 grid.set_image_for_shortcut(image_path, shortcut.appname,
                                             shortcut.exe)
示例#4
0
文件: gui.py 项目: PiotrWpl/Ice
 def startIce(self):
     # very similar to the one in ice.py
     try:
         if steam_is_running():
             log_both("Ice cannot be run while Steam is open. Please close Steam and try again")
             return
         log_both("=========================Starting Ice")
         fs.create_directory_if_needed(fs.roms_directory(), log="Creating ROMs directory at %s" % fs.roms_directory())
         # Find all of the ROMs that are currently in the designated folders
         roms = console.find_all_roms()
         # Find the Steam Account that the user would like to add ROMs for
         user_ids = steam_user_manager.user_ids_on_this_machine()
         grid_manager = IceGridImageManager()
         for user_id in user_ids:
             log_both("---------------Running for user %s" % str(user_id))
             # Load their shortcuts into a SteamShortcutManager object
             shortcuts_path = steam_user_manager.shortcuts_file_for_user_id(user_id)
             shortcuts_manager = SteamShortcutManager(shortcuts_path)
             rom_manager = IceROMManager(shortcuts_manager)
             # Add the new ROMs in each folder to our Shortcut Manager
             rom_manager.sync_roms(roms)
             # Generate a new shortcuts.vdf file with all of the new additions
             shortcuts_manager.save()
             if IceGridImageManager.should_download_images():
                 log_both("---Downloading grid images")
                 grid_manager.update_user_images(user_id,roms)
             else:
                 log_both("Skipping 'Download Image' step")
         log_both("=========================Finished")
     except ConfigError as error:
         log_user("=========================Stopping\n")
         log_config_error(error)
         log_exception()
         log_file("!!!")
     except StandardError as error:
         log_both("####################################")
         log_both("An Error has occurred:")
         log_both(error)
         log_exception()
         log_both("####################################")
示例#5
0
文件: console.py 项目: rrfenton/Ice
 def find_all_roms(self):
     """
     Reads a list of all the ROMs from the appropriate directory for the
     console
     """
     roms = []
     # If the emulator is not functional, we pretend it doesn't have any
     # ROMs
     if not self.emulator.is_functional():
         return roms
     for filename in os.listdir(self.roms_directory()):
         file_path = os.path.join(self.roms_directory(),filename)
         if not os.path.isdir(file_path):
             # On Linux/OSX, we want to make sure hidden files don't get
             # accidently added as well
             if settings.platform_string() != "Windows" and filename.startswith('.'):
                 continue
             if self.emulator is not None and not self.emulator.valid_rom(file_path):
                 log_file("Ignoring Non-ROM file: %s" % file_path)
                 continue
             roms.append(ROM(file_path,self))
     return roms
示例#6
0
文件: console.py 项目: rrfenton/Ice
 def find_all_roms(self):
     """
     Reads a list of all the ROMs from the appropriate directory for the
     console
     """
     roms = []
     # If the emulator is not functional, we pretend it doesn't have any
     # ROMs
     if not self.emulator.is_functional():
         return roms
     for filename in os.listdir(self.roms_directory()):
         file_path = os.path.join(self.roms_directory(), filename)
         if not os.path.isdir(file_path):
             # On Linux/OSX, we want to make sure hidden files don't get
             # accidently added as well
             if settings.platform_string(
             ) != "Windows" and filename.startswith('.'):
                 continue
             if self.emulator is not None and not self.emulator.valid_rom(
                     file_path):
                 log_file("Ignoring Non-ROM file: %s" % file_path)
                 continue
             roms.append(ROM(file_path, self))
     return roms
示例#7
0
def lookup_emulator(platform,console):
    emulators_key = platform + ' Emulators' # ex: "Windows Emulators"
    console_key = console.shortname.lower()
    try:
        user_supplied_name = settings.config()[emulators_key][console_key]
        if not user_supplied_name:
            log_file("No user supplied name for %s" % console.shortname)
            return None
        name = emulator_platform_prefix(platform) + user_supplied_name
        return emulator_from_name(name)(console.shortname)
    except KeyError as e:
        # TODO(#28) Throw a ConfigError once it will be caught...
        log_file("Configuration missing key for %s on %s" % (console.shortname, platform))
        return None
    except AttributeError as e:
        # TODO(#28) Throw a ConfigError once it will be caught...
        log_user("Cannot load emulator for %s. Check that your spelling is correct, and that the emulator you request is supported" % console.shortname)
        log_file("Error loading [%s] %s" % (emulator_key, console_key))
        return None
示例#8
0
def lookup_emulator(platform, console):
    emulators_key = platform + ' Emulators'  # ex: "Windows Emulators"
    console_key = console.shortname.lower()
    try:
        user_supplied_name = settings.config()[emulators_key][console_key]
        if not user_supplied_name:
            log_file("No user supplied name for %s" % console.shortname)
            return None
        name = emulator_platform_prefix(platform) + user_supplied_name
        return emulator_from_name(name)(console.shortname)
    except KeyError as e:
        # TODO(#28) Throw a ConfigError once it will be caught...
        log_file("Configuration missing key for %s on %s" %
                 (console.shortname, platform))
        return None
    except AttributeError as e:
        # TODO(#28) Throw a ConfigError once it will be caught...
        log_user(
            "Cannot load emulator for %s. Check that your spelling is correct, and that the emulator you request is supported"
            % console.shortname)
        log_file("Error loading [%s] %s" % (emulator_key, console_key))
        return None
示例#9
0
 def update_user_images(self,user_id,roms):
     """
     Sets a suitable grid image for every rom in 'roms' for the user defined
     by 'user_id'
     """
     grid = steam_grid.SteamGrid(steam_user_manager.userdata_directory_for_user_id(user_id))
     for rom in roms:
         shortcut = rom.to_shortcut()
         if not grid.existing_image_for_filename(grid.filename_for_shortcut(shortcut.appname,shortcut.exe)):
             image = self.find_image_for_rom(rom)
             # Game not found
             if image is None:
                 log_file("No game found for %s on %s" % (rom.name(),rom.console.fullname))
                 log_user("The image provider has no game called %s for %s. Try going to %s and submittng the game yourself" % (rom.name(),rom.console.fullname, self.host_for_image_source()))
             # Game found, but there is no picture
             elif image == "":
                 log_file("No image found for %s. The URL checked was '%s'" % (rom.name(),self.url_for_rom(rom)))
                 log_user("We couldn't find an image for %s. If you find one you like, upload it to %s, and next time Ice runs it will use it" % (rom.name(),self.host_for_image_source()))
             # Game found, AND there is a picture there
             else:
                 log_file("Setting custom image for %s" % rom.name())
                 image_path = self.download_image(image)
                 grid.set_image_for_shortcut(image_path,shortcut.appname,shortcut.exe)