diff options
66 files changed, 468 insertions, 472 deletions
diff --git a/cerbero/bootstrap/android.py b/cerbero/bootstrap/android.py index a3a27278..ca379370 100644 --- a/cerbero/bootstrap/android.py +++ b/cerbero/bootstrap/android.py @@ -43,7 +43,7 @@ class AndroidBootstrapper (BootstrapperBase): try: shell.call('unzip %s' % ndk_zip, dest) shell.call('mv android-ndk-%s/* .' % self.NDK_VERSION, dest) - except Exception, ex: + except Exception as ex: raise FatalError(_("Error installing Android NDK: %s") % (ex)) diff --git a/cerbero/bootstrap/windows.py b/cerbero/bootstrap/windows.py index 149fdba6..e86f54c8 100644 --- a/cerbero/bootstrap/windows.py +++ b/cerbero/bootstrap/windows.py @@ -175,7 +175,7 @@ class WindowsBootstrapper(BootstrapperBase): # get the path libdir = libdir.split('=')[1] # strip the surrounding quotes - print "Replacing old libdir : ", libdir + print("Replacing old libdir : ", libdir) return libdir.strip()[1:-1] def remove_mingw_cpp(self): diff --git a/cerbero/build/build.py b/cerbero/build/build.py index d2834a92..649fb237 100644 --- a/cerbero/build/build.py +++ b/cerbero/build/build.py @@ -87,7 +87,7 @@ def modify_environment(func): self._restore_env(old_env) return res - call.func_name = func.func_name + call.__name__ = func.__name__ return call @@ -175,16 +175,16 @@ class MakefilesBase (Build): return None self._old_env = {} - for var in append_env.keys() + new_env.keys(): + for var in list(append_env.keys()) + list(new_env.keys()): self._old_env[var] = os.environ.get(var, None) - for var, val in append_env.iteritems(): - if not os.environ.has_key(var): + for var, val in append_env.items(): + if var not in os.environ: os.environ[var] = val else: os.environ[var] = '%s %s' % (os.environ[var], val) - for var, val in new_env.iteritems(): + for var, val in new_env.items(): if val is None: if var in os.environ: del os.environ[var] @@ -197,7 +197,7 @@ class MakefilesBase (Build): if old_env is None: return - for var, val in old_env.iteritems(): + for var, val in old_env.items(): if val is None: if var in os.environ: del os.environ[var] @@ -267,7 +267,7 @@ class Autotools (MakefilesBase): # On windows, environment variables are upperscase, but we still # need to pass things like am_cv_python_platform in lowercase for # configure and autogen.sh - for k, v in os.environ.iteritems(): + for k, v in os.environ.items(): if k[2:6] == '_cv_': self.configure_tpl += ' %s="%s"' % (k, v) diff --git a/cerbero/build/cookbook.py b/cerbero/build/cookbook.py index ceb020d2..d01a0498 100644 --- a/cerbero/build/cookbook.py +++ b/cerbero/build/cookbook.py @@ -143,7 +143,7 @@ class CookBook (object): @return: list of recipes @rtype: list ''' - recipes = self.recipes.values() + recipes = list(self.recipes.values()) recipes.sort(key=lambda x: x.name) return recipes @@ -268,10 +268,10 @@ class CookBook (object): @rtype: list ''' recipe = self.get_recipe(recipe_name) - return [r for r in self.recipes.values() if recipe.name in r.deps] + return [r for r in list(self.recipes.values()) if recipe.name in r.deps] def _runtime_deps (self): - return [x.name for x in self.recipes.values() if x.runtime_dep] + return [x.name for x in list(self.recipes.values()) if x.runtime_dep] def _cache_file(self, config): if config.cache_file is not None: @@ -294,7 +294,7 @@ class CookBook (object): os.makedirs(os.path.dirname(cache_file)) with open(cache_file, 'wb') as f: pickle.dump(self.status, f) - except IOError, ex: + except IOError as ex: m.warning(_("Could not cache the CookBook: %s") % ex) def _find_deps(self, recipe, state={}, ordered=[]): @@ -309,7 +309,7 @@ class CookBook (object): for recipe_name in recipe_deps: try: recipedep = self.get_recipe(recipe_name) - except RecipeNotFoundError, e: + except RecipeNotFoundError as e: raise FatalError(_("Recipe %s has a unknown dependency %s" % (recipe.name, recipe_name))) try: @@ -335,14 +335,14 @@ class CookBook (object): self.recipes = {} recipes = defaultdict(dict) recipes_repos = self._config.get_recipes_repos() - for reponame, (repodir, priority) in recipes_repos.iteritems(): + for reponame, (repodir, priority) in recipes_repos.items(): recipes[int(priority)].update(self._load_recipes_from_dir(repodir)) # Add recipes by asceding pripority for key in sorted(recipes.keys()): self.recipes.update(recipes[key]) # Check for updates in the recipe file to reset the status - for recipe in self.recipes.values(): + for recipe in list(self.recipes.values()): if recipe.name not in self.status: continue st = self.status[recipe.name] @@ -399,7 +399,7 @@ class CookBook (object): recipe = crecipe.UniversalFlatRecipe(self._config) else: recipe = crecipe.UniversalRecipe(self._config) - for c in self._config.arch_config.keys(): + for c in list(self._config.arch_config.keys()): try: d = {'Platform': Platform, 'Architecture': Architecture, 'BuildType': BuildType, 'SourceType': SourceType, @@ -423,9 +423,9 @@ class CookBook (object): recipe.add_recipe(r) else: return r - except InvalidRecipeError, e: + except InvalidRecipeError as e: self._invalid_recipes[r.name] = e - except Exception, ex: + except Exception as ex: m.warning("Error loading recipe in file %s %s" % (filepath, ex)) if self._config.target_arch == Architecture.UNIVERSAL: diff --git a/cerbero/build/filesprovider.py b/cerbero/build/filesprovider.py index ffe4cae2..2cd6d4e8 100644 --- a/cerbero/build/filesprovider.py +++ b/cerbero/build/filesprovider.py @@ -191,7 +191,7 @@ class FilesProvider(object): # The library search function returns a dict that is a mapping from # library name to filenames, but we only want a list of filenames if not isinstance(cat_files, list): - cat_files = flatten_files_list(cat_files.values()) + cat_files = flatten_files_list(list(cat_files.values())) files.extend(cat_files) return sorted(list(set(files))) diff --git a/cerbero/build/oven.py b/cerbero/build/oven.py index 077dd561..060b444f 100644 --- a/cerbero/build/oven.py +++ b/cerbero/build/oven.py @@ -95,7 +95,7 @@ class Oven (object): for recipe in ordered_recipes: try: self._cook_recipe(recipe, i, len(ordered_recipes)) - except BuildStepError, be: + except BuildStepError as be: if not self.interactive: raise be msg = be.msg @@ -144,7 +144,7 @@ class Oven (object): # update status successfully self.cookbook.update_step_status(recipe.name, step) shell.close_logfile_output() - except FatalError, e: + except FatalError as e: shell.close_logfile_output(dump=True) self._handle_build_step_error(recipe, step, e.arch) except Exception: diff --git a/cerbero/build/recipe.py b/cerbero/build/recipe.py index aa2bb6f7..dd8a6422 100644 --- a/cerbero/build/recipe.py +++ b/cerbero/build/recipe.py @@ -31,6 +31,7 @@ from cerbero.tools.osxuniversalgenerator import OSXUniversalGenerator from cerbero.utils import N_, _ from cerbero.utils import shell from cerbero.utils import messages as m +from functools import reduce class MetaRecipe(type): @@ -84,7 +85,7 @@ class BuildSteps(object): BuildSteps.POST_INSTALL] -class Recipe(FilesProvider): +class Recipe(FilesProvider, metaclass=MetaRecipe): ''' Base class for recipes. A Recipe describes a module and the way it's built. @@ -109,8 +110,6 @@ class Recipe(FilesProvider): @type runtime_dep: bool ''' - __metaclass__ = MetaRecipe - name = None licenses = [] version = None @@ -221,7 +220,7 @@ class Recipe(FilesProvider): output_dir = os.path.join(self.config.prefix, 'lib' + self.config.lib_suffix) genlib = GenLib() - for (libname, dllpaths) in self.libraries().items(): + for (libname, dllpaths) in list(self.libraries().items()): if len(dllpaths) > 1: m.warning("BUG: Found multiple DLLs for libname {}:\n{}".format(libname, '\n'.join(dllpaths))) continue @@ -278,7 +277,7 @@ class MetaUniversalRecipe(type): setattr(cls, step, lambda self, name=step: step_func(self, name)) -class UniversalRecipe(object): +class UniversalRecipe(object, metaclass=MetaUniversalRecipe): ''' Stores similar recipe objects that are going to be built together @@ -287,16 +286,14 @@ class UniversalRecipe(object): other targets, it will likely be a unitary group ''' - __metaclass__ = MetaUniversalRecipe - def __init__(self, config): self._config = config self._recipes = {} self._proxy_recipe = None def __str__(self): - if self._recipes.values(): - return str(self._recipes.values()[0]) + if list(self._recipes.values()): + return str(list(self._recipes.values())[0]) return super(UniversalRecipe, self).__str__() def add_recipe(self, recipe): @@ -329,7 +326,7 @@ class UniversalRecipe(object): def __setattr__(self, name, value): object.__setattr__(self, name, value) if name not in ['_config', '_recipes', '_proxy_recipe']: - for o in self._recipes.values(): + for o in list(self._recipes.values()): setattr(o, name, value) def get_for_arch (self, arch, name): @@ -341,14 +338,15 @@ class UniversalRecipe(object): def _do_step(self, step): if step in BuildSteps.FETCH: # No, really, let's not download a million times... - stepfunc = getattr(self._recipes.values()[0], step) + stepfunc = getattr(list(self._recipes.values())[0], step) try: stepfunc() - except FatalError, e: + except FatalError as e: + e.arch = arch raise e return - for arch, recipe in self._recipes.iteritems(): + for arch, recipe in self._recipes.items(): config = self._config.arch_config[arch] config.do_setup_env() stepfunc = getattr(recipe, step) @@ -356,7 +354,7 @@ class UniversalRecipe(object): # Call the step function try: stepfunc() - except FatalError, e: + except FatalError as e: e.arch = arch raise e @@ -378,7 +376,7 @@ class UniversalFlatRecipe(UniversalRecipe): def merge(self): arch_inputs = {} - for arch, recipe in self._recipes.iteritems(): + for arch, recipe in self._recipes.items(): # change the prefix temporarly to the arch prefix where files are # actually installed recipe.config.prefix = os.path.join(self.config.prefix, arch) @@ -386,15 +384,15 @@ class UniversalFlatRecipe(UniversalRecipe): recipe.config.prefix = self._config.prefix # merge the common files - inputs = reduce(lambda x, y: x & y, arch_inputs.values()) + inputs = reduce(lambda x, y: x & y, list(arch_inputs.values())) output = self._config.prefix generator = OSXUniversalGenerator(output) generator.merge_files(list(inputs), [os.path.join(self._config.prefix, arch) for arch in - self._recipes.keys()]) + list(self._recipes.keys())]) # merge the architecture specific files - for arch in self._recipes.keys(): + for arch in list(self._recipes.keys()): ainputs = list(inputs ^ arch_inputs[arch]) output = self._config.prefix generator = OSXUniversalGenerator(output) @@ -404,7 +402,7 @@ class UniversalFlatRecipe(UniversalRecipe): def _do_step(self, step): if step in BuildSteps.FETCH: # No, really, let's not download a million times... - stepfunc = getattr(self._recipes.values()[0], step) + stepfunc = getattr(list(self._recipes.values())[0], step) stepfunc() return @@ -412,9 +410,9 @@ class UniversalFlatRecipe(UniversalRecipe): # with the same final prefix, but we want to install each architecture # on a different path (eg: /path/to/prefix/x86). - archs_prefix = self._recipes.keys() + archs_prefix = list(self._recipes.keys()) - for arch, recipe in self._recipes.iteritems(): + for arch, recipe in self._recipes.items(): config = self._config.arch_config[arch] config.do_setup_env() stepfunc = getattr(recipe, step) diff --git a/cerbero/build/source.py b/cerbero/build/source.py index 61b56dd3..35c19a90 100644 --- a/cerbero/build/source.py +++ b/cerbero/build/source.py @@ -19,8 +19,8 @@ import os import shutil import tarfile -import urllib -import urlparse +import urllib.request, urllib.parse, urllib.error +import urllib.parse from cerbero.config import Platform from cerbero.utils import git, svn, shell, _ @@ -104,10 +104,10 @@ class Tarball (Source): self.replace_name_and_version(self.tarball_dirname) self.download_path = os.path.join(self.repo_dir, self.tarball_name) # URL-encode spaces and other special characters in the URL's path - split = list(urlparse.urlsplit(self.url)) - split[2] = urllib.quote(split[2]) - self.url = urlparse.urlunsplit(split) - self.mirror_url = urlparse.urljoin(TARBALL_MIRROR, self.tarball_name) + split = list(urllib.parse.urlsplit(self.url)) + split[2] = urllib.parse.quote(split[2]) + self.url = urllib.parse.urlunsplit(split) + self.mirror_url = urllib.parse.urljoin(TARBALL_MIRROR, self.tarball_name) def fetch(self, redownload=False): if not os.path.exists(self.repo_dir): @@ -180,18 +180,18 @@ class GitCache (Source): # First try to get the sources from the cached dir if there is one cached_dir = os.path.join(self.config.cached_sources, self.name) if os.path.isdir(os.path.join(cached_dir, ".git")): - for remote, url in self.remotes.iteritems(): + for remote, url in self.remotes.items(): git.add_remote(self.repo_dir, remote, "file://" + cached_dir) - for remote, url in self.config.recipe_remotes(self.name).iteritems(): + for remote, url in self.config.recipe_remotes(self.name).items(): git.add_remote(self.repo_dir, remote, "file://" + cached_dir) git.fetch(self.repo_dir, fail=False) else: cached_dir = None # add remotes from both upstream and config so user can easily # cherry-pick patches between branches - for remote, url in self.remotes.iteritems(): + for remote, url in self.remotes.items(): git.add_remote(self.repo_dir, remote, url) - for remote, url in self.config.recipe_remotes(self.name).iteritems(): + for remote, url in self.config.recipe_remotes(self.name).items(): git.add_remote(self.repo_dir, remote, url) # fetch remote branches git.fetch(self.repo_dir, fail=False) diff --git a/cerbero/commands/__init__.py b/cerbero/commands/__init__.py index 6324f215..1f4de46e 100644 --- a/cerbero/commands/__init__.py +++ b/cerbero/commands/__init__.py @@ -64,9 +64,9 @@ def load_commands(subparsers): continue try: __import__('cerbero.commands.%s' % name) - except ImportError, e: + except ImportError as e: m.warning("Error importing command %s:\n %s" % (name, e)) - for command in _commands.values(): + for command in list(_commands.values()): command.add_parser(subparsers) diff --git a/cerbero/commands/add_package.py b/cerbero/commands/add_package.py index 8e6f0da9..803a5c8f 100644 --- a/cerbero/commands/add_package.py +++ b/cerbero/commands/add_package.py @@ -104,7 +104,7 @@ class AddPackage(Command): ArgparseArgument('-l', '--license', default='', help=_('license of the package. ' 'Supported licenses: %s') % - ', '.join(self.supported_licenses.keys())), + ', '.join(list(self.supported_licenses.keys()))), ArgparseArgument('-d', '--deps', default='', help=_('comma separated list of the package ' 'dependencies')), @@ -130,7 +130,7 @@ class AddPackage(Command): 'windows:recipe2) ' 'Supported platforms: %s') % ', '.join( - self.supported_platforms.keys())), + list(self.supported_platforms.keys()))), ArgparseArgument('--platform-files-devel', default='', help=_('comma separated list of platform:recipe ' 'files to add to the devel package ' @@ -138,7 +138,7 @@ class AddPackage(Command): 'windows:recipe2) ' 'Supported platforms: %s') % ', '.join( - self.supported_platforms.keys())), + list(self.supported_platforms.keys()))), ArgparseArgument('-f', '--force', action='store_true', default=False, help=_('Replace package if existing'))]) @@ -184,7 +184,7 @@ class AddPackage(Command): for dname in deps: try: package = store.get_package(dname) - except Exception, ex: + except Exception as ex: raise UsageError(_("Error creating package: " "dependant package %s does not exist") % dname) template_args['deps'] = deps @@ -201,7 +201,7 @@ class AddPackage(Command): for pname in includes: try: package = store.get_package(pname) - except Exception, ex: + except Exception as ex: raise UsageError(_("Error creating package: " "included package %s does not exist") % pname) include_files.extend(package.files) @@ -254,12 +254,12 @@ class AddPackage(Command): m.action(_("Package '%s' successfully created in %s") % (name, filename)) - except IOError, ex: + except IOError as ex: raise FatalError(_("Error creating package: %s") % ex) def merge_dict(self, d1, d2): ret = d1 - for k, v in d2.iteritems(): + for k, v in d2.items(): if k in ret: ret[k].extend(v) else: @@ -303,7 +303,7 @@ class AddPackage(Command): parsed_files = extra_files template_arg = [] - for platform, files in parsed_files.iteritems(): + for platform, files in parsed_files.items(): template_arg.append( self.supported_platforms[platform] + ': [' + \ ', '.join(['\'' + recipe_files + '\'' \ diff --git a/cerbero/commands/add_recipe.py b/cerbero/commands/add_recipe.py index da3967aa..55764683 100644 --- a/cerbero/commands/add_recipe.py +++ b/cerbero/commands/add_recipe.py @@ -75,7 +75,7 @@ class AddRecipe(Command): ArgparseArgument('-l', '--licenses', default='', help=_('comma separated list of the recipe ' 'licenses. Supported licenses: %s') % - ', '.join(self.supported_licenses.keys())), + ', '.join(list(self.supported_licenses.keys()))), ArgparseArgument('-c', '--commit', default='', help=_('commit to use ' '(default to "sdk-$version")')), @@ -125,7 +125,7 @@ class AddRecipe(Command): for dname in deps: try: recipe = cookbook.get_recipe(dname) - except RecipeNotFoundError, ex: + except RecipeNotFoundError as ex: raise UsageError(_("Error creating recipe: " "dependant recipe %s does not exist") % dname) template_args['deps'] = deps @@ -137,7 +137,7 @@ class AddRecipe(Command): m.action(_("Recipe '%s' successfully created in %s") % (name, filename)) - except IOError, ex: + except IOError as ex: raise FatalError(_("Error creating recipe: %s") % ex) def validate_licenses(self, licenses): diff --git a/cerbero/commands/check.py b/cerbero/commands/check.py index 96b3e841..dd1013a2 100644 --- a/cerbero/commands/check.py +++ b/cerbero/commands/check.py @@ -63,9 +63,9 @@ class Check(Command): if stepfunc: try: stepfunc() - except FatalError, e: + except FatalError as e: raise e - except Exception, ex: + except Exception as ex: raise FatalError(_("Error running %s checks: %s") % (recipe.name, ex)) diff --git a/cerbero/commands/checkpackage.py b/cerbero/commands/checkpackage.py index e8db78c9..adba5380 100644 --- a/cerbero/commands/checkpackage.py +++ b/cerbero/commands/checkpackage.py @@ -43,8 +43,7 @@ class CheckPackage(Command): store = PackagesStore(config) p = store.get_package(p_name) - ordered_recipes = map(lambda x: cookbook.get_recipe(x), - p.recipes_dependencies()) + ordered_recipes = [cookbook.get_recipe(x) for x in p.recipes_dependencies()] for recipe in ordered_recipes: if cookbook.recipe_needs_build(recipe.name): @@ -62,7 +61,7 @@ class CheckPackage(Command): try: m.message('Running checks for recipe %s' % recipe.name) stepfunc() - except Exception, ex: + except Exception as ex: failed.append(recipe.name) m.warning(_("%s checks failed: %s") % (recipe.name, ex)) if failed: diff --git a/cerbero/commands/cleanone.py b/cerbero/commands/cleanone.py index c410ddbe..93151df1 100644 --- a/cerbero/commands/cleanone.py +++ b/cerbero/commands/cleanone.py @@ -42,14 +42,14 @@ class CleanOne(Command): try: stepfunc = getattr(recipe, 'clean') except: - print '%s has no clean step, skipped' % recipe.name + print('%s has no clean step, skipped' % recipe.name) if stepfunc: try: stepfunc() - except FatalError, e: + except FatalError as e: raise e - except Exception, ex: + except Exception as ex: raise FatalError(_("Error running %s checks: %s") % (recipe.name, ex)) diff --git a/cerbero/commands/debugpackages.py b/cerbero/commands/debugpackages.py index 8553c35a..8c380c26 100644 --- a/cerbero/commands/debugpackages.py +++ b/cerbero/commands/debugpackages.py @@ -56,7 +56,7 @@ class DebugPackages(Command): def find_orphan_files(self, allfiles, prefix, excludes=[]): cmd = 'find . -type f %s' - exc = map(lambda x: "\\( ! -name '%s' \\)" % x, excludes) + exc = ["\\( ! -name '%s' \\)" % x for x in excludes] cmd = cmd % ' '.join(exc) distfiles = shell.check_call(cmd, prefix).split('\n') diff --git a/cerbero/commands/genlibfiles.py b/cerbero/commands/genlibfiles.py index b63ec5ab..810e5ba8 100644 --- a/cerbero/commands/genlibfiles.py +++ b/cerbero/commands/genlibfiles.py @@ -51,7 +51,7 @@ class GenLibraryFiles(Command): for recipe in recipes: try: recipe.gen_library_file(args.output_dir) - except Exception, e: + except Exception as e: m.message(_("Error generaring library files for %s:\n %s") % (recipe.name, e)) diff --git a/cerbero/commands/gensdkshell.py b/cerbero/commands/gensdkshell.py index db62b88d..db3d1c35 100644 --- a/cerbero/commands/gensdkshell.py +++ b/cerbero/commands/gensdkshell.py @@ -102,7 +102,7 @@ class GenSdkShell(Command): self._putvar('GI_TYPELIB_PATH', '%s/girepository-1.0' % libdir) envstr = 'export %s="%s"\n' % (prefix_env_name, prefix) - for e, v in env.iteritems(): + for e, v in env.items(): envstr += 'export %s="%s"\n' % (e, v) try: filepath = os.path.join(output_dir, name) @@ -113,7 +113,7 @@ class GenSdkShell(Command): with open(filepath, 'w+') as f: f.write(SCRIPT_TPL % (envstr, cmd)) shell.call("chmod +x %s" % filepath) - except IOError, ex: + except IOError as ex: raise FatalError(_("Error creating script: %s" % ex)) diff --git a/cerbero/commands/info.py b/cerbero/commands/info.py index 0c6820e1..b45e8bfc 100644 --- a/cerbero/commands/info.py +++ b/cerbero/commands/info.py @@ -58,8 +58,8 @@ class PackageInfo(Command): recipes_licenses = p.recipes_licenses() recipes_licenses.update(p.devel_recipes_licenses()) for recipe_name, categories_licenses in \ - recipes_licenses.iteritems(): - for category_licenses in categories_licenses.itervalues(): + recipes_licenses.items(): + for category_licenses in categories_licenses.values(): licenses.extend(category_licenses) licenses = sorted(list(set(licenses))) d = {'name': p.name, 'version': p.version, 'url': p.url, diff --git a/cerbero/commands/list.py b/cerbero/commands/list.py index 57c0eda0..c0f288d0 100644 --- a/cerbero/commands/list.py +++ b/cerbero/commands/list.py @@ -70,12 +70,12 @@ class ShowConfig(Command): def run(self, config, args): for n in config._properties: if n == "variants": - print "%25s :" % (n) + print("%25s :" % (n)) variants = getattr(config, n).__dict__ for v in variants: - print "%30s : %s" % (v, variants[v]) + print("%30s : %s" % (v, variants[v])) else: - print "%25s : %s" % (n, getattr(config, n)) + print("%25s : %s" % (n, getattr(config, n))) register_command(List) diff --git a/cerbero/config.py b/cerbero/config.py index bc548d15..6687395e 100644 --- a/cerbero/config.py +++ b/cerbero/config.py @@ -136,7 +136,7 @@ class Config (object): # Map of architectures to the corresponding config file. We # do this so that we don't need to duplicate arch specific # config again in the universal config. - for arch, config_file in self.universal_archs.items(): + for arch, config_file in list(self.universal_archs.items()): arch_config[arch] = self._copy(arch) # Allow the config to detect whether this config is # running under a universal setup and some @@ -162,7 +162,7 @@ class Config (object): self._validate_properties() self._raw_environ = os.environ.copy() - for config in self.arch_config.values(): + for config in list(self.arch_config.values()): config._restore_environment() if self.target_arch == Architecture.UNIVERSAL: config.sources = os.path.join(self.sources, config.target_arch) @@ -179,13 +179,13 @@ class Config (object): "prefix, 'gi' variant will be removed")) self.variants.gi = False - for c in self.arch_config.values(): + for c in list(self.arch_config.values()): c.variants = self.variants self.do_setup_env() # Store current os.environ data - for c in self.arch_config.values(): + for c in list(self.arch_config.values()): self._create_path(c.local_sources) self._create_path(c.sources) self._create_path(c.logs) @@ -203,7 +203,7 @@ class Config (object): self.env = self.get_env(self.prefix, libdir, self.py_prefix) # set all the variables - for e, v in self.env.iteritems(): + for e, v in self.env.items(): os.environ[e] = v def get_env(self, prefix, libdir, py_prefix): @@ -352,14 +352,14 @@ class Config (object): def get_recipes_repos(self): recipes_dir = {'default': (self.recipes_dir, 0)} - for name, (path, priority) in self.external_recipes.iteritems(): + for name, (path, priority) in self.external_recipes.items(): path = os.path.abspath(os.path.expanduser(path)) recipes_dir[name] = (path, priority) return recipes_dir def get_packages_repos(self): packages_dir = {'default': (self.packages_dir, 0)} - for name, (path, priority) in self.external_packages.iteritems(): + for name, (path, priority) in self.external_packages.items(): path = os.path.abspath(os.path.expanduser(path)) packages_dir[name] = (path, priority) return packages_dir diff --git a/cerbero/hacks.py b/cerbero/hacks.py index 784a3807..51602b1e 100644 --- a/cerbero/hacks.py +++ b/cerbero/hacks.py @@ -23,7 +23,7 @@ import sys ### XML Hacks ### import re -import StringIO +import io from xml.dom import minidom from cerbero.utils import etree oldwrite = etree.ElementTree.write @@ -39,7 +39,7 @@ def pretify(string, pretty_print=True): def write(self, file_or_filename, encoding=None, pretty_print=False): if not pretty_print: return oldwrite(self, file_or_filename, encoding) - tmpfile = StringIO.StringIO() + tmpfile = io.StringIO() oldwrite(self, tmpfile, encoding) tmpfile.seek(0) if hasattr(file_or_filename, "write"): @@ -69,7 +69,7 @@ class _Environ(environclass): def __init__(self, environ): UserDict.UserDict.__init__(self) self.data = {} - for k, v in environ.items(): + for k, v in list(environ.items()): self.data[k] = v def __setitem__(self, key, item): diff --git a/cerbero/ide/vs/pkgconfig2vsprops.py b/cerbero/ide/vs/pkgconfig2vsprops.py index 1d68f8c3..78ced23d 100755 --- a/cerbero/ide/vs/pkgconfig2vsprops.py +++ b/cerbero/ide/vs/pkgconfig2vsprops.py @@ -36,7 +36,7 @@ class PkgConfig2VSProps(object): if target not in self.generators: raise FatalError('Target version must be one of %s' % - generators.keys()) + list(generators.keys())) pkgconfig = PkgConfig([libname], False) requires = pkgconfig.requires() @@ -70,7 +70,7 @@ if __name__ == "__main__": try: p2v = PkgConfig2VSProps(args.library, args.c) p2v.create(args.o) - except Exception, e: + except Exception as e: import traceback traceback.print_exc() m.error(str(e)) diff --git a/cerbero/ide/xcode/fwlib.py b/cerbero/ide/xcode/fwlib.py index c59aa25a..a344dbdd 100644 --- a/cerbero/ide/xcode/fwlib.py +++ b/cerbero/ide/xcode/fwlib.py @@ -148,12 +148,12 @@ class StaticFrameworkLibrary(FrameworkLibrary): if len(s) == 4 and s[2] == 'T': syms[s[3]].append(s) dups = {} - for k,v in syms.iteritems(): + for k,v in syms.items(): if len(v) > 1: dups[k] = v if dups: m.warning ("The static library contains duplicated symbols") - for k, v in dups.iteritems(): + for k, v in dups.items(): m.message (k) # symbol name for l in v: m.message (" %s" % l[0]) # file diff --git a/cerbero/ide/xcode/xcconfig.py b/cerbero/ide/xcode/xcconfig.py index b4225150..a4afef67 100755 --- a/cerbero/ide/xcode/xcconfig.py +++ b/cerbero/ide/xcode/xcconfig.py @@ -19,6 +19,7 @@ import sys from cerbero.ide.pkgconfig import PkgConfig +from functools import reduce XCCONFIG_TPL = ''' @@ -55,7 +56,7 @@ class XCConfig(object): if __name__ == "__main__": if len(sys.argv) < 2: - print "usage: xcconfig output_file libraries" + print("usage: xcconfig output_file libraries") sys.exit(1) xcconfig = XCConfig(sys.argv[2:]) xcconfig.create(sys.argv[1]) diff --git a/cerbero/main.py b/cerbero/main.py index 5a503be5..d700b04e 100644 --- a/cerbero/main.py +++ b/cerbero/main.py @@ -20,9 +20,9 @@ from cerbero import hacks try: import argparse -except ImportError, e: - print "Could not import argparse. Try installing it with "\ - "'sudo easy_install argparse" +except ImportError as e: + print("Could not import argparse. Try installing it with "\ + "'sudo easy_install argparse") raise e import sys @@ -96,28 +96,28 @@ class Main(object): try: self.config = config.Config() self.config.load(self.args.config) - except ConfigurationError, exc: + except ConfigurationError as exc: self.log_error(exc, False) def run_command(self): command = self.args.command try: res = commands.run(command, self.config, self.args) - except UsageError, exc: + except UsageError as exc: self.log_error(exc, True, command) sys.exit(1) - except FatalError, exc: + except FatalError as exc: traceback.print_exc() self.log_error(exc, True, command) - except BuildStepError, exc: + except BuildStepError as exc: self.log_error(exc.msg, False, command) - except AbortedError, exc: + except AbortedError as exc: self.log_error('', False, command) - except CerberoException, exc: + except CerberoException as exc: self.log_error(exc, False, command) except KeyboardInterrupt: self.log_error(_('Interrupted')) - except IOError, e: + except IOError as e: if e.errno != errno.EPIPE: raise sys.exit(0) diff --git a/cerbero/packages/android.py b/cerbero/packages/android.py index 5d88ed85..4dee99e3 100644 --- a/cerbero/packages/android.py +++ b/cerbero/packages/android.py @@ -48,7 +48,7 @@ class AndroidPackager(DistTarball): if isinstance(self.config.universal_archs, list): archs = self.config.universal_archs elif isinstance(self.config.universal_archs, dict): - archs = self.config.universal_archs.keys() + archs = list(self.config.universal_archs.keys()) else: raise ConfigurationError('universal_archs must be a list or a dict') diff --git a/cerbero/packages/debian.py b/cerbero/packages/debian.py index b49ea40d..247756a1 100644 --- a/cerbero/packages/debian.py +++ b/cerbero/packages/debian.py @@ -242,7 +242,7 @@ class DebianPackager(LinuxPackager): self._write_debian_file(packagedir, 'control', control + control_devel) self._write_debian_file(packagedir, 'copyright', copyright) rules_path = self._write_debian_file(packagedir, 'rules', rules) - os.chmod(rules_path, 0755) + os.chmod(rules_path, 0o755) self._write_debian_file(packagedir, os.path.join('source', 'format'), source_format) if self.package.has_runtime_package: diff --git a/cerbero/packages/linux.py b/cerbero/packages/linux.py index aa2db445..9dd550a0 100644 --- a/cerbero/packages/linux.py +++ b/cerbero/packages/linux.py @@ -169,8 +169,8 @@ class LinuxPackager(PackagerBase): licenses = [] recipes_licenses = self.package.recipes_licenses() recipes_licenses.update(self.package.devel_recipes_licenses()) - for recipe_name, categories_licenses in recipes_licenses.iteritems(): - for category_licenses in categories_licenses.itervalues(): + for recipe_name, categories_licenses in recipes_licenses.items(): + for category_licenses in categories_licenses.values(): licenses.extend(category_licenses) return sorted(list(set(licenses))) diff --git a/cerbero/packages/osx/buildtools.py b/cerbero/packages/osx/buildtools.py index 16c15668..28511691 100644 --- a/cerbero/packages/osx/buildtools.py +++ b/cerbero/packages/osx/buildtools.py @@ -54,7 +54,7 @@ class PackageBuild(object): def _cmd_with_args(self, args, output): args_str = '' - for k, v in args.iteritems(): + for k, v in args.items(): args_str += " --%s '%s'" % (k, v) return '%s %s %s' % (self.CMD, args_str, output) diff --git a/cerbero/packages/osx/bundles.py b/cerbero/packages/osx/bundles.py index 6947ae65..0e199e4d 100644 --- a/cerbero/packages/osx/bundles.py +++ b/cerbero/packages/osx/bundles.py @@ -149,10 +149,10 @@ class FrameworkBundlePackager(BundlePackagerBase): links[name] = 'Versions/Current/%s' % name # Create all links - for dest, src in links.iteritems(): + for dest, src in links.items(): shell.call ('ln -s %s %s' % (src, dest), tmp) inner_tmp = os.path.join(tmp, vdir) - for dest, src in inner_links.iteritems(): + for dest, src in inner_links.items(): shell.call ('ln -s %s %s' % (src, dest), inner_tmp) # Copy the framework library to Versions/$VERSION/$ARCH/Framework diff --git a/cerbero/packages/osx/packager.py b/cerbero/packages/osx/packager.py index 9c3e54b8..5d440c7b 100644 --- a/cerbero/packages/osx/packager.py +++ b/cerbero/packages/osx/packager.py @@ -133,7 +133,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin): try: runtime_path = self._create_package(PackageType.RUNTIME, output_dir, force) - except EmptyPackageError, e: + except EmptyPackageError as e: if not devel: raise e runtime_path = None @@ -145,7 +145,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin): # create the development package devel_path = self._create_package(PackageType.DEVEL, output_dir, force) - except EmptyPackageError, e: + except EmptyPackageError as e: if runtime_path is None: raise e devel_path = None @@ -332,7 +332,7 @@ class ProductPackage(PackagerBase): self.empty_packages[PackageType.DEVEL].append(p) def _create_packages_dmg(self): - paths = self.packages_paths[PackageType.RUNTIME].values() + paths = list(self.packages_paths[PackageType.RUNTIME].values()) dmg_file = os.path.join(self.output_dir, self._package_name('-packages.dmg')) diff --git a/cerbero/packages/package.py b/cerbero/packages/package.py index 0c37c906..eb2df49b 100644 --- a/cerbero/packages/package.py +++ b/cerbero/packages/package.py @@ -258,7 +258,7 @@ class Package(PackageBase): def devel_recipes_licenses(self): licenses = self._list_licenses(self._recipes_files_devel) - for recipe_name, categories in self._recipes_files.iteritems(): + for recipe_name, categories in self._recipes_files.items(): # also add development licenses for recipe from which used the # 'libs' category if len(categories) == 0 or FilesProvider.LIBS_CAT in categories: @@ -273,7 +273,7 @@ class Package(PackageBase): def files_list(self): files = [] - for recipe_name, categories in self._recipes_files.iteritems(): + for recipe_name, categories in self._recipes_files.items(): recipe = self.cookbook.get_recipe(recipe_name) if len(categories) == 0: rfiles = recipe.dist_files_list() @@ -284,13 +284,13 @@ class Package(PackageBase): def devel_files_list(self): files = [] - for recipe, categories in self._recipes_files.iteritems(): + for recipe, categories in self._recipes_files.items(): # only add development files for recipe from which used the 'libs' # category if len(categories) == 0 or FilesProvider.LIBS_CAT in categories: rfiles = self.cookbook.get_recipe(recipe).devel_files_list() files.extend(rfiles) - for recipe, categories in self._recipes_files_devel.iteritems(): + for recipe, categories in self._recipes_files_devel.items(): recipe = self.cookbook.get_recipe(recipe) if not categories: rfiles = recipe.devel_files_list() @@ -308,21 +308,21 @@ class Package(PackageBase): self._recipes_files = {} for r in self._files: l = r.split(':') - if self._recipes_files.has_key(l[0]): + if l[0] in self._recipes_files: self._recipes_files[l[0]] += l[1:] else: self._recipes_files[l[0]] = l[1:] self._recipes_files_devel = {} for r in self._files_devel: l = r.split(':') - if self._recipes_files_devel.has_key(l[0]): + if l[0] in self._recipes_files_devel: self._recipes_files_devel[l[0]] += l[1:] else: self._recipes_files_devel[l[0]] = l[1:] def _list_licenses(self, recipes_files): licenses = {} - for recipe_name, categories in recipes_files.iteritems(): + for recipe_name, categories in recipes_files.items(): r = self.cookbook.get_recipe(recipe_name) # Package.files|files_devel|platform_files|platform_files_devel = \ # [recipe:category] @@ -555,7 +555,7 @@ class App(Package): # Also include all the libraries provided by the recipes we depend # on. for recipe in self.cookbook.list_recipe_deps(self.app_recipe): - files.extend(flatten_files_list(recipe.libraries().values())) + files.extend(flatten_files_list(list(recipe.libraries().values()))) files.extend(recipe.files_list_by_category(FilesProvider.PY_CAT)) files.extend(recipe.files_list_by_category(FilesProvider.TYPELIB_CAT)) diff --git a/cerbero/packages/packagesstore.py b/cerbero/packages/packagesstore.py index 7eb22ecd..e089cc16 100644 --- a/cerbero/packages/packagesstore.py +++ b/cerbero/packages/packagesstore.py @@ -58,7 +58,7 @@ class PackagesStore (object): @return: list of packages @rtype: list ''' - packages = self._packages.values() + packages = list(self._packages.values()) packages.sort(key=lambda x: x.name) return packages @@ -161,7 +161,7 @@ class PackagesStore (object): self._packages = {} packages = defaultdict(dict) repos = self._config.get_packages_repos() - for reponame, (repodir, priority) in repos.iteritems(): + for reponame, (repodir, priority) in repos.items(): packages[int(priority)].update( self._load_packages_from_dir(repodir)) # Add recipes by asceding pripority @@ -177,7 +177,7 @@ class PackagesStore (object): m_path = os.path.join(repo, 'custom.py') if os.path.exists(m_path): custom = imp.load_source('custom', m_path) - except Exception, ex: + except Exception as ex: # import traceback # traceback.print_exc() # m.warning("Error loading package %s" % ex) @@ -200,7 +200,7 @@ class PackagesStore (object): 'Distro': Distro, 'DistroVersion': DistroVersion, 'License': License, 'package': package, 'PackageType': PackageType, 'custom': custom} - execfile(filepath, d) + exec(compile(open(filepath).read(), filepath, 'exec'), d) if 'Package' in d: p = d['Package'](self._config, self, self.cookbook) elif 'SDKPackage' in d: @@ -217,7 +217,7 @@ class PackagesStore (object): # may have changed it p.load_files() return p - except Exception, ex: + except Exception as ex: import traceback traceback.print_exc() m.warning("Error loading package %s" % ex) diff --git a/cerbero/packages/rpm.py b/cerbero/packages/rpm.py index 4e778b34..513d8881 100644 --- a/cerbero/packages/rpm.py +++ b/cerbero/packages/rpm.py @@ -26,6 +26,7 @@ from cerbero.packages import PackageType from cerbero.packages.linux import LinuxPackager from cerbero.packages.package import MetaPackage from cerbero.utils import shell, _ +from functools import reduce SPEC_TPL = ''' diff --git a/cerbero/packages/wix.py b/cerbero/packages/wix.py index 8ff4d68f..62a710b3 100644 --- a/cerbero/packages/wix.py +++ b/cerbero/packages/wix.py @@ -375,7 +375,7 @@ class MSI(WixBase): self.package.packages] # Remove empty packages - packages = [x for x in packages if x[0] in self.packages_deps.keys()] + packages = [x for x in packages if x[0] in list(self.packages_deps.keys())] if len(packages) == 0: raise FatalError("All packages are empty: %s" % [x[0] for x in self.package.packages]) @@ -393,7 +393,7 @@ class MSI(WixBase): required_packages) # Add a merge module ref for all the packages - for package, path in self.packages_deps.iteritems(): + for package, path in self.packages_deps.items(): etree.SubElement(self.installdir, 'Merge', Id=self._package_id(package.name), Language='1033', SourceFile=path, DiskId='1') @@ -519,7 +519,7 @@ class MSI(WixBase): mergerefs = [x for x in deps if x in required_packages] # don't add empty packages - mergerefs = [x for x in mergerefs if x in self.packages_deps.keys()] + mergerefs = [x for x in mergerefs if x in list(self.packages_deps.keys())] for p in mergerefs: etree.SubElement(feature, "MergeRef", diff --git a/cerbero/packages/wix_packager.py b/cerbero/packages/wix_packager.py index 66190037..64cc4ba5 100644 --- a/cerbero/packages/wix_packager.py +++ b/cerbero/packages/wix_packager.py @@ -159,7 +159,7 @@ class MSIPackager(PackagerBase): zipf.close() if not keep_temp: - for msms in self.merge_modules.values(): + for msms in list(self.merge_modules.values()): for p in msms: os.remove(p) @@ -192,7 +192,7 @@ class MSIPackager(PackagerBase): except EmptyPackageError: m.warning("Package %s is empty" % package) self.packagedeps = packagedeps - self.merge_modules[package_type] = packagedeps.values() + self.merge_modules[package_type] = list(packagedeps.values()) def _create_config(self): config = WixConfig(self.config, self.package) diff --git a/cerbero/tools/osxuniversalgenerator.py b/cerbero/tools/osxuniversalgenerator.py index eabf0e7f..8eb91073 100644 --- a/cerbero/tools/osxuniversalgenerator.py +++ b/cerbero/tools/osxuniversalgenerator.py @@ -134,14 +134,14 @@ class OSXUniversalGenerator(object): if f.endswith('.h'): action = 'copy' else: - raise Exception, 'Unexpected file type %s %s' % (str(ftype), f) + raise Exception('Unexpected file type %s %s' % (str(ftype), f)) actions.append(action) if len(actions) == 0: return 'skip' #we should skip this one, the file doesn't exist all_same = all(x == actions[0] for x in actions) if not all_same: - raise Exception, 'Different file types found: %s : %s' \ - % (str(ftype), str(files_list)) + raise Exception('Different file types found: %s : %s' \ + % (str(ftype), str(files_list))) return actions[0] def do_merge(self, filepath, dirs): @@ -166,7 +166,7 @@ class OSXUniversalGenerator(object): elif action == 'skip': pass #just pass else: - raise Exception, 'unexpected action %s' % action + raise Exception('unexpected action %s' % action) def parse_dirs(self, dirs, filters=None): self.missing = [] diff --git a/cerbero/utils/__init__.py b/cerbero/utils/__init__.py index ba5d8575..8e79e159 100644 --- a/cerbero/utils/__init__.py +++ b/cerbero/utils/__init__.py @@ -345,8 +345,8 @@ def remove_list_duplicates(seq): def parse_file(filename, dict): try: - execfile(filename, dict) - except Exception, ex: + exec(compile(open(filename).read(), filename, 'exec'), dict) + except Exception as ex: import traceback traceback.print_exc() raise ex diff --git a/cerbero/utils/msbuild.py b/cerbero/utils/msbuild.py index e6088220..8775feac 100644 --- a/cerbero/utils/msbuild.py +++ b/cerbero/utils/msbuild.py @@ -1,77 +1,77 @@ -# cerbero - a multi-platform build system for Open Source software
-# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import _winreg as winreg
-import os
-
-from cerbero.config import Architecture
-from cerbero.utils import fix_winpath, shell
-
-
-class MSBuild(object):
-
- def __init__(self, solution, arch=Architecture.X86, config='Release',
- sdk='Windows7.1SDK', **properties):
- self.properties = {}
- if arch == Architecture.X86:
- self.properties['Platform'] = 'Win32'
- elif arch == Architecture.X86_64:
- self.properties['Platform'] = 'x64'
- self.properties['Configuration'] = config
- self.properties['PlatformToolset'] = sdk
- self.properties.update(properties)
- self.solution = solution
-
- def build(self):
- self._call('build')
-
- @staticmethod
- def get_msbuild_tools_path():
- reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
- key = winreg.OpenKey(reg,
- r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0")
- path = winreg.QueryValueEx(key, 'MSBuildToolsPath')[0]
- return fix_winpath(path)
-
- @staticmethod
- def get_vs_path():
- reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
- key = winreg.OpenKey(reg,
- r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7")
- path = winreg.QueryValueEx(key, '10.0')[0]
- path = str(path)
- path = path.replace('\\VC', '\\Common7\\IDE')
- return path
-
- def _call(self, command):
- properties = self._format_properties()
- msbuildpath = self.get_msbuild_tools_path()
- vs_path = self.get_vs_path()
- old_path = os.environ['PATH']
- if self.properties['Platform'] == 'Win32':
- os.environ['PATH'] = '%s;%s' % (os.environ['PATH'], vs_path)
- try:
- shell.call('msbuild.exe %s %s /target:%s' %
- (self.solution, properties, command), msbuildpath)
- finally:
- os.environ['PATH'] = old_path
-
- def _format_properties(self):
- props = ['/property:%s=%s' % (k, v) for k, v in
- self.properties.iteritems()]
- return ' '.join(props)
+# cerbero - a multi-platform build system for Open Source software +# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import winreg as winreg +import os + +from cerbero.config import Architecture +from cerbero.utils import fix_winpath, shell + + +class MSBuild(object): + + def __init__(self, solution, arch=Architecture.X86, config='Release', + sdk='Windows7.1SDK', **properties): + self.properties = {} + if arch == Architecture.X86: + self.properties['Platform'] = 'Win32' + elif arch == Architecture.X86_64: + self.properties['Platform'] = 'x64' + self.properties['Configuration'] = config + self.properties['PlatformToolset'] = sdk + self.properties.update(properties) + self.solution = solution + + def build(self): + self._call('build') + + @staticmethod + def get_msbuild_tools_path(): + reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) + key = winreg.OpenKey(reg, + r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0") + path = winreg.QueryValueEx(key, 'MSBuildToolsPath')[0] + return fix_winpath(path) + + @staticmethod + def get_vs_path(): + reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) + key = winreg.OpenKey(reg, + r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7") + path = winreg.QueryValueEx(key, '10.0')[0] + path = str(path) + path = path.replace('\\VC', '\\Common7\\IDE') + return path + + def _call(self, command): + properties = self._format_properties() + msbuildpath = self.get_msbuild_tools_path() + vs_path = self.get_vs_path() + old_path = os.environ['PATH'] + if self.properties['Platform'] == 'Win32': + os.environ['PATH'] = '%s;%s' % (os.environ['PATH'], vs_path) + try: + shell.call('msbuild.exe %s %s /target:%s' % + (self.solution, properties, command), msbuildpath) + finally: + os.environ['PATH'] = old_path + + def _format_properties(self): + props = ['/property:%s=%s' % (k, v) for k, v in + self.properties.items()] + return ' '.join(props) diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py index f5991cac..e7ca9c1e 100644 --- a/cerbero/utils/shell.py +++ b/cerbero/utils/shell.py @@ -29,7 +29,7 @@ import time import glob import shutil import hashlib -import urllib2 +import urllib.request, urllib.error, urllib.parse from distutils.version import StrictVersion from cerbero.enums import Platform @@ -77,7 +77,7 @@ def close_logfile_output(dump=False): while True: data = LOGFILE.read() if data: - print data + print(data) else: break # if logfile is empty, remove it @@ -249,7 +249,7 @@ def download_wget(url, destination=None, recursive=False, check_cert=True, overw logging.info("Downloading %s", url) try: call(cmd, path) - except FatalError, e: + except FatalError as e: if os.path.exists(destination): os.remove(destination) raise e @@ -291,9 +291,9 @@ def download_urllib2(url, destination=None, recursive=False, check_cert=False, o try: logging.info(destination) with open(destination, 'wb') as d: - f = urllib2.urlopen(url, context=ctx) + f = urllib.request.urlopen(url, context=ctx) d.write(f.read()) - except urllib2.HTTPError, e: + except urllib.error.HTTPError as e: if os.path.exists(destination): os.remove(destination) raise e @@ -331,7 +331,7 @@ def download_curl(url, destination=None, recursive=False, check_cert=True, overw logging.info("Downloading %s", url) try: call(cmd, path) - except FatalError, e: + except FatalError as e: os.remove(destination) raise e @@ -391,7 +391,7 @@ def replace(filepath, replacements): ''' Replaces keys in the 'replacements' dict with their values in file ''' with open(filepath, 'r') as f: content = f.read() - for k, v in replacements.iteritems(): + for k, v in replacements.items(): content = content.replace(k, v) with open(filepath, 'w+') as f: f.write(content) @@ -405,9 +405,9 @@ def prompt(message, options=[]): ''' Prompts the user for input with the message and options ''' if len(options) != 0: message = "%s [%s] " % (message, '/'.join(options)) - res = raw_input(message) + res = input(message) while res not in [str(x) for x in options]: - res = raw_input(message) + res = input(message) return res @@ -416,9 +416,9 @@ def prompt_multiple(message, options): output = message + '\n' for i in range(len(options)): output += "[%s] %s\n" % (i, options[i]) - res = raw_input(output) + res = input(output) while res not in [str(x) for x in range(len(options))]: - res = raw_input(output) + res = input(output) return options[int(res)] diff --git a/config/ios.config b/config/ios.config index 403e1791..0477e2bf 100644 --- a/config/ios.config +++ b/config/ios.config @@ -126,7 +126,7 @@ for missing_header in ["bzlib.h", "crt_externs.h"]: missing_path = os.path.join(sysroot, "usr", "include", missing_header) if not os.path.lexists(missing_path): # FIXME This is not smart especially as we need to sudo - print "We need to create a syslink between %s and %s as they are missing in the device SDK" %(os.path.join(macosx_headers, missing_header), missing_path) + print("We need to create a syslink between %s and %s as they are missing in the device SDK" %(os.path.join(macosx_headers, missing_header), missing_path)) shell.call("sudo ln -s %s %s" %(os.path.join(macosx_headers, missing_header), missing_path)) diff --git a/recipes/cdparanoia.recipe b/recipes/cdparanoia.recipe index ff975fc6..c74e4374 100644 --- a/recipes/cdparanoia.recipe +++ b/recipes/cdparanoia.recipe @@ -37,4 +37,4 @@ class Recipe(recipe.Recipe): f = os.path.join(self.config.prefix, lib) if os.path.isfile(f) and not os.path.islink(f) and \ fnmatch(f, '*.so.*'): - os.chmod(f, 0755) + os.chmod(f, 0o755) diff --git a/recipes/docbook-xml.recipe b/recipes/docbook-xml.recipe index f06e006d..4bfcfe49 100644 --- a/recipes/docbook-xml.recipe +++ b/recipes/docbook-xml.recipe @@ -24,7 +24,7 @@ class Recipe(recipe.Recipe): lines= f.readlines() if len(lines) != 0: lines = lines[2:-1] - except Exception, ex: + except Exception as ex: lines = [''] return ''.join(lines) diff --git a/recipes/docbook-xsl.recipe b/recipes/docbook-xsl.recipe index a1f189f0..bf532b29 100644 --- a/recipes/docbook-xsl.recipe +++ b/recipes/docbook-xsl.recipe @@ -23,7 +23,7 @@ class Recipe(recipe.Recipe): lines= f.readlines() if len(lines) != 0: lines = lines[2:-1] - except Exception, ex: + except Exception as ex: lines = [''] return ''.join(lines) diff --git a/recipes/gst-android-1.0.recipe b/recipes/gst-android-1.0.recipe index fa9cbff6..a65a262f 100644 --- a/recipes/gst-android-1.0.recipe +++ b/recipes/gst-android-1.0.recipe @@ -38,7 +38,7 @@ class Recipe(recipe.Recipe): plugins = list_gstreamer_1_0_plugins_by_category(self.config) f = open(os.path.join(ndk_build_dir_dst, 'plugins.mk'), 'w') - for c, p in plugins.iteritems(): + for c, p in plugins.items(): p = ' '.join(p) f.write('GSTREAMER_PLUGINS_%s := %s\n' % (c.upper(), p)) f.close() diff --git a/recipes/gstreamer-ios-templates.recipe b/recipes/gstreamer-ios-templates.recipe index 80a4c4b6..96af216c 100644 --- a/recipes/gstreamer-ios-templates.recipe +++ b/recipes/gstreamer-ios-templates.recipe @@ -33,7 +33,7 @@ class Recipe(recipe.Recipe): decls = [] regs = [] categories = '' - for c, ps in plugins.iteritems(): + for c, ps in plugins.items(): c = c.upper() define = DEFINE_TPL % c # By default enable only the core plugins diff --git a/recipes/nettle/nettle.recipe b/recipes/nettle/nettle.recipe index 98e791f8..78371cfa 100644 --- a/recipes/nettle/nettle.recipe +++ b/recipes/nettle/nettle.recipe @@ -57,4 +57,4 @@ class Recipe(recipe.Recipe): f = os.path.join(self.config.prefix, lib) if os.path.isfile(f) and not os.path.islink(f) and \ fnmatch(f, '*.so.*'): - os.chmod(f, 0755) + os.chmod(f, 0o755) diff --git a/test/test_cerbero_build_build.py b/test/test_cerbero_build_build.py index c8406aed..941addf0 100644 --- a/test/test_cerbero_build_build.py +++ b/test/test_cerbero_build_build.py @@ -55,27 +55,27 @@ class ModifyEnvTest(unittest.TestCase): os.environ[self.var] = self.val1 self.mk.append_env = {self.var: self.val2} val = self.mk.get_env_var(self.var) - self.assertEquals(val, "%s %s" % (self.val1, self.val2)) + self.assertEqual(val, "%s %s" % (self.val1, self.val2)) def testAppendNonExistentEnv(self): if self.var in os.environ: del os.environ[self.var] self.mk.append_env = {self.var: self.val2} val = self.mk.get_env_var(self.var) - self.assertEquals(val, ' %s' % self.val2) + self.assertEqual(val, ' %s' % self.val2) def testNewEnv(self): os.environ[self.var] = self.val1 self.mk.new_env = {self.var: self.val2} val = self.mk.get_env_var(self.var) - self.assertEquals(val, self.val2) + self.assertEqual(val, self.val2) def testAppendAndNewEnv(self): os.environ[self.var] = '' self.mk.append_env = {self.var: self.val1} self.mk.new_env = {self.var: self.val2} val = self.mk.get_env_var(self.var) - self.assertEquals(val, self.val2) + self.assertEqual(val, self.val2) def testSystemLibs(self): os.environ['PKG_CONFIG_PATH'] = '/path/1' @@ -83,15 +83,15 @@ class ModifyEnvTest(unittest.TestCase): self.mk.config.allow_system_libs = True self.mk.use_system_libs = True val = self.mk.get_env_var('PKG_CONFIG_PATH') - self.assertEquals(val,'/path/2:/usr/lib/pkgconfig:' + self.assertEqual(val,'/path/2:/usr/lib/pkgconfig:' '/usr/share/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig') val = self.mk.get_env_var('PKG_CONFIG_LIBDIR') - self.assertEquals(val,'/path/2') + self.assertEqual(val,'/path/2') def testNestedModif(self): os.environ[self.var] = self.val1 self.mk.append_env = {self.var: self.val2} val = self.mk.get_env_var(self.var) - self.assertEquals(val, "%s %s" % (self.val1, self.val2)) + self.assertEqual(val, "%s %s" % (self.val1, self.val2)) val = self.mk.get_env_var_nested(self.var) - self.assertEquals(val, "%s %s" % (self.val1, self.val2)) + self.assertEqual(val, "%s %s" % (self.val1, self.val2)) diff --git a/test/test_cerbero_build_cookbook.py b/test/test_cerbero_build_cookbook.py index 80b9f9e9..6fe6d601 100644 --- a/test/test_cerbero_build_cookbook.py +++ b/test/test_cerbero_build_cookbook.py @@ -34,7 +34,7 @@ class PackageTest(unittest.TestCase): self.cookbook = CookBook(self.config, False) def testSetGetConfig(self): - self.assertEquals(self.config, self.cookbook.get_config()) + self.assertEqual(self.config, self.cookbook.get_config()) self.cookbook.set_config(None) self.assertIsNone(self.cookbook._config) @@ -42,7 +42,7 @@ class PackageTest(unittest.TestCase): status = {'test': 'test'} self.cookbook.set_status(status) self.cookbook._restore_cache() - self.assertEquals(self.cookbook.status, {}) + self.assertEqual(self.cookbook.status, {}) def testSaveCache(self): tmp = tempfile.NamedTemporaryFile() @@ -52,7 +52,7 @@ class PackageTest(unittest.TestCase): self.cookbook.save() with open(self.cookbook._cache_file(self.config), 'rb') as f: loaded_status = pickle.load(f) - self.assertEquals(status, loaded_status) + self.assertEqual(status, loaded_status) def testLoad(self): tmp = tempfile.NamedTemporaryFile() @@ -61,30 +61,30 @@ class PackageTest(unittest.TestCase): with open(tmp.name, 'wb') as f: pickle.dump(status, f) self.cookbook._restore_cache() - self.assertEquals(status, self.cookbook.status) + self.assertEqual(status, self.cookbook.status) def testAddGetRecipe(self): recipe = Recipe1(self.config) - self.failUnlessRaises(RecipeNotFoundError, self.cookbook.get_recipe, + self.assertRaises(RecipeNotFoundError, self.cookbook.get_recipe, recipe.name) self.cookbook.add_recipe(recipe) - self.assertEquals(recipe, self.cookbook.recipes[recipe.name]) - self.assertEquals(recipe, self.cookbook.get_recipe(recipe.name)) - self.assertEquals(self.cookbook.get_recipes_list(), [recipe]) + self.assertEqual(recipe, self.cookbook.recipes[recipe.name]) + self.assertEqual(recipe, self.cookbook.get_recipe(recipe.name)) + self.assertEqual(self.cookbook.get_recipes_list(), [recipe]) def testGetRecipesStatus(self): recipe = Recipe1(self.config) self.cookbook._restore_cache() - self.assertEquals(self.cookbook.status, {}) + self.assertEqual(self.cookbook.status, {}) self.cookbook.add_recipe(recipe) - self.assertEquals(len(self.cookbook.status), 0) + self.assertEqual(len(self.cookbook.status), 0) status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(len(self.cookbook.status), 1) - self.assertEquals(status.steps, []) + self.assertEqual(len(self.cookbook.status), 1) + self.assertEqual(status.steps, []) status.steps.append('1') status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(len(self.cookbook.status), 1) - self.assertEquals(status.steps[0], '1') + self.assertEqual(len(self.cookbook.status), 1) + self.assertEqual(status.steps[0], '1') def testUpdateStatus(self): recipe = Recipe1(self.config) @@ -92,13 +92,13 @@ class PackageTest(unittest.TestCase): self.cookbook._restore_cache() self.cookbook.update_step_status(recipe.name, 'fetch') status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(status.steps, ['fetch']) + self.assertEqual(status.steps, ['fetch']) self.cookbook.update_step_status(recipe.name, 'build') status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(status.steps, ['fetch', 'build']) + self.assertEqual(status.steps, ['fetch', 'build']) self.cookbook.update_step_status(recipe.name, 'install') status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(status.steps, ['fetch', 'build', 'install']) + self.assertEqual(status.steps, ['fetch', 'build', 'install']) for step in ['fetch', 'build', 'install']: self.assertTrue(self.cookbook.step_done(recipe.name, step)) @@ -108,10 +108,10 @@ class PackageTest(unittest.TestCase): self.cookbook._restore_cache() self.cookbook.update_build_status(recipe.name, '1.0') self.assertTrue(self.cookbook.status[recipe.name].needs_build) - self.assertEquals(self.cookbook.status[recipe.name].built_version, '1.0') + self.assertEqual(self.cookbook.status[recipe.name].built_version, '1.0') self.cookbook.update_build_status(recipe.name, None) self.assertFalse(self.cookbook.status[recipe.name].needs_build) - self.assertEquals(self.cookbook.status[recipe.name].built_version, None) + self.assertEqual(self.cookbook.status[recipe.name].built_version, None) def testResetRecipeStatus(self): recipe = Recipe1(self.config) @@ -119,5 +119,5 @@ class PackageTest(unittest.TestCase): self.cookbook._restore_cache() self.cookbook.reset_recipe_status(recipe.name) status = self.cookbook._recipe_status(recipe.name) - self.assertEquals(status.steps, []) + self.assertEqual(status.steps, []) self.assertTrue(self.cookbook.status[recipe.name].needs_build) diff --git a/test/test_cerbero_build_filesprovider.py b/test/test_cerbero_build_filesprovider.py index 7e0814d8..fdd36d5a 100644 --- a/test/test_cerbero_build_filesprovider.py +++ b/test/test_cerbero_build_filesprovider.py @@ -79,39 +79,39 @@ class PackageTest(unittest.TestCase): shutil.rmtree(self.tmp) def testFilesCategories(self): - self.assertEquals(sorted(['bins', 'libs', 'misc', 'devel']), + self.assertEqual(sorted(['bins', 'libs', 'misc', 'devel']), self.win32recipe._files_categories()) def testListBinaries(self): - self.assertEquals(self.win32recipe.files_list_by_category('bins'), + self.assertEqual(self.win32recipe.files_list_by_category('bins'), sorted(self.winbin)) - self.assertEquals(self.linuxrecipe.files_list_by_category('bins'), + self.assertEqual(self.linuxrecipe.files_list_by_category('bins'), sorted(self.linuxbin)) def testListLibraries(self): add_files(self.tmp) - self.assertEquals(self.win32recipe.files_list_by_category('libs'), + self.assertEqual(self.win32recipe.files_list_by_category('libs'), sorted(self.winlib)) - self.assertEquals(self.linuxrecipe.files_list_by_category('libs'), + self.assertEqual(self.linuxrecipe.files_list_by_category('libs'), sorted(self.linuxlib)) def testDevelFiles(self): add_files(self.tmp) - self.assertEquals(self.win32recipe.devel_files_list(), + self.assertEqual(self.win32recipe.devel_files_list(), sorted(self.windevfiles)) - self.assertEquals(self.linuxrecipe.devel_files_list(), + self.assertEqual(self.linuxrecipe.devel_files_list(), sorted(self.lindevfiles)) def testDistFiles(self): win32files = self.winlib + self.winbin + self.winmisc linuxfiles = self.linuxlib + self.linuxbin + self.linuxmisc add_files(self.tmp) - self.assertEquals(self.win32recipe.dist_files_list(), sorted(win32files)) - self.assertEquals(self.linuxrecipe.dist_files_list(), sorted(linuxfiles)) + self.assertEqual(self.win32recipe.dist_files_list(), sorted(win32files)) + self.assertEqual(self.linuxrecipe.dist_files_list(), sorted(linuxfiles)) def testGetAllFiles(self): win32files = self.winlib + self.winbin + self.winmisc + self.windevfiles linuxfiles = self.linuxlib + self.linuxbin + self.linuxmisc + self.lindevfiles add_files(self.tmp) - self.assertEquals(self.win32recipe.files_list(), sorted(win32files)) - self.assertEquals(self.linuxrecipe.files_list(), sorted(linuxfiles)) + self.assertEqual(self.win32recipe.files_list(), sorted(win32files)) + self.assertEqual(self.linuxrecipe.files_list(), sorted(linuxfiles)) diff --git a/test/test_cerbero_build_recipe.py b/test/test_cerbero_build_recipe.py index 78d31bb1..2b2a643c 100644 --- a/test/test_cerbero_build_recipe.py +++ b/test/test_cerbero_build_recipe.py @@ -62,9 +62,7 @@ class Recipe(recipe.Recipe): platform_licenses_test = {Platform.LINUX: [License.BSD]} -class Class3(object): - - __metaclass__ = recipe.MetaUniversalRecipe +class Class3(object, metaclass=recipe.MetaUniversalRecipe): def _do_step(self, name): return name @@ -92,12 +90,12 @@ class TestReceiptMetaClass(unittest.TestCase): def testFunctions(self): self.assertTrue(hasattr(self.t, 'class1_method')) self.assertTrue(hasattr(self.t, 'class2_method')) - self.assertEquals(self.t.fetch(), 'CODEPASS') - self.assertEquals(self.t.compile(), 'CODEPASS') - self.assertEquals(self.t.post_install(), 'CODEPASS') + self.assertEqual(self.t.fetch(), 'CODEPASS') + self.assertEqual(self.t.compile(), 'CODEPASS') + self.assertEqual(self.t.post_install(), 'CODEPASS') def testSubclassesInit(self): - self.assertEquals(self.t.test, 'CODEPASS') + self.assertEqual(self.t.test, 'CODEPASS') class TestReceipt(unittest.TestCase): @@ -114,14 +112,14 @@ class TestReceipt(unittest.TestCase): build_dir = os.path.join(self.config.sources, self.recipe.package_name) build_dir = os.path.abspath(build_dir) - self.assertEquals(self.recipe.repo_dir, repo_dir) - self.assertEquals(self.recipe.build_dir, build_dir) + self.assertEqual(self.recipe.repo_dir, repo_dir) + self.assertEqual(self.recipe.build_dir, build_dir) def testListDeps(self): self.recipe.config.target_platform = Platform.LINUX - self.assertEquals(['dep1', 'dep2', 'dep3'], self.recipe.list_deps()) + self.assertEqual(['dep1', 'dep2', 'dep3'], self.recipe.list_deps()) self.recipe.config.target_platform = Platform.WINDOWS - self.assertEquals(['dep1', 'dep2', 'dep4'], self.recipe.list_deps()) + self.assertEqual(['dep1', 'dep2', 'dep4'], self.recipe.list_deps()) def testRemoveSteps(self): self.recipe._remove_steps(['donotexits']) @@ -141,20 +139,20 @@ class TestLicenses(unittest.TestCase): self.recipe = Recipe(self.config) def testLicenses(self): - self.assertEquals(self.recipe.licenses, [License.LGPL]) + self.assertEqual(self.recipe.licenses, [License.LGPL]) licenses_libs = self.recipe.list_licenses_by_categories(['libs']) - self.assertEquals(licenses_libs['libs'], [License.LGPL]) - self.assertEquals(licenses_libs.values(), [[License.LGPL]]) + self.assertEqual(licenses_libs['libs'], [License.LGPL]) + self.assertEqual(list(licenses_libs.values()), [[License.LGPL]]) licenses_bins = self.recipe.list_licenses_by_categories(['bins']) - self.assertEquals(licenses_bins['bins'], [License.GPL]) - self.assertEquals(licenses_bins.values(), [[License.GPL]]) + self.assertEqual(licenses_bins['bins'], [License.GPL]) + self.assertEqual(list(licenses_bins.values()), [[License.GPL]]) self.recipe.platform = Platform.LINUX self.recipe.config.target_platform = Platform.LINUX licenses_test = self.recipe.list_licenses_by_categories(['test']) - self.assertEquals(licenses_test['test'], [License.BSD]) - self.assertEquals(licenses_test.values(), [[License.BSD]]) + self.assertEqual(licenses_test['test'], [License.BSD]) + self.assertEqual(list(licenses_test.values()), [[License.BSD]]) class TestMetaUniveralRecipe(unittest.TestCase): @@ -164,7 +162,7 @@ class TestMetaUniveralRecipe(unittest.TestCase): for _, step in recipe.BuildSteps(): self.assertTrue(hasattr(obj, step)) stepfunc = getattr(obj, step) - self.assertEquals(stepfunc(), step) + self.assertEqual(stepfunc(), step) class TestUniversalRecipe(unittest.TestCase): @@ -186,30 +184,30 @@ class TestUniversalRecipe(unittest.TestCase): self.assertTrue(self.recipe.is_empty()) def testProxyEmpty(self): - self.failUnlessRaises(AttributeError, getattr, self.recipe, 'name') + self.assertRaises(AttributeError, getattr, self.recipe, 'name') def testProxyRecipe(self): self.recipe.add_recipe(self.recipe_x86) - self.assertEquals(self.recipe.name, self.recipe_x86.name) - self.assertEquals(self.recipe.licence, self.recipe_x86.licence) - self.assertEquals(self.recipe.uuid, self.recipe_x86.uuid) + self.assertEqual(self.recipe.name, self.recipe_x86.name) + self.assertEqual(self.recipe.licence, self.recipe_x86.licence) + self.assertEqual(self.recipe.uuid, self.recipe_x86.uuid) def testAddRecipe(self): self.recipe.add_recipe(self.recipe_x86) - self.assertEquals(self.recipe._recipes[Architecture.X86], + self.assertEqual(self.recipe._recipes[Architecture.X86], self.recipe_x86) - self.assertEquals(self.recipe._proxy_recipe, + self.assertEqual(self.recipe._proxy_recipe, self.recipe_x86) def testDifferentRecipe(self): self.recipe.add_recipe(self.recipe_x86) recipe_test = Recipe1(self.config_x86) recipe_test.name = 'noname' - self.failUnlessRaises(FatalError, self.recipe.add_recipe, recipe_test) + self.assertRaises(FatalError, self.recipe.add_recipe, recipe_test) def testSteps(self): - self.assertEquals(self.recipe.steps, []) + self.assertEqual(self.recipe.steps, []) self.recipe.add_recipe(self.recipe_x86) self.recipe.add_recipe(self.recipe_x86_64) - self.assertEquals(self.recipe.steps, + self.assertEqual(self.recipe.steps, recipe.BuildSteps() + [recipe.BuildSteps.MERGE]) diff --git a/test/test_cerbero_config.py b/test/test_cerbero_config.py index 8baf0edb..f4465f83 100644 --- a/test/test_cerbero_config.py +++ b/test/test_cerbero_config.py @@ -39,7 +39,7 @@ class LinuxPackagesTest(unittest.TestCase): f.write('%s="test"\n' % p) func() for p in properties: - self.assertEquals(getattr(config, p), 'test') + self.assertEqual(getattr(config, p), 'test') def testAllPropsInitializedNone(self): config = Config() @@ -92,9 +92,9 @@ class LinuxPackagesTest(unittest.TestCase): 'force_git_commit': None, 'universal_archs': [cconfig.Architecture.X86, cconfig.Architecture.X86_64], } - self.assertEquals(sorted(config._properties), sorted(props.keys())) - for p, v in props.iteritems(): - self.assertEquals(getattr(config, p), v) + self.assertEqual(sorted(config._properties), sorted(props.keys())) + for p, v in props.items(): + self.assertEqual(getattr(config, p), v) def testLoadMainConfig(self): config = Config() @@ -126,7 +126,7 @@ class LinuxPackagesTest(unittest.TestCase): config = Config() del os.environ[cconfig.CERBERO_UNINSTALLED] config._check_uninstalled() - self.failUnlessRaises(FatalError, config.load_defaults) + self.assertRaises(FatalError, config.load_defaults) def testCheckUninstalled(self): config = Config() @@ -145,43 +145,43 @@ class LinuxPackagesTest(unittest.TestCase): config.do_setup_env() env = config.get_env(tmpdir, os.path.join(tmpdir, 'lib'), config.py_prefix) - for k, v in env.iteritems(): - self.assertEquals(os.environ[k], v) + for k, v in env.items(): + self.assertEqual(os.environ[k], v) def testParseBadConfigFile(self): config = Config() tmpfile = tempfile.NamedTemporaryFile() with open(tmpfile.name, 'w') as f: f.write('nonsense line') - self.failUnlessRaises(ConfigurationError, config.parse, tmpfile.name) + self.assertRaises(ConfigurationError, config.parse, tmpfile.name) def testJoinPath(self): config = Config() config.platform = Platform.LINUX - self.assertEquals(config._join_path('/test1', '/test2'), '/test1:/test2') + self.assertEqual(config._join_path('/test1', '/test2'), '/test1:/test2') config.platform = Platform.WINDOWS - self.assertEquals(config._join_path('/test1', '/test2'), '/test1;/test2') + self.assertEqual(config._join_path('/test1', '/test2'), '/test1;/test2') def testLoadCommandConfig(self): config = Config() config.filename = None config._load_cmd_config(None) self.assertIsNone(config.filename) - self.failUnlessRaises(ConfigurationError, config._load_cmd_config, + self.assertRaises(ConfigurationError, config._load_cmd_config, '/foo/bar') tmpfile = tempfile.NamedTemporaryFile() config._load_cmd_config(tmpfile.name) - self.assertEquals(config.filename, cconfig.DEFAULT_CONFIG_FILE) + self.assertEqual(config.filename, cconfig.DEFAULT_CONFIG_FILE) def testLastDefaults(self): config = Config() config._load_last_defaults() cerbero_home = os.path.expanduser('~/cerbero') - self.assertEquals(config.prefix, os.path.join(cerbero_home, 'dist')) - self.assertEquals(config.install_dir, config.prefix) - self.assertEquals(config.sources, + self.assertEqual(config.prefix, os.path.join(cerbero_home, 'dist')) + self.assertEqual(config.install_dir, config.prefix) + self.assertEqual(config.sources, os.path.join(cerbero_home, 'sources')) - self.assertEquals(config.local_sources, + self.assertEqual(config.local_sources, os.path.join(cerbero_home, 'sources', 'local')) def testRecipesExternalRepositories(self): @@ -192,7 +192,7 @@ class LinuxPackagesTest(unittest.TestCase): expected = {'default': ('test', 0), 'test1': ('/path/to/repo', 1), 'test2': ('/path/to/other/repo', 2)} - self.assertEquals(config.get_recipes_repos(), expected) + self.assertEqual(config.get_recipes_repos(), expected) def testPakcagesExternalRepositories(self): config = Config() @@ -202,4 +202,4 @@ class LinuxPackagesTest(unittest.TestCase): expected = {'default': ('test', 0), 'test1': ('/path/to/repo', 1), 'test2': ('/path/to/other/repo', 2)} - self.assertEquals(config.get_packages_repos(), expected) + self.assertEqual(config.get_packages_repos(), expected) diff --git a/test/test_cerbero_ide_pkgconfig.py b/test/test_cerbero_ide_pkgconfig.py index 4827efd7..fbcf7909 100644 --- a/test/test_cerbero_ide_pkgconfig.py +++ b/test/test_cerbero_ide_pkgconfig.py @@ -35,41 +35,41 @@ class TestPkgConfig(unittest.TestCase): def testListAll(self): expected = ['gobject-2.0', 'gmodule-2.0', 'libxml-2.0', 'gthread-2.0', 'glib-2.0', 'gmodule-no-export-2.0', 'gstreamer-0.10'] - self.assertEquals(sorted(PkgConfig.list_all()), sorted(expected)) + self.assertEqual(sorted(PkgConfig.list_all()), sorted(expected)) def testIncludeDirs(self): expected = ['/usr/include/gstreamer-0.10', '/usr/include/glib-2.0', '/usr/lib/glib-2.0/include', '/usr/include/libxml2'] - self.assertEquals(self.pkgconfig.include_dirs(), expected) + self.assertEqual(self.pkgconfig.include_dirs(), expected) expected = ['/usr/include/gstreamer-0.10'] - self.assertEquals(self.pkgconfig2.include_dirs(), expected) + self.assertEqual(self.pkgconfig2.include_dirs(), expected) def testCFlags(self): expected = ['-pthread'] - self.assertEquals(self.pkgconfig.cflags(), expected) + self.assertEqual(self.pkgconfig.cflags(), expected) expected = [] - self.assertEquals(self.pkgconfig2.cflags(), expected) + self.assertEqual(self.pkgconfig2.cflags(), expected) def testLibrariesDir(self): expected = [] - self.assertEquals(self.pkgconfig.libraries_dirs(), expected) + self.assertEqual(self.pkgconfig.libraries_dirs(), expected) expected = [] - self.assertEquals(self.pkgconfig2.libraries_dirs(), expected) + self.assertEqual(self.pkgconfig2.libraries_dirs(), expected) def testLibraries(self): expected = ['gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'xml2', 'gthread-2.0', 'rt', 'glib-2.0'] - self.assertEquals(self.pkgconfig.libraries(), expected) + self.assertEqual(self.pkgconfig.libraries(), expected) expected = ['gstreamer-0.10'] - self.assertEquals(self.pkgconfig2.libraries(), expected) + self.assertEqual(self.pkgconfig2.libraries(), expected) def testRequires(self): expected = ['glib-2.0', 'gobject-2.0', 'gmodule-no-export-2.0', 'gthread-2.0', 'libxml-2.0'] - self.assertEquals(self.pkgconfig.requires(), expected) - self.assertEquals(self.pkgconfig2.requires(), expected) + self.assertEqual(self.pkgconfig.requires(), expected) + self.assertEqual(self.pkgconfig2.requires(), expected) def testPrefix(self): - self.assertEquals(self.pkgconfig.prefix(), '/usr') - self.assertEquals(self.pkgconfig2.prefix(), '/usr') + self.assertEqual(self.pkgconfig.prefix(), '/usr') + self.assertEqual(self.pkgconfig2.prefix(), '/usr') diff --git a/test/test_cerbero_ide_xcode_xcconfig.py b/test/test_cerbero_ide_xcode_xcconfig.py index 87c76d94..5ce7d522 100644 --- a/test/test_cerbero_ide_xcode_xcconfig.py +++ b/test/test_cerbero_ide_xcode_xcconfig.py @@ -49,11 +49,11 @@ class TestPkgConfig(unittest.TestCase): '/usr/lib/glib-2.0/include ' '/usr/include/libxml2', 'lsp': ''} - self.assertEquals(expected, xcconfig._fill()) + self.assertEqual(expected, xcconfig._fill()) def testXCConfig(self): tmp = tempfile.NamedTemporaryFile() xcconfig = XCConfig('gstreamer-0.10') xcconfig.create(tmp.name) with open(tmp.name, 'r') as f: - self.assertEquals(f.read(), XCCONFIG) + self.assertEqual(f.read(), XCCONFIG) diff --git a/test/test_cerbero_packages_disttarball.py b/test/test_cerbero_packages_disttarball.py index b7427a2d..8db2c98d 100644 --- a/test/test_cerbero_packages_disttarball.py +++ b/test/test_cerbero_packages_disttarball.py @@ -44,27 +44,27 @@ class DistTarballTest(unittest.TestCase): def testRuntimePackage(self): # Creates one package with the runtime files filenames = self.packager.pack(self.tmp, devel=False) - self.assertEquals(len(filenames), 1) + self.assertEqual(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) - self.assertEquals(tarfiles, self.package.files_list()) + self.assertEqual(tarfiles, self.package.files_list()) def testRuntimeAndDevelPackages(self): # Creates 2 packages, one with the runtime files a second one with the # devel files filenames = self.packager.pack(self.tmp, devel=True) - self.assertEquals(len(filenames), 2) + self.assertEqual(len(filenames), 2) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) - self.assertEquals(tarfiles, self.package.files_list()) + self.assertEqual(tarfiles, self.package.files_list()) tar = tarfile.open(filenames[1], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) - self.assertEquals(tarfiles, self.package.devel_files_list()) + self.assertEqual(tarfiles, self.package.devel_files_list()) def testRuntimeWithDevelPackage(self): # Creates 1 package, with the runtime files and the devel files filenames = self.packager.pack(self.tmp, devel=True, split=False) - self.assertEquals(len(filenames), 1) + self.assertEqual(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) - self.assertEquals(tarfiles, self.package.all_files_list()) + self.assertEqual(tarfiles, self.package.all_files_list()) diff --git a/test/test_cerbero_packages_linux.py b/test/test_cerbero_packages_linux.py index a29b0198..9ac86fca 100644 --- a/test/test_cerbero_packages_linux.py +++ b/test/test_cerbero_packages_linux.py @@ -71,24 +71,24 @@ class LinuxPackagesTest(unittest.TestCase): # Test default values package = Package1(config, None, None) packager = linux.LinuxPackager(config, package, None) - self.assertEquals(packager.package_prefix, '') - self.assertEquals(packager.full_package_name, 'gstreamer-test1-1.0') - self.assertEquals(packager.packager, DEFAULT_PACKAGER) + self.assertEqual(packager.package_prefix, '') + self.assertEqual(packager.full_package_name, 'gstreamer-test1-1.0') + self.assertEqual(packager.packager, DEFAULT_PACKAGER) # Test packages_prefix and packager config.packages_prefix = 'test' config.packager = 'Pin <pan@p.un>' packager = linux.LinuxPackager(config, package, None) - self.assertEquals(packager.package_prefix, 'test-') - self.assertEquals(packager.full_package_name, + self.assertEqual(packager.package_prefix, 'test-') + self.assertEqual(packager.full_package_name, 'test-gstreamer-test1-1.0') - self.assertEquals(packager.packager, 'Pin <pan@p.un>') + self.assertEqual(packager.packager, 'Pin <pan@p.un>') # Test ignore package package.ignore_package_prefix = True packager = linux.LinuxPackager(config, package, None) - self.assertEquals(packager.package_prefix, '') - self.assertEquals(packager.full_package_name, 'gstreamer-test1-1.0') + self.assertEqual(packager.package_prefix, '') + self.assertEqual(packager.full_package_name, 'gstreamer-test1-1.0') def testRequires(self): self.packager._empty_packages = [] @@ -98,25 +98,25 @@ class LinuxPackagesTest(unittest.TestCase): 'gstreamer-test1']) requires = self.packager.get_requires(PackageType.RUNTIME, '-dev') - self.assertEquals(expected, requires) + self.assertEqual(expected, requires) # test devel packages requires = self.packager.get_requires(PackageType.DEVEL, '-dev') - self.assertEquals([], requires) + self.assertEqual([], requires) self.store.get_package('gstreamer-test1').has_devel_package = True requires = self.packager.get_requires(PackageType.DEVEL, '-dev') - self.assertEquals(['gstreamer-test1-dev'], requires) + self.assertEqual(['gstreamer-test1-dev'], requires) for p in expected: self.store.get_package(p).has_devel_package = True requires = self.packager.get_requires(PackageType.DEVEL, '-dev') - self.assertEquals([x + '-dev' for x in expected], requires) + self.assertEqual([x + '-dev' for x in expected], requires) # test empty packages self.packager._empty_packages = \ [self.store.get_package('gstreamer-test2')] requires = self.packager.get_requires(PackageType.RUNTIME, '-dev') expected.remove('gstreamer-test2') - self.assertEquals(expected, requires) + self.assertEqual(expected, requires) def testMetaPackageRequires(self): self.packager._empty_packages = [] @@ -127,16 +127,16 @@ class LinuxPackagesTest(unittest.TestCase): self.store.get_package('gstreamer-test3').has_runtime_package = True self.store.get_package('gstreamer-test-bindings').has_runtime_package = True requires = self.packager.get_meta_requires(PackageType.RUNTIME, '') - self.assertEquals(expected, requires) + self.assertEqual(expected, requires) # test devel packages requires = self.packager.get_meta_requires(PackageType.DEVEL, '-dev') - self.assertEquals(([], [], []), requires) + self.assertEqual(([], [], []), requires) # test empty packages self.store.get_package('gstreamer-test1').has_devel_package = True requires = self.packager.get_meta_requires(PackageType.DEVEL, '-dev') - self.assertEquals((['gstreamer-test1-dev'], [], []), requires) + self.assertEqual((['gstreamer-test1-dev'], [], []), requires) for p in [self.store.get_package(x[0]) for x in expected]: p.has_devel_package = True @@ -144,7 +144,7 @@ class LinuxPackagesTest(unittest.TestCase): expected = (['gstreamer-test1-dev'], ['gstreamer-test3-dev'], ['gstreamer-test-bindings-dev']) - self.assertEquals(expected, requires) + self.assertEqual(expected, requires) def testPackDeps(self): expected = sorted(['gstreamer-test-bindings', @@ -158,12 +158,12 @@ class LinuxPackagesTest(unittest.TestCase): global packed packed = [] self.packager.pack_deps('', '', True) - self.assertEquals(sorted(packed), expected) + self.assertEqual(sorted(packed), expected) packed = [] self.packager.devel = False self.packager.pack_deps('', '', True) - self.assertEquals(sorted(packed), expected) + self.assertEqual(sorted(packed), expected) packed = [] def testPack(self): @@ -172,11 +172,11 @@ class LinuxPackagesTest(unittest.TestCase): paths = self.packager.pack('', False, True, True, False, None) self.assertTrue(os.path.exists('gstreamer-runtime-stamp')) os.remove('gstreamer-runtime-stamp') - self.assertEquals(paths, ['test']) + self.assertEqual(paths, ['test']) self.packager = DummyPackager(self.config, self.store.get_package('gstreamer-test1'), self.store) paths = self.packager.pack('', False, True, True, False, None) self.assertTrue(os.path.exists('gstreamer-test1-stamp')) os.remove('gstreamer-test1-stamp') - self.assertEquals(paths, ['test']) + self.assertEqual(paths, ['test']) diff --git a/test/test_cerbero_packages_osx_info_plist.py b/test/test_cerbero_packages_osx_info_plist.py index 86d1fa30..e3394853 100644 --- a/test/test_cerbero_packages_osx_info_plist.py +++ b/test/test_cerbero_packages_osx_info_plist.py @@ -41,27 +41,27 @@ class InfoPlistTest(unittest.TestCase): 'Test package') def testFormatProperty(self): - self.assertEquals('<key>Key</key>\n<string>Value</string>', + self.assertEqual('<key>Key</key>\n<string>Value</string>', self.info_plist._format_property('Key', 'Value')) def testGetPropertiesString(self): result = self.info_plist._get_properties_string() expected = self.PROPS_TPL % {'icon': '', 'ptype': ''} - self.assertEquals(result, expected) + self.assertEqual(result, expected) def testFrameworkPackageType(self): self.info_plist = FrameworkPlist('test', 'test.org', '1.0', 'Test package') result = self.info_plist._get_properties_string() expected = self.PROPS_TPL % {'ptype': 'FMWK', 'icon': ''} - self.assertEquals(result, expected) + self.assertEqual(result, expected) def testApplicationPackageType(self): self.info_plist = ApplicationPlist('test', 'test.org', '1.0', 'Test package') result = self.info_plist._get_properties_string() expected = self.PROPS_TPL % {'ptype': 'APPL', 'icon': ''} - self.assertEquals(result, expected) + self.assertEqual(result, expected) def testGetPropertiesStringWithIcon(self): self.info_plist.icon = 'test.ico' @@ -70,7 +70,7 @@ class InfoPlistTest(unittest.TestCase): self.info_plist._format_property('CFBundleIconFile', 'test.ico') + '\n'} self.info_plist.icon = None - self.assertEquals(result, expected) + self.assertEqual(result, expected) def testSave(self): tmp = tempfile.NamedTemporaryFile() @@ -80,4 +80,4 @@ class InfoPlistTest(unittest.TestCase): expected = INFO_PLIST_TPL % (self.info_plist.BEGIN, self.info_plist._get_properties_string(), self.info_plist.END) - self.assertEquals(result, expected) + self.assertEqual(result, expected) diff --git a/test/test_cerbero_packages_package.py b/test/test_cerbero_packages_package.py index 7344a4a2..f4cd8839 100644 --- a/test/test_cerbero_packages_package.py +++ b/test/test_cerbero_packages_package.py @@ -50,23 +50,23 @@ class PackageTest(unittest.TestCase): shutil.rmtree(self.tmp) def testPackageMode(self): - self.assertEquals(self.linuxpackage.name, 'gstreamer-test1') - self.assertEquals(self.linuxpackage.shortdesc, 'GStreamer Test') + self.assertEqual(self.linuxpackage.name, 'gstreamer-test1') + self.assertEqual(self.linuxpackage.shortdesc, 'GStreamer Test') self.linuxpackage.set_mode(PackageType.DEVEL) - self.assertEquals(self.linuxpackage.package_mode, PackageType.DEVEL) - self.assertEquals(self.linuxpackage.name, 'gstreamer-test1-devel') - self.assertEquals(self.linuxpackage.shortdesc, + self.assertEqual(self.linuxpackage.package_mode, PackageType.DEVEL) + self.assertEqual(self.linuxpackage.name, 'gstreamer-test1-devel') + self.assertEqual(self.linuxpackage.shortdesc, 'GStreamer Test (Development Files)') def testParseFiles(self): - self.assertEquals(self.win32package._recipes_files['recipe1'], + self.assertEqual(self.win32package._recipes_files['recipe1'], ['misc', 'libs', 'bins']) - self.assertEquals(self.win32package._recipes_files['recipe5'], ['libs']) + self.assertEqual(self.win32package._recipes_files['recipe5'], ['libs']) def testListRecipesDeps(self): - self.assertEquals(self.win32package.recipes_dependencies(), + self.assertEqual(self.win32package.recipes_dependencies(), ['recipe1', 'recipe5', 'recipe2']) - self.assertEquals(self.linuxpackage.recipes_dependencies(), + self.assertEqual(self.linuxpackage.recipes_dependencies(), ['recipe1', 'recipe2']) def testFilesList(self): @@ -79,9 +79,9 @@ class PackageTest(unittest.TestCase): 'lib/libgstreamer-x11.so.1', 'lib/libgstreamer-0.10.so.1', 'libexec/gstreamer-0.10/pluginsloader', 'linux'] - self.assertEquals(sorted(winfiles), + self.assertEqual(sorted(winfiles), sorted(self.win32package.files_list())) - self.assertEquals(sorted(linuxfiles), + self.assertEqual(sorted(linuxfiles), sorted(self.linuxpackage.files_list())) def testDevelFilesList(self): @@ -97,18 +97,18 @@ class PackageTest(unittest.TestCase): 'lib/libtest.def', 'lib/test.lib', 'lib/libgstreamer-0.10.dll.a', 'lib/libgstreamer-0.10.def', 'lib/gstreamer-0.10.lib'] - self.assertEquals(sorted(windevfiles), self.win32package.devel_files_list()) - self.assertEquals(sorted(linuxdevfiles), self.linuxpackage.devel_files_list()) + self.assertEqual(sorted(windevfiles), self.win32package.devel_files_list()) + self.assertEqual(sorted(linuxdevfiles), self.linuxpackage.devel_files_list()) def testSystemDependencies(self): config = Config(self.tmp, Platform.LINUX) config.target_distro = Distro.DEBIAN package = Package4(config, None, None) - self.assertEquals(package.get_sys_deps(), ['python']) + self.assertEqual(package.get_sys_deps(), ['python']) config.target_distro = Distro.REDHAT config.target_distro_version = DistroVersion.FEDORA_16 package = Package4(config, None, None) - self.assertEquals(package.get_sys_deps(), ['python27']) + self.assertEqual(package.get_sys_deps(), ['python27']) class TestMetaPackages(unittest.TestCase): @@ -132,20 +132,20 @@ class TestMetaPackages(unittest.TestCase): files.extend(list_func()) list_func = getattr(self.package, func_name) - self.assertEquals(sorted(files), list_func()) + self.assertEqual(sorted(files), list_func()) def testListPackages(self): expected = ['gstreamer-test1', 'gstreamer-test3', 'gstreamer-test-bindings', 'gstreamer-test2'] - self.assertEquals(self.package.list_packages(), expected) + self.assertEqual(self.package.list_packages(), expected) def testPlatfromPackages(self): packages_attr = object.__getattribute__(self.package, 'packages') - self.assertEquals(len(packages_attr), 3) + self.assertEqual(len(packages_attr), 3) platform_packages_attr = object.__getattribute__(self.package, 'platform_packages') - self.assertEquals(len(platform_packages_attr), 1) - self.assertEquals(len(self.package.packages), + self.assertEqual(len(platform_packages_attr), 1) + self.assertEqual(len(self.package.packages), len(packages_attr) + len(platform_packages_attr)) def testFilesList(self): @@ -174,7 +174,7 @@ class AppPackageTest(unittest.TestCase): self.app.embed_deps = True expected = self.app._app_recipe.files_list() result = self.app.files_list() - self.assertEquals(expected, result) + self.assertEqual(expected, result) def testListFilesWithEmbededDeps(self): self.app.embed_deps = True @@ -188,16 +188,16 @@ class AppPackageTest(unittest.TestCase): files.extend(package.files_list()) files.extend(self.app._app_recipe.files_list()) files = sorted(set(files)) - self.assertEquals(files, self.app.files_list()) + self.assertEqual(files, self.app.files_list()) def testListFilesWithoutEmbededDeps(self): self.app.embed_deps = False expected = self.app._app_recipe.files_list() result = self.app.files_list() - self.assertEquals(expected, result) + self.assertEqual(expected, result) def testDevelFilesList(self): - self.assertEquals(self.app.devel_files_list(), []) + self.assertEqual(self.app.devel_files_list(), []) def testAllFilesList(self): - self.assertEquals(self.app.files_list(), self.app.all_files_list()) + self.assertEqual(self.app.files_list(), self.app.all_files_list()) diff --git a/test/test_cerbero_packages_packagemaker.py b/test/test_cerbero_packages_packagemaker.py index 75d55f0d..9e0ce4e1 100644 --- a/test/test_cerbero_packages_packagemaker.py +++ b/test/test_cerbero_packages_packagemaker.py @@ -51,7 +51,7 @@ class PackageMakerTest(unittest.TestCase): tmpdest = packager._create_bundle(files, PackageType.RUNTIME)[0] bundlefiles = shell.check_call('find . -type f ', tmpdest).split('\n') bundlefiles = sorted([f[2:] for f in bundlefiles])[1:] - self.assertEquals(bundlefiles, self.files) + self.assertEqual(bundlefiles, self.files) shutil.rmtree(tmpdest) def _add_files(self): @@ -86,7 +86,7 @@ class TestPackageMaker(unittest.TestCase): args = {'r': 'root', 'i': 'pkg_id', 'n': 'version', 't': 'title', 'l': 'destination', 'o': 'output_file'} cmd = pm._cmd_with_args(args) - self.assertEquals(cmd, + self.assertEqual(cmd, "./PackageMaker -i 'pkg_id' -l 'destination' -o 'output_file' " "-n 'version' -r 'root' -t 'title'") @@ -94,6 +94,6 @@ class TestPackageMaker(unittest.TestCase): pm = DummyPackageMaker() pm.create_package('root', 'pkg_id', 'version', 'title', 'output_file', 'destination') - self.assertEquals(pm.cmd, + self.assertEqual(pm.cmd, "./PackageMaker -g '10.6' -i 'pkg_id' -l 'destination' -o 'output_file' " "-n 'version' -r 'root' -t 'title'") diff --git a/test/test_cerbero_packages_packagesstore.py b/test/test_cerbero_packages_packagesstore.py index 920650a9..5f932933 100644 --- a/test/test_cerbero_packages_packagesstore.py +++ b/test/test_cerbero_packages_packagesstore.py @@ -61,18 +61,18 @@ class PackageTest(unittest.TestCase): def testAddPackage(self): package = common.Package1(self.config, None, None) - self.assertEquals(len(self.store._packages), 0) + self.assertEqual(len(self.store._packages), 0) self.store.add_package(package) - self.assertEquals(len(self.store._packages), 1) - self.assertEquals(package, self.store._packages[package.name]) + self.assertEqual(len(self.store._packages), 1) + self.assertEqual(package, self.store._packages[package.name]) def testGetPackage(self): package = common.Package1(self.config, None, None) self.store.add_package(package) - self.assertEquals(package, self.store.get_package(package.name)) + self.assertEqual(package, self.store.get_package(package.name)) def testPackageNotFound(self): - self.failUnlessRaises(PackageNotFoundError, self.store.get_package, + self.assertRaises(PackageNotFoundError, self.store.get_package, 'unknown') def testPackagesList(self): @@ -81,21 +81,21 @@ class PackageTest(unittest.TestCase): self.store.add_package(package) self.store.add_package(metapackage) l = sorted([package, metapackage], key=lambda x: x.name) - self.assertEquals(l, self.store.get_packages_list()) + self.assertEqual(l, self.store.get_packages_list()) def testPackageDeps(self): package = common.Package1(self.config, None, None) package2 = common.Package2(self.config, None, None) self.store.add_package(package) self.store.add_package(package2) - self.assertEquals(package.deps, + self.assertEqual(package.deps, [x.name for x in self.store.get_package_deps(package.name)]) def testMetaPackageDeps(self): metapackage = common.MetaPackage(self.config, None) self.store.add_package(metapackage) # the metapackage depends on package that are not yet in the store - self.failUnlessRaises(PackageNotFoundError, + self.assertRaises(PackageNotFoundError, self.store.get_package_deps, metapackage.name) for klass in [common.Package1, common.Package2, common.Package3, common.Package4]: @@ -107,7 +107,7 @@ class PackageTest(unittest.TestCase): deps = ['gstreamer-test-bindings', 'gstreamer-test1', 'gstreamer-test2', 'gstreamer-test3'] res = [x.name for x in self.store.get_package_deps(metapackage.name)] - self.assertEquals(sorted(deps), sorted(res)) + self.assertEqual(sorted(deps), sorted(res)) def testLoadPackageFromFile(self): package_file = tempfile.NamedTemporaryFile() @@ -115,7 +115,7 @@ class PackageTest(unittest.TestCase): package_file.flush() p = self.store._load_package_from_file(package_file.name) self.assertIsInstance(p, Package) - self.assertEquals('test-package', p.name) + self.assertEqual('test-package', p.name) def testLoadMetaPackageFromFile(self): for x, t in [(SDKPACKAGE, SDKPackage), @@ -124,9 +124,9 @@ class PackageTest(unittest.TestCase): package_file.write(x) package_file.flush() p = self.store._load_package_from_file(package_file.name) - print p, type(p) + print(p, type(p)) self.assertIsInstance(p, t) - self.assertEquals('test-package', p.name) + self.assertEqual('test-package', p.name) def testImports(self): package_file = tempfile.NamedTemporaryFile() @@ -136,5 +136,5 @@ class PackageTest(unittest.TestCase): self.assertIsInstance(p, Package) try: p.test_imports() - except ImportError, e: + except ImportError as e: self.fail("Import error raised, %s", e) diff --git a/test/test_cerbero_packages_pmdoc.py b/test/test_cerbero_packages_pmdoc.py index daaa1d83..0694aefa 100644 --- a/test/test_cerbero_packages_pmdoc.py +++ b/test/test_cerbero_packages_pmdoc.py @@ -42,17 +42,17 @@ class IndexTest(unittest.TestCase, XMLMixin): def testAddRoot(self): self.index._add_root() - self.assertEquals(self.index.root.tag, Index.DOCUMENT_TAG) - self.assertEquals(self.index.root.attrib['spec'], Index.SPEC_VERSION) - self.assertEquals(len(self.index.root.getchildren()), 0) + self.assertEqual(self.index.root.tag, Index.DOCUMENT_TAG) + self.assertEqual(self.index.root.attrib['spec'], Index.SPEC_VERSION) + self.assertEqual(len(self.index.root.getchildren()), 0) def testAddProperties(self): self.index._add_root() self.index._add_properties() children = self.index.root.getchildren() - self.assertEquals(len(children), 1) + self.assertEqual(len(children), 1) properties = children[0] - self.assertEquals(len(properties.getchildren()), 6) + self.assertEqual(len(properties.getchildren()), 6) self.check_text(properties, Index.TAG_ORGANIZATION, self.package.org) self.check_text(properties, Index.TAG_TITLE, self.package.title) self.check_text(properties, Index.TAG_BUILD, @@ -68,7 +68,7 @@ class IndexTest(unittest.TestCase, XMLMixin): self.index._add_root() self.index._add_distribution() children = self.index.root.getchildren() - self.assertEquals(len(children), 1) + self.assertEqual(len(children), 1) dist =children[0] self.find_one(dist, Index.TAG_SCRIPTS) self.check_attrib(dist, Index.TAG_VERSION, Index.ATTR_MIN_SPEC, @@ -90,7 +90,7 @@ class IndexTest(unittest.TestCase, XMLMixin): self.index._add_contents() children = self.index.root.getchildren() # 1 choice + 4 item - self.assertEquals(len(children), 5) + self.assertEqual(len(children), 5) contents = self.find_one(self.index.root, Index.TAG_CONTENTS) packages =[] @@ -107,14 +107,14 @@ class IndexTest(unittest.TestCase, XMLMixin): self.fail("Incorrect choice %s" % choice) elpkrefs = [x.attrib['id'] for x in \ choice.iterfind(Index.TAG_PKGREF)] - self.assertEquals(sorted(["default.%s.%s" % + self.assertEqual(sorted(["default.%s.%s" % (self.config.target_arch, x) for x in pkrefs]), sorted(elpkrefs)) packages.extend(pkrefs) items = [x.text[:-4] for x in self.index.root.iterfind(Index.TAG_ITEM) if x.attrib['type']=='pkgref'] - self.assertEquals(sorted(packages), sorted(items)) + self.assertEqual(sorted(packages), sorted(items)) class PkgRefTest(unittest.TestCase, XMLMixin): @@ -128,10 +128,10 @@ class PkgRefTest(unittest.TestCase, XMLMixin): def testAddRoot(self): self.pkgref._add_root() - self.assertEquals(self.pkgref.root.tag, PkgRef.TAG_PKGREF) - self.assertEquals(self.pkgref.root.attrib['spec'], PkgRef.SPEC_VERSION) - self.assertEquals(self.pkgref.root.attrib['uuid'], self.package.uuid) - self.assertEquals(len(self.pkgref.root.getchildren()), 0) + self.assertEqual(self.pkgref.root.tag, PkgRef.TAG_PKGREF) + self.assertEqual(self.pkgref.root.attrib['spec'], PkgRef.SPEC_VERSION) + self.assertEqual(self.pkgref.root.attrib['uuid'], self.package.uuid) + self.assertEqual(len(self.pkgref.root.getchildren()), 0) def testAddScripts(self): self.pkgref._add_root() @@ -170,7 +170,7 @@ class PkgRefTest(unittest.TestCase, XMLMixin): 'parent', 'installTo.isRelativeType', 'installTo', 'version', 'identifier'] docmods = [x.text for x in config.iterfind(PkgRef.TAG_MOD)] - self.assertEquals(sorted(mods), sorted(docmods)) + self.assertEqual(sorted(mods), sorted(docmods)) flags = self.find_one(config, PkgRef.TAG_FLAGS) self.find_one(flags, PkgRef.TAG_FOLLOW_SYMLINKS) @@ -204,10 +204,10 @@ class PkgContentsTest(unittest.TestCase, XMLMixin): def testAddRoot(self): self.pkgcontents._add_root() - self.assertEquals(self.pkgcontents.root.tag, + self.assertEqual(self.pkgcontents.root.tag, PkgContents.TAG_PKG_CONTENTS) - self.assertEquals(self.pkgcontents.root.attrib['spec'], PkgContents.SPEC_VERSION) - self.assertEquals(len(self.pkgcontents.root.getchildren()), 0) + self.assertEqual(self.pkgcontents.root.attrib['spec'], PkgContents.SPEC_VERSION) + self.assertEqual(len(self.pkgcontents.root.getchildren()), 0) def testAddPackageRoot(self): self.pkgcontents._add_root() @@ -222,7 +222,7 @@ class PkgContentsTest(unittest.TestCase, XMLMixin): children = [x for x in self.pkgcontents.proot.getchildren() if x.tag == PkgContents.TAG_F] children_path = [x.attrib['n'] for x in children] - self.assertEquals(sorted(children_path), sorted(['bin', 'lib', 'README'])) + self.assertEqual(sorted(children_path), sorted(['bin', 'lib', 'README'])) for c in children: if c.attrib['n'] == 'bin': self.check_attrib(c, PkgContents.TAG_F, 'n', 'gst-inspect') @@ -232,9 +232,9 @@ class PkgContentsTest(unittest.TestCase, XMLMixin): self.check_attrib(c, PkgContents.TAG_F, 'n', 'libgstplugin.so') else: - self.assertEquals(c.attrib['n'], 'libgstreamer.so.1.0') + self.assertEqual(c.attrib['n'], 'libgstreamer.so.1.0') else: - self.assertEquals(c.attrib['n'], 'README') + self.assertEqual(c.attrib['n'], 'README') class TestPMDoc(unittest.TestCase): @@ -269,4 +269,4 @@ class TestPMDoc(unittest.TestCase): for p in packages: expected_files.append("%s.xml" % p) expected_files.append("%s-contents.xml" % p) - self.assertEquals(sorted(files), sorted(expected_files)) + self.assertEqual(sorted(files), sorted(expected_files)) diff --git a/test/test_cerbero_packages_wix.py b/test/test_cerbero_packages_wix.py index e68baec1..4b0a55ba 100644 --- a/test/test_cerbero_packages_wix.py +++ b/test/test_cerbero_packages_wix.py @@ -17,7 +17,7 @@ # Boston, MA 02111-1307, USA. import unittest -import StringIO +import io from cerbero import hacks from cerbero.build import recipe @@ -97,14 +97,14 @@ class MergeModuleTest(unittest.TestCase): def test_add_root(self): self.mergemodule._add_root() - self.assertEquals( + self.assertEqual( '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" />', etree.tostring(self.mergemodule.root)) def test_add_module(self): self.mergemodule._add_root() self.mergemodule._add_module() - self.assertEquals( + self.assertEqual( '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' '<Module Id="_gstreamer_test" Language="1033" Version="1.0" />' '</Wix>', etree.tostring(self.mergemodule.root)) @@ -113,7 +113,7 @@ class MergeModuleTest(unittest.TestCase): self.mergemodule._add_root() self.mergemodule._add_module() self.mergemodule._add_package() - self.assertEquals( + self.assertEqual( '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' '<Module Id="_gstreamer_test" Language="1033" Version="1.0">' '<Package Comments="test" Description="GStreamer Test" Id="1" ' @@ -126,7 +126,7 @@ class MergeModuleTest(unittest.TestCase): self.mergemodule._add_module() self.mergemodule._add_package() self.mergemodule._add_root_dir() - self.assertEquals( + self.assertEqual( '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' '<Module Id="_gstreamer_test" Language="1033" Version="1.0">' '<Package Comments="test" Description="GStreamer Test" Id="1" ' @@ -140,14 +140,14 @@ class MergeModuleTest(unittest.TestCase): self.mergemodule._add_module() self.mergemodule._add_package() self.mergemodule._add_root_dir() - self.assertEquals(len(self.mergemodule._dirnodes), 1) - self.assertEquals(self.mergemodule._dirnodes[''], self.mergemodule.rdir) + self.assertEqual(len(self.mergemodule._dirnodes), 1) + self.assertEqual(self.mergemodule._dirnodes[''], self.mergemodule.rdir) self.mergemodule._add_directory('lib/gstreamer-0.10') - self.assertEquals(len(self.mergemodule._dirnodes), 3) + self.assertEqual(len(self.mergemodule._dirnodes), 3) self.assertTrue('lib' in self.mergemodule._dirnodes) self.assertTrue('lib/gstreamer-0.10' in self.mergemodule._dirnodes) self.mergemodule._add_directory('bin') - self.assertEquals(len(self.mergemodule._dirnodes), 4) + self.assertEqual(len(self.mergemodule._dirnodes), 4) self.assertTrue('bin' in self.mergemodule._dirnodes) def test_add_file(self): @@ -155,14 +155,14 @@ class MergeModuleTest(unittest.TestCase): self.mergemodule._add_module() self.mergemodule._add_package() self.mergemodule._add_root_dir() - self.assertEquals(len(self.mergemodule._dirnodes), 1) - self.assertEquals(self.mergemodule._dirnodes[''], self.mergemodule.rdir) + self.assertEqual(len(self.mergemodule._dirnodes), 1) + self.assertEqual(self.mergemodule._dirnodes[''], self.mergemodule.rdir) self.mergemodule._add_file('bin/gst-inspect-0.10.exe') - self.assertEquals(len(self.mergemodule._dirnodes), 2) + self.assertEqual(len(self.mergemodule._dirnodes), 2) self.assertTrue('bin' in self.mergemodule._dirnodes) self.assertTrue('gstreamer-0.10.exe' not in self.mergemodule._dirnodes) self.mergemodule._add_file('bin/gst-launch-0.10.exe') - self.assertEquals(len(self.mergemodule._dirnodes), 2) + self.assertEqual(len(self.mergemodule._dirnodes), 2) self.assertTrue('bin' in self.mergemodule._dirnodes) self.assertTrue('gstreamer-0.10.exe' not in self.mergemodule._dirnodes) @@ -170,19 +170,19 @@ class MergeModuleTest(unittest.TestCase): self.config.platform = Platform.WINDOWS self.mergemodule._get_uuid = lambda : '1' self.mergemodule.fill() - tmp = StringIO.StringIO() + tmp = io.StringIO() self.mergemodule.write(tmp) #self._compstr(tmp.getvalue(), MERGE_MODULE) - self.assertEquals(MERGE_MODULE, tmp.getvalue()) + self.assertEqual(MERGE_MODULE, tmp.getvalue()) def _compstr(self, str1, str2): str1 = str1.split('\n') str2 = str2.split('\n') for i in range(len(str1)): if str1[i] != str2[i]: - print str1[i] - print str2[i] - print "" + print(str1[i]) + print(str2[i]) + print("") class InstallerTest(unittest.TestCase): diff --git a/test/test_cerbero_tools_osxuniversalgenerator.py b/test/test_cerbero_tools_osxuniversalgenerator.py index 4fc74637..3259238b 100644 --- a/test/test_cerbero_tools_osxuniversalgenerator.py +++ b/test/test_cerbero_tools_osxuniversalgenerator.py @@ -98,10 +98,10 @@ class OSXUniversalGeneratorTest(unittest.TestCase): for arch in [Architecture.X86, Architecture.X86_64]: res = self._get_file_type( os.path.join(self.tmp, arch, 'lib', 'libfoo.so')) - self.assertEquals(res, SHARED_LIBRARY[arch]) + self.assertEqual(res, SHARED_LIBRARY[arch]) res = self._get_file_type( os.path.join(self.tmp, arch, 'bin', 'test_app')) - self.assertEquals(res, EXECUTABLE[arch]) + self.assertEqual(res, EXECUTABLE[arch]) def testMergeDirs(self): self._compile(Architecture.X86) @@ -158,7 +158,7 @@ class OSXUniversalGeneratorTest(unittest.TestCase): self.assertTrue(os.path.exists(file1)) self.assertTrue(os.path.exists(file2)) - self.assertEquals(os.readlink(file2), file1) + self.assertEqual(os.readlink(file2), file1) def testMergePCFiles(self): for arch in [Architecture.X86, Architecture.X86_64]: @@ -171,7 +171,7 @@ class OSXUniversalGeneratorTest(unittest.TestCase): [os.path.join(self.tmp, Architecture.X86), os.path.join(self.tmp, Architecture.X86_64)]) pc_file = os.path.join(self.tmp, Architecture.UNIVERSAL, 'test.pc') - self.assertEquals(open(pc_file).readline(), + self.assertEqual(open(pc_file).readline(), os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'test')) def testMergedLibraryPaths(self): diff --git a/test/test_common.py b/test/test_common.py index c6949656..7904b753 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -51,9 +51,9 @@ class XMLMixin(): n = self.find_one(parent, tag) if attrib not in n.attrib: self.fail("Attribute %s not found in %s" % (attrib, n)) - self.assertEquals(n.attrib[attrib], value) + self.assertEqual(n.attrib[attrib], value) def check_text(self, parent, tag, value): n = self.find_one(parent, tag) - self.assertEquals(n.text, value) + self.assertEqual(n.text, value) diff --git a/tools/certdata2pem.py b/tools/certdata2pem.py index 5cc8f4cc..fa8246ba 100644 --- a/tools/certdata2pem.py +++ b/tools/certdata2pem.py @@ -70,13 +70,13 @@ for line in open('certdata.txt', 'r'): field, type = line_parts value = None else: - raise NotImplementedError, 'line_parts < 2 not supported.' + raise NotImplementedError('line_parts < 2 not supported.') if type == 'MULTILINE_OCTAL': in_multiline = True value = "" continue obj[field] = value -if len(obj.items()) > 0: +if len(list(obj.items())) > 0: objects.append(obj) # Read blacklist. @@ -95,7 +95,7 @@ for obj in objects: if obj['CKA_CLASS'] not in ('CKO_NETSCAPE_TRUST', 'CKO_NSS_TRUST'): continue if obj['CKA_LABEL'] in blacklist: - print "Certificate %s blacklisted, ignoring." % obj['CKA_LABEL'] + print("Certificate %s blacklisted, ignoring." % obj['CKA_LABEL']) elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR', 'CKT_NSS_TRUSTED_DELEGATOR'): trust[obj['CKA_LABEL']] = True @@ -104,13 +104,13 @@ for obj in objects: trust[obj['CKA_LABEL']] = True elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_UNTRUSTED', 'CKT_NSS_NOT_TRUSTED'): - print '!'*74 - print "UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s" % obj['CKA_LABEL'] - print '!'*74 + print('!'*74) + print("UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s" % obj['CKA_LABEL']) + print('!'*74) else: - print "Ignoring certificate %s. SAUTH=%s, EPROT=%s" % \ + print("Ignoring certificate %s. SAUTH=%s, EPROT=%s" % \ (obj['CKA_LABEL'], obj['CKA_TRUST_SERVER_AUTH'], - obj['CKA_TRUST_EMAIL_PROTECTION']) + obj['CKA_TRUST_EMAIL_PROTECTION'])) for obj in objects: if obj['CKA_CLASS'] == 'CKO_CERTIFICATE': diff --git a/tools/show-coverage.py b/tools/show-coverage.py index 2e89ff42..28cf4c4e 100644 --- a/tools/show-coverage.py +++ b/tools/show-coverage.py @@ -17,7 +17,7 @@ class Presentation: def show(self, maxlen=20): format = '%%-%ds %%3d %%%% (%%4d / %%4d)' % maxlen - print format % (self.name, self.percent, self.covered, self.lines) + print(format % (self.name, self.percent, self.covered, self.lines)) class Coverage: @@ -46,20 +46,19 @@ class Coverage: def show_results(self): if not hasattr(self, 'files'): - print 'No coverage data' + print('No coverage data') return if self.files: - self.maxlen = max(map(lambda f: len(self._strip_filename(f)), - self.files)) + self.maxlen = max([len(self._strip_filename(f)) for f in self.files]) else: self.maxlen = 0 - print 'Coverage report:' - print '-' * (self.maxlen + 23) + print('Coverage report:') + print('-' * (self.maxlen + 23)) for file in self.files: self.show_one(file) - print '-' * (self.maxlen + 23) + print('-' * (self.maxlen + 23)) p = Presentation('Total', self.total_lines, self.total_covered) p.show(self.maxlen) |