コード例 #1
0
ファイル: grid_image_manager.py プロジェクト: dkrisman/Ice
 def should_download_images():
     try:
         should_download = settings.config()["Grid Images"]["source"] != ""
         return should_download
     except KeyError:
         log_both("Could not find '[Grid Images] Source' in config.txt.")
         return False
コード例 #2
0
ファイル: filesystem_helper.py プロジェクト: nikt11/Ice
def create_directory_if_needed(dir, log=None):
    """
    Checks to see if a directory exists and, if not, creates it
    """
    if not os.path.exists(dir):
        if log is not None:
            log_both(log)
        os.makedirs(dir)
コード例 #3
0
 def add_rom(self, rom):
     # Don't add a ROM if we don't have a supported emulator for it
     if rom.console.emulator is None:
         return
     if not self.rom_already_in_steam(rom):
         log_both("Adding %s" % rom.name())
         generated_shortcut = rom.to_shortcut()
         self.managed_shortcuts.add(generated_shortcut)
         self.shortcut_manager.add(generated_shortcut)
コード例 #4
0
ファイル: rom_manager.py プロジェクト: rrfenton/Ice
 def add_rom(self,rom):
     # Don't add a ROM if we don't have a supported emulator for it
     if rom.console.emulator is None:
         return
     if not self.rom_already_in_steam(rom):
         log_both("Adding %s" % rom.name())
         generated_shortcut = rom.to_shortcut()
         self.managed_shortcuts.add(generated_shortcut)
         self.shortcut_manager.add(generated_shortcut)
コード例 #5
0
 def remove_deleted_roms_from_steam(self, roms):
     # We define 'has been deleted' by checking whether we have a shortcut
     # that was managed by Ice in Steam that is no longer in our ROM folders
     rom_shortcuts = set()
     for rom in roms:
         rom_shortcuts.add(rom.to_shortcut())
     deleted_rom_shortcuts = self.managed_shortcuts - rom_shortcuts
     for shortcut in deleted_rom_shortcuts:
         log_both("Deleting: %s" % shortcut.appname)
         self.shortcut_manager.shortcuts.remove(shortcut)
コード例 #6
0
ファイル: rom_manager.py プロジェクト: rrfenton/Ice
 def remove_deleted_roms_from_steam(self,roms):
     # We define 'has been deleted' by checking whether we have a shortcut
     # that was managed by Ice in Steam that is no longer in our ROM folders
     rom_shortcuts = set()
     for rom in roms:
         rom_shortcuts.add(rom.to_shortcut())
     deleted_rom_shortcuts = self.managed_shortcuts - rom_shortcuts
     for shortcut in deleted_rom_shortcuts:
         log_both("Deleting: %s" % shortcut.appname)
         self.shortcut_manager.shortcuts.remove(shortcut)
コード例 #7
0
ファイル: console.py プロジェクト: waytai/Ice
def supported_consoles():
    if supported_consoles.cached is None:
        sc = Console.settings_consoles()
        # Remove any consoles from supported_consoles if there does not exist an
        # emulator for them
        for console in list(sc):
            if console.emulator is None:
                sc.remove(console)
            else:
                log_both("Detected Console: %s => %s" % (console.fullname, console.emulator.name))
        # Cache it for next time
        supported_consoles.cached = sc
    return supported_consoles.cached
コード例 #8
0
ファイル: emulator_manager.py プロジェクト: PiotrWpl/Ice
def custom_emulators():
    global cached_emulators
    if cached_emulators is None:
        cached_emulators = {}
        emulator_data = settings.emulators()
        for name in emulator_data.keys():
            current = emulator_data[name]
            if 'location' not in current or current['location'] == "":
                log_both("No location set for '%s' in emulators.txt. Ignoring emulator" % name)
                continue
            if 'command' not in current or current['command'] == "":
                log_both("No command set for '%s' in emulators.txt. Ignoring emulator" % name)
                continue
            current_emulator = custom_emulator.CustomEmulator(name, current['location'], current['command'])
            log_both("Detected Emulator: %s" % name)
            cached_emulators[name] = current_emulator
    return cached_emulators
コード例 #9
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("####################################")
コード例 #10
0
ファイル: rom_manager.py プロジェクト: castrojo/Ice
"""

import sys
import os

import filesystem_helper
import steam_user_manager
from ice_logging import log_both
from steam_shortcut_manager import SteamShortcutManager,SteamShortcut
from steam_grid import SteamGrid

# Check to see if the directory we are going to use to Store ROMs exists. If it
# does not, then create it.
roms_dir = filesystem_helper.roms_directory()
if not os.path.exists(roms_dir):
    log_both("Creating ROMs directory at %s" % roms_dir)
    os.makedirs(roms_dir)

class IceROMManager():
    def __init__(self,shortcut_manager):
        """
        Takes an already initialized SteamShortcutsManager. Then does a O(n)
        computation to figure out which ROMs from Ice are already present and
        caches that result. That way, adding a ROM to the SteamShortcutsManager
        can be a O(1) lookup to see if the ROM is already managed, and a O(1)
        addition to the list (if it does not exist)
        
        Stores the managed ROMs in a set to optimize time complexity. See
        http://wiki.python.org/moin/TimeComplexity
        for details
        """