def view_log(_execution, _job, _url, _alias): """View workflow or job execution logs.""" session = _get_session(_url, _alias) exc = Execution(session, _execution) logs = exc.job_logs(_job[0]) if _job else exc.logs() try: for line in logs: sys.stdout.write('%s\n' % (line.encode('utf-8'), )) except HTTPError: # Azkaban responds with 500 if the execution or job isn't found if _job: raise AzkabanError('Execution %s and/or job %s not found.', _execution, _job) else: raise AzkabanError('Execution %s not found.', _execution)