summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ferguson <ferguson.david@gmail.com>2013-06-05 11:21:30 -0400
committerDavid Ferguson <ferguson.david@gmail.com>2013-06-05 11:25:50 -0400
commitaf7aa23ce01fc8e1af0ac5f66bd575f3e5f8f32c (patch)
tree04114c80d8b439ca31db13d55b9773a8a2959ea8
parent29531b25e5d597178f749770fd70928aba5f9928 (diff)
downloadbuild-af7aa23ce01fc8e1af0ac5f66bd575f3e5f8f32c.zip
build-af7aa23ce01fc8e1af0ac5f66bd575f3e5f8f32c.tar.gz
build-af7aa23ce01fc8e1af0ac5f66bd575f3e5f8f32c.tar.bz2
repopick: handle additional error cases around subprocesses
* gracefully error if the project path cannot be found * poll() was not a reliable determination of EOF on my Darwin-Python 2.7 system. Change-Id: I203c2a75820f8acc079a5c9751d1c04daf6f3a16
-rwxr-xr-xtools/repopick.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/repopick.py b/tools/repopick.py
index 3dd580b..039f122 100755
--- a/tools/repopick.py
+++ b/tools/repopick.py
@@ -129,16 +129,15 @@ if args.abandon_first:
plist = subprocess.Popen([repo_bin,"info"], stdout=subprocess.PIPE)
needs_abandon = False
while(True):
- retcode = plist.poll()
pline = plist.stdout.readline().rstrip()
+ if not pline:
+ break
matchObj = re.match(r'Local Branches.*\[(.*)\]', pline.decode())
if matchObj:
local_branches = re.split('\s*,\s*', matchObj.group(1))
if any(args.start_branch[0] in s for s in local_branches):
needs_abandon = True
break
- if(retcode is not None):
- break
if needs_abandon:
# Perform the abandon only if the branch already exists
@@ -191,14 +190,16 @@ for change in args.change_number:
# - convert the project name to a project path
plist = subprocess.Popen([repo_bin,"list"], stdout=subprocess.PIPE)
while(True):
- retcode = plist.poll()
pline = plist.stdout.readline().rstrip()
+ if not pline:
+ break
ppaths = re.split('\s*:\s*', pline.decode())
if ppaths[1] == project_name:
project_path = ppaths[0]
break
- if(retcode is not None):
- break
+ if 'project_path' not in locals():
+ sys.stderr.write('ERROR: Could not determine the project path for project %s\n' % project_name)
+ sys.exit(1)
# Check that the project path exists
if not os.path.isdir(project_path):