[jhbuild/wip/sam/python3: 4/4] Fix some obvious issues



commit b670d867425133a7a322e8c3ed50d43ad1f38634
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Wed Jan 27 12:48:28 2016 +0100

    Fix some obvious issues

 jhbuild/utils/sysid.py             |    6 +++---
 jhbuild/utils/systeminstall.py     |    8 ++++----
 jhbuild/versioncontrol/__init__.py |    3 ++-
 jhbuild/versioncontrol/git.py      |    4 +++-
 4 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/jhbuild/utils/sysid.py b/jhbuild/utils/sysid.py
index 9146942..3ef2605 100644
--- a/jhbuild/utils/sysid.py
+++ b/jhbuild/utils/sysid.py
@@ -83,7 +83,7 @@ def get_macos_info():
     global sys_id
 
     try:
-        ver = subprocess.check_output('sw_vers -productVersion')
+        ver = subprocess.check_output('sw_vers -productVersion').decode('unicode-escape')
 
         sys_name = 'Mac OS X ' + ver
         sys_id = 'macos-' + ver
@@ -98,7 +98,7 @@ def get_freebsd_info():
     global sys_id
 
     try:
-        ver = subprocess.check_output('freebsd-version').strip()
+        ver = subprocess.check_output('freebsd-version').strip().decode('unicode-escape')
 
         sys_name = 'FreeBSD ' + ver
         return True
@@ -106,7 +106,7 @@ def get_freebsd_info():
         pass
 
     try:
-        ver = subprocess.check_output(['uname', '-r']).strip()
+        ver = subprocess.check_output(['uname', '-r']).strip().decode('unicode-escape')
 
         sys_name = 'FreeBSD ' + ver
         return True
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 9a1f248..6530948 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -37,14 +37,14 @@ def get_installed_pkgconfigs(config):
         stdout = proc.communicate()[0]
         proc.wait()
         pkgs = []
-        for line in StringIO(stdout):
+        for line in StringIO(stdout.decode('unicode-escape')):
             pkg, rest = line.split(None, 1)
             pkgs.append(pkg)
 
         # see if we can get the versions "the easy way"
         try:
             stdout = subprocess.check_output(['pkg-config', '--modversion'] + pkgs)
-            versions = stdout.splitlines()
+            versions = stdout.decode('unicode-escape').splitlines()
             if len(versions) == len(pkgs):
                 return dict(list(zip(pkgs, versions)))
         except OSError:
@@ -59,7 +59,7 @@ def get_installed_pkgconfigs(config):
             proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
             stdout = proc.communicate()[0]
             proc.wait()
-            pkgversions[pkg] = stdout.strip()
+            pkgversions[pkg] = stdout.decode('unicode-escape').strip()
     except OSError: # pkg-config not installed
         pass
     return pkgversions
@@ -378,7 +378,7 @@ class PacmanSystemInstall(SystemInstall):
             try:
                 result = subprocess.check_output(['pkgfile', '--raw', filename])
                 if result:
-                    package_names.add(result.split('\n')[0])
+                    package_names.add(result.decode('unicode-escape').split('\n')[0])
             except subprocess.CalledProcessError:
                 logging.warning(_('Provider for "%s" was not found, ignoring' %(name if name else filename)))
 
diff --git a/jhbuild/versioncontrol/__init__.py b/jhbuild/versioncontrol/__init__.py
index 2d9b600..be198a0 100644
--- a/jhbuild/versioncontrol/__init__.py
+++ b/jhbuild/versioncontrol/__init__.py
@@ -29,6 +29,7 @@ __metaclass__ = type
 from jhbuild.errors import FatalError, BuildStateError
 import importlib
 import os
+import traceback
 import warnings
 
 class Repository:
@@ -197,7 +198,7 @@ def get_repo_type(name):
             importlib.import_module('jhbuild.versioncontrol.%s' % name)
         except ImportError as e:
             warnings.warn("Failed to import versioncontrol.%s: %s" %
-                          (name, e))
+                          (name, traceback.format_exc()))
             pass
     if name not in _repo_types:
         raise FatalError(_('unknown repository type %s') % name)
diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index bf1b25f..628c2dd 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -30,10 +30,11 @@ import urllib.request, urllib.parse, urllib.error
 import sys
 import logging
 
+import jhbuild.main
+
 from jhbuild.errors import FatalError, CommandError
 from jhbuild.utils.cmds import get_output, check_version
 from jhbuild.versioncontrol import Repository, Branch, register_repo_type
-import jhbuild.versioncontrol.svn
 from jhbuild.commands.sanitycheck import inpath
 from jhbuild.utils.sxml import sxml
 
@@ -576,6 +577,7 @@ class GitSvnBranch(GitBranch):
 
         # FIXME (add self.revision support)
         try:
+            import jhbuild.versioncontrol.svn
             last_revision = jhbuild.versioncontrol.svn.get_info (self.module)['last changed rev']
             if not self.revision:
                 cmd.extend(['-r', last_revision])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]