Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Ice's official documentation is available at [Getting Started.](http://scottrice

###Running the Source

You will need Python 2.7 to run Ice. Python 3.0 and up will not work.
You will need Python 2.7 or Python 3.0 and up to run Ice.

You will also need pip installed. The easiest way to get that is to run `easy_install pip`.

Expand Down
11 changes: 7 additions & 4 deletions src/ice-qt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import sys
import traceback

Expand All @@ -16,7 +17,9 @@
traceback.print_exc()
sys.stderr = stderr
traceback.print_exc()
print ""
print "An error has occurred! A copy of the crash report has been saved to 'error.log'."
print "If this continues please submit an issue on our Github page (http://github.com/scottrice/Ice)"
raw_input()
print("")
print("An error has occurred! A copy of the crash report has been saved to 'error.log'.")
print("If this continues please submit an issue on our Github page (http://github.com/scottrice/Ice)")
try: input = raw_input
except NameError: pass
input()
10 changes: 6 additions & 4 deletions src/ice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import sys
import traceback

Expand All @@ -16,7 +17,8 @@
traceback.print_exc()
sys.stderr = stderr
traceback.print_exc()
print ""
print "An error has occurred! A copy of the crash report has been saved to 'error.log'."
print "If this continues please submit an issue on our Github page (http://github.com/scottrice/Ice)"
raw_input()
print("")
print("An error has occurred! A copy of the crash report has been saved to 'error.log'.")
print("If this continues please submit an issue on our Github page (http://github.com/scottrice/Ice)")
try: raw_input()
except NameError: input()
6 changes: 3 additions & 3 deletions src/ice/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import datetime
import os

from persistence.backed_object_manager import BackedObjectManager
from persistence.adapters.console_adapter import ConsoleBackedObjectAdapter
from persistence.adapters.emulator_adapter import EmulatorBackedObjectAdapter
from ice.persistence.backed_object_manager import BackedObjectManager
from ice.persistence.adapters.console_adapter import ConsoleBackedObjectAdapter
from ice.persistence.adapters.emulator_adapter import EmulatorBackedObjectAdapter


class Configuration(object):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os

from rom import ROM
from ice.rom import ROM


class Console(object):
Expand Down
4 changes: 2 additions & 2 deletions src/ice/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import tempfile
import shutil

from persistence.backed_object import BackedObject
import utils
from ice.persistence.backed_object import BackedObject
import ice.utils


class Emulator(BackedObject):
Expand Down
6 changes: 3 additions & 3 deletions src/ice/environment_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import psutil
import sys

from error.path_existance_error import PathExistanceError
from error.process_running_error import ProcessRunningError
from error.writable_path_error import WritablePathError
from ice.error.path_existance_error import PathExistanceError
from ice.error.process_running_error import ProcessRunningError
from ice.error.writable_path_error import WritablePathError


class EnvironmentChecker(object):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/error/path_existance_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from env_checker_error import EnvCheckerError
from ice.error.env_checker_error import EnvCheckerError


class PathExistanceError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/error/process_running_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from env_checker_error import EnvCheckerError
from ice.error.env_checker_error import EnvCheckerError


class ProcessRunningError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/error/writable_path_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from env_checker_error import EnvCheckerError
from ice.error.env_checker_error import EnvCheckerError


class WritablePathError(Exception):
Expand Down
4 changes: 2 additions & 2 deletions src/ice/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _paths_in_directory(self, directory):
return [os.path.join(directory, name) for name in glob.glob(pattern)]

def files_in_directory(self, directory):
return filter(os.path.isfile, self._paths_in_directory(directory))
return list(filter(os.path.isfile, self._paths_in_directory(directory)))

def subdirectories_of_directory(self, directory):
return filter(os.path.isdir, self._paths_in_directory(directory))
return list(filter(os.path.isdir, self._paths_in_directory(directory)))
2 changes: 1 addition & 1 deletion src/ice/gridproviders/combined_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8

import grid_image_provider
from ice.gridproviders import grid_image_provider
from functools import reduce


Expand Down
22 changes: 15 additions & 7 deletions src/ice/gridproviders/consolegrid_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@

import sys
import os
import urllib
import urllib2
try:
from urllib import quote
from urllib import urlretrieve
from urllib2 import urlopen
from urllib2 import URLError
except:
from urllib.request import quote
from urllib.request import urlretrieve
from urllib.request import urlopen
from urllib.request import URLError

import grid_image_provider
from ice.gridproviders import grid_image_provider


class ConsoleGridProvider(grid_image_provider.GridImageProvider):
Expand All @@ -31,7 +39,7 @@ def is_enabled():

