Here are the examples of the python api bokeh.util.terminal.fail taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
View Source File : s3.py
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
def connect_to_s3():
''' Return the connection object or None if connection failed.
'''
try:
# calling_format due to https://github.com/boto/boto/issues/2836
from boto.s3.connection import OrdinaryCallingFormat
return boto.connect_s3(calling_format=OrdinaryCallingFormat())
except NoAuthHandlerFound:
fail("Upload was requested but could not connect to S3.")
fail("This is expected if you are an external contributor submitting a PR to Bokeh.")
fail("This could also happen if S3 credentials are not available on the machine where this test is running.")
return None
def upload_file_to_s3_by_job_id(file_path, content_type="text/html", extra_message=None):
0
View Source File : s3.py
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
def upload_file_to_s3(file_path, s3_filename, content_type="text/html", extra_message=None):
''' Upload a file to the ci.bokeh.org s3 bucket
'''
conn = connect_to_s3()
upload = conn is not None
try:
with open(file_path, "rb") as f:
contents = f.read()
except OSError:
fail("Upload was requested but file %s was not available." % file_path)
upload = False
if __version__.endswith("-dirty"):
fail("Uploads are not permitted when working directory is dirty.")
fail("Make sure that __version__ doesn't contain -dirty suffix.")
upload = False
if upload:
bucket = conn.get_bucket(S3_BUCKET)
key = S3Key(bucket, s3_filename)
key.set_metadata("Content-Type", content_type)
key.set_contents_from_string(contents, policy="public-read")
url = join(S3_URL, s3_filename)
if extra_message is not None:
ok("%s | Access upload at: %s" % (extra_message, url))
else:
trace("Access upload at: %s" % url)
#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Private API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
logging.getLogger('boto').setLevel(logging.INFO)
0
View Source File : screenshot.py
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
License : BSD 3-Clause "New" or "Revised" License
Project Creator : holzschu
def _run_in_browser(engine, url, local_wait=None, global_wait=None):
"""
wait is in milliseconds
"""
cmd = engine + [url]
if local_wait is not None:
cmd += [str(local_wait)]
if global_wait is not None:
cmd += [str(global_wait)]
trace("Running command: %s" % " ".join(cmd))
env = os.environ.copy()
env["NODE_PATH"] = join(TOP_PATH, 'bokehjs', 'node_modules')
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
except OSError as e:
fail("Failed to run: %s" % " ".join(cmd))
fail(str(e))
sys.exit(1)
(stdout, stderr) = proc.communicate()
if proc.returncode != 0:
output = stderr.decode("utf-8")
fail(output)
sys.exit(1)
output = stdout.decode("utf-8")
return json.loads(output)
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------