Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def upload_file_to_s3(file_path,
                      s3_filename,
                      content_type="text/html",
                      extra_message=None):
    """
    Uploads a file to bokeh-travis 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)
Ejemplo n.º 3
0
def upload_file_to_s3(file_path, s3_filename, content_type="text/html", extra_message=None):
    """
    Uploads a file to bokeh-travis 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)
Ejemplo n.º 4
0
 def upload_imgs(self):
     if isfile(self.img_path):
         trace("%s Uploading image to S3 to %s" % (green(">>>"), self.img_path))
         upload_file_to_s3(self.img_path, self.img_url_path, "image/png")
     if isfile(self.diff_path):
         trace("%s Uploading image to S3 to %s" % (green(">>>"), self.diff_path))
         upload_file_to_s3(self.diff_path, self.diff_url_path, "image/png")
Ejemplo n.º 5
0
def _get_screenshot(engine, url, screenshot_path, local_wait, global_wait, width, height):
    """
    wait is in milliseconds
    """
    cmd = engine + [url, screenshot_path, str(local_wait), str(global_wait), str(width), str(height)]
    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)
        proc.wait()
    except OSError as e:
        fail("Failed to run: %s" % " ".join(cmd))
        fail(str(e))
        sys.exit(1)

    if proc.returncode != 0:
        output = proc.stderr.read().decode("utf-8")
        fail(output)
        sys.exit(1)

    output = proc.stdout.read().decode("utf-8")
    return json.loads(output)
Ejemplo n.º 6
0
 def upload_imgs(self):
     if isfile(self.img_path):
         trace("%s Uploading image to S3 to %s" % (green(">>>"), self.img_path))
         upload_file_to_s3(self.img_path, self.img_url_path, "image/png")
     if isfile(self.diff_path):
         trace("%s Uploading image to S3 to %s" % (green(">>>"), self.diff_path))
         upload_file_to_s3(self.diff_path, self.diff_url_path, "image/png")
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        _store_binary(ref_path, ref)
        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = white("%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")
Ejemplo n.º 9
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        ref_dir = dirname(ref_path)
        if not exists(ref_dir):
            os.makedirs(ref_dir)

        with open(ref_path, "wb") as f:
            f.write(ref)

        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = white("%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")