def consolegrid_top_picture_url(self, rom):
host = self.api_url()
quoted_name = urllib.quote(rom.name())
quoted_name = quote(rom.name())
return "%s?console=%s&game=%s" % (host, rom.console.shortname, quoted_name)

def find_url_for_rom(self, rom):
Expand All @@ -40,7 +48,7 @@ def find_url_for_rom(self, rom):
ConsoleGrid.com
"""
try:
response = urllib2.urlopen(self.consolegrid_top_picture_url(rom))
response = urlopen(self.consolegrid_top_picture_url(rom))
if response.getcode() == 204:
name = rom.name()
console = rom.console.fullname
Expand All @@ -49,7 +57,7 @@ def find_url_for_rom(self, rom):
)
else:
return response.read()
except urllib2.URLError as error:
except URLError as error:
# Connection was refused. ConsoleGrid may be down, or something bad
# may have happened
self.logger.debug(
Expand All @@ -61,7 +69,7 @@ def download_image(self, url):
Downloads the image at 'url' and returns the path to the image on the
local filesystem
"""
(path, headers) = urllib.urlretrieve(url)
(path, headers) = urlretrieve(url)
return path

def image_for_rom(self, rom):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/gridproviders/local_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
import os

import grid_image_provider
from ice.gridproviders import grid_image_provider


class LocalProvider(grid_image_provider.GridImageProvider):
Expand Down
2 changes: 1 addition & 1 deletion src/ice/gui/steam_preview_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from PyQt4 import QtGui

from steam_shortcut_widget import SteamShortcutWidget
from ice.gui.steam_shortcut_widget import SteamShortcutWidget


class SteamPreviewWidget(QtGui.QWidget):
Expand Down
5 changes: 3 additions & 2 deletions src/ice/persistence/config_file_backing_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
Copyright (c) 2014 Scott Rice. All rights reserved.
"""

import ConfigParser
try: import ConfigParser
except: import configparser as ConfigParser

import backing_store
from ice.persistence import backing_store


class ConfigFileBackingStore(backing_store.BackingStore):
Expand Down
5 changes: 3 additions & 2 deletions src/ice/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def name(self):
name_with_ext = os.path.basename(self.path)

# normalize the name to get rid of symbols that break the shortcuts.vdf
name_with_ext = unicodedata.normalize(
'NFKD', unicode(name_with_ext.decode('utf-8'))).encode('ascii', 'ignore')
try: name_with_ext = unicode(name_with_ext.decode('utf-8'))
except: pass
name_with_ext = unicodedata.normalize('NFKD', name_with_ext).encode('ascii', 'ignore').decode('ascii')

dot_index = name_with_ext.rfind('.')
if dot_index == -1:
Expand Down
6 changes: 3 additions & 3 deletions src/ice/rom_finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from console import Console
from rom import ROM
from ice.console import Console
from ice.rom import ROM
from functools import reduce


Expand All @@ -27,7 +27,7 @@ def roms_for_console(self, console):
roms_directory = self.config.roms_directory_for_console(console)
paths = self.filesystem.files_in_directory(roms_directory)
valid_rom_paths = filter(console.is_valid_rom, paths)
return map(lambda path: ROM(path, console), valid_rom_paths)
return list(map(lambda path: ROM(path, console), valid_rom_paths))

def roms_for_consoles(self, consoles):
"""
Expand Down
10 changes: 6 additions & 4 deletions src/ice/runners/command_line_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Copyright (c) 2014 Scott Rice. All rights reserved.
"""

from ice_engine import IceEngine
from __future__ import print_function
from ice.runners.ice_engine import IceEngine


class CommandLineRunner(object):
Expand All @@ -16,6 +17,7 @@ def run(self, argv):
engine.run()
# Keeps the console from closing (until the user hits enter) so they can
# read any console output
print ""
print "Close the window, or hit enter to exit..."
raw_input()
print("")
print("Close the window, or hit enter to exit...")
try: raw_input()
except NameError: input()
20 changes: 11 additions & 9 deletions src/ice/steam_shortcut_synchronizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from rom import ICE_FLAG_TAG
from ice.rom import ICE_FLAG_TAG

class SteamShortcutSynchronizer(object):

Expand All @@ -11,17 +11,17 @@ def shortcut_is_managed_by_ice(self, managed_ids, shortcut):
return shortcut.appid() in managed_ids or ICE_FLAG_TAG in shortcut.tags

def unmanaged_shortcuts(self, managed_ids, shortcuts):
return filter(lambda shortcut: not self.shortcut_is_managed_by_ice(managed_ids, shortcut), shortcuts)
return list(filter(lambda shortcut: not self.shortcut_is_managed_by_ice(managed_ids, shortcut), shortcuts))

def removed_shortcuts(self, current_shortcuts, new_shortcuts):
# To get the list of only removed shortcuts we take all of the current
# shortcuts and filter out any that exist in the new shortcuts
return filter(lambda shortcut: shortcut not in new_shortcuts, current_shortcuts)
return [shortcut for shortcut in current_shortcuts if shortcut not in new_shortcuts]

def added_shortcuts(self, current_shortcuts, new_shortcuts):
# To get the list of only added shortcuts we take all of the new shortcuts
# and filter out any that existed in the current shortcuts
return filter(lambda shortcut: shortcut not in current_shortcuts, new_shortcuts)
return [shortcut for shortcut in new_shortcuts if shortcut not in current_shortcuts]

def sync_roms_for_user(self, user, roms):
"""
Expand All @@ -34,20 +34,22 @@ def sync_roms_for_user(self, user, roms):
# to Plex would be 'Unmanaged'
previous_managed_ids = self.managed_rom_archive.previous_managed_ids(user)
unmanaged_shortcuts = self.unmanaged_shortcuts(previous_managed_ids, user.shortcuts)
current_ice_shortcuts = filter(lambda shortcut: shortcut not in unmanaged_shortcuts, user.shortcuts)
current_ice_shortcuts = list(filter(lambda shortcut: shortcut not in unmanaged_shortcuts, user.shortcuts))
# Generate a list of shortcuts out of our list of ROMs
rom_shortcuts = map(lambda rom: rom.to_shortcut(), roms)
rom_shortcuts = list(map(lambda rom: rom.to_shortcut(), roms))
# Calculate which ROMs were added and which were removed so we can inform
# the user
removed = self.removed_shortcuts(current_ice_shortcuts, rom_shortcuts)
map(lambda shortcut: self.logger.info("Removing ROM: `%s`" % shortcut.name), removed)
for shortcut in removed:
self.logger.info("Removing ROM: `%s`" % shortcut.name)
added = self.added_shortcuts(current_ice_shortcuts, rom_shortcuts)
map(lambda shortcut: self.logger.info("Adding ROM: `%s`" % shortcut.name), added)
for shortcut in added:
self.logger.info("Adding ROM: `%s`" % shortcut.name)

# Set the updated shortcuts
user.shortcuts = unmanaged_shortcuts + rom_shortcuts
user.save_shortcuts()

# Update the archive
new_managed_ids = map(lambda shortcut: shortcut.appid(), rom_shortcuts)
new_managed_ids = list(map(lambda shortcut: shortcut.appid(), rom_shortcuts))
self.managed_rom_archive.set_managed_ids(user, new_managed_ids)
8 changes: 7 additions & 1 deletion src/ice/tests/environment_checker_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ def setUp(self):
self.tempdir = tempfile.mkdtemp()

def tearDown(self):
shutil.rmtree(self.tempdir)
def del_rw(action, name, exc):
for root, subdirs, files in os.walk(name):
for filename in subdirs + files:
subdir_filename = os.path.join(root, filename)
os.chmod(name, stat.S_IWRITE)
shutil.rmtree(subdir_filename, onerror=del_rw)
shutil.rmtree(self.tempdir, onerror=del_rw)

def testRequireDirectoryExistsSucceedsWhenDirectoryExists(self):
try:
Expand Down
6 changes: 3 additions & 3 deletions src/ice/tests/filesystem_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_files_in_directory_only_returns_files(self):
os.mkdir(dir1)
dir2 = os.path.join(self.tempdir, "dir2")
os.mkdir(dir2)
self.assertEquals(
self.assertEqual(
self.filesystem.files_in_directory(
self.tempdir), [
file1, file2])
Expand All @@ -71,7 +71,7 @@ def test_files_in_directory_doesnt_return_hidden_files(self):
os.mkdir(dir1)
dir2 = os.path.join(self.tempdir, "dir2")
os.mkdir(dir2)
self.assertEquals(
self.assertEqual(
self.filesystem.files_in_directory(
self.tempdir), [
file1, file2])
Expand All @@ -97,7 +97,7 @@ def test_subdirectories_of_directory_only_returns_directories(self):
os.mkdir(dir1)
dir2 = os.path.join(self.tempdir, "dir2")
os.mkdir(dir2)
self.assertEquals(
self.assertEqual(
self.filesystem.subdirectories_of_directory(
self.tempdir), [
dir1, dir2])
Loading