Skip to content

Commit

Permalink
initial stab at *Context failure handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaite committed Apr 10, 2010
1 parent a2634e6 commit dbd1c32
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions client/pony_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}
pb_servers['default'] = pb_servers['pb-dev']

error_state = False
###

DEBUG_LEVEL = 5
Expand Down Expand Up @@ -239,6 +240,7 @@ def __init__(self, always_cleanup=True, dependencies=[], optional=[],

def initialize(self):
Context.initialize(self)
global error_state
log_info('changing to temp directory:', self.tempdir)

self.cwd = os.getcwd()
Expand All @@ -249,7 +251,6 @@ def initialize(self):

(ret, out, err) = _run_command([self.easy_install, '-U', 'pip'])
if ret != 0:
VirtualenvContext.finish(self)
raise Exception("error in installing pip: %s, %s" % (out, err))

for dep in self.dependencies:
Expand All @@ -258,7 +259,10 @@ def initialize(self):
dep])

if ret != 0:
raise Exception("pip cannot install req dependency: %s" % dep)
error_state = True
print 'about to break'
log_critical('pip could not isntall req dependency: %s' % dep)
break

for dep in self.optional:
log_info("installing optional dependency:", dep)
Expand Down Expand Up @@ -750,9 +754,20 @@ def _upload_file(server_url, fileobj, auth_key):

def do(name, commands, context=None, arch=None, stop_if_failure=True):
reslist = []

if context:
context.initialize()
print 'error_state:',error_state
if error_state:
context.finish()
success = False
arch = get_arch()
client_info = dict(package=name, arch=arch, success=success)
print 'client_info:',client_info
context.update_client_info(client_info)
files_to_upload = None
return (client_info, reslist, files_to_upload)


for c in commands:
log_debug('running:', str(c))
Expand All @@ -763,7 +778,7 @@ def do(name, commands, context=None, arch=None, stop_if_failure=True):
context.end_command(c)

reslist.append(c.get_results())

if stop_if_failure and not c.success():
break

Expand Down Expand Up @@ -867,7 +882,7 @@ def parse_cmdline(argv=[]):
action='store', default=[],
help='comma-delimited list of tags to be applied')
cmdline.add_option('-l', '--log-level', dest='log_level',
action'store', default='WARNING_LEVEL',
action='store', default='WARNING_LEVEL',
help='Change the amount of output you get during build process.')

if not argv:
Expand Down

0 comments on commit dbd1c32

Please sign in to comment.