summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-24 14:39:14 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-25 14:39:06 +0900
commitf33929d014c21eaabb5471a70abf698af7742b8c (patch)
tree46a639f789df27677bc66eecf2d4b76fc21f35ab /project.py
parent3010e5ba646f938a856fc286439a3df34ed9a53f (diff)
downloadgit-repo-f33929d014c21eaabb5471a70abf698af7742b8c.tar.gz
project.py: Consistently use the _error method to print error messages
Use the _error method instead of directly calling `print`. Also add a new _warn convenience method. Change-Id: Ia332c14ef8d9d1fe2df128dbf36b5521802ccdf1
Diffstat (limited to 'project.py')
-rw-r--r--project.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/project.py b/project.py
index 24cac8bd..4f2b203a 100644
--- a/project.py
+++ b/project.py
@@ -63,6 +63,10 @@ def _error(fmt, *args):
63 msg = fmt % args 63 msg = fmt % args
64 print('error: %s' % msg, file=sys.stderr) 64 print('error: %s' % msg, file=sys.stderr)
65 65
66def _warn(fmt, *args):
67 msg = fmt % args
68 print('warn: %s' % msg, file=sys.stderr)
69
66def not_rev(r): 70def not_rev(r):
67 return '^' + r 71 return '^' + r
68 72
@@ -1092,8 +1096,7 @@ class Project(object):
1092 tar.extractall(path=path) 1096 tar.extractall(path=path)
1093 return True 1097 return True
1094 except (IOError, tarfile.TarError) as e: 1098 except (IOError, tarfile.TarError) as e:
1095 print("error: Cannot extract archive %s: " 1099 _error("Cannot extract archive %s: %s", tarpath, str(e))
1096 "%s" % (tarpath, str(e)), file=sys.stderr)
1097 return False 1100 return False
1098 1101
1099 def Sync_NetworkHalf(self, 1102 def Sync_NetworkHalf(self,
@@ -1110,8 +1113,7 @@ class Project(object):
1110 """ 1113 """
1111 if archive and not isinstance(self, MetaProject): 1114 if archive and not isinstance(self, MetaProject):
1112 if self.remote.url.startswith(('http://', 'https://')): 1115 if self.remote.url.startswith(('http://', 'https://')):
1113 print("error: %s: Cannot fetch archives from http/https " 1116 _error("%s: Cannot fetch archives from http/https remotes.", self.name)
1114 "remotes." % self.name, file=sys.stderr)
1115 return False 1117 return False
1116 1118
1117 name = self.relpath.replace('\\', '/') 1119 name = self.relpath.replace('\\', '/')
@@ -1122,7 +1124,7 @@ class Project(object):
1122 try: 1124 try:
1123 self._FetchArchive(tarpath, cwd=topdir) 1125 self._FetchArchive(tarpath, cwd=topdir)
1124 except GitError as e: 1126 except GitError as e:
1125 print('error: %s' % str(e), file=sys.stderr) 1127 _error('%s', e)
1126 return False 1128 return False
1127 1129
1128 # From now on, we only need absolute tarpath 1130 # From now on, we only need absolute tarpath
@@ -1133,8 +1135,7 @@ class Project(object):
1133 try: 1135 try:
1134 os.remove(tarpath) 1136 os.remove(tarpath)
1135 except OSError as e: 1137 except OSError as e:
1136 print("warn: Cannot remove archive %s: " 1138 _warn("Cannot remove archive %s: %s", tarpath, str(e))
1137 "%s" % (tarpath, str(e)), file=sys.stderr)
1138 self._CopyAndLinkFiles() 1139 self._CopyAndLinkFiles()
1139 return True 1140 return True
1140 if is_new is None: 1141 if is_new is None: