diff --git a/tagcompare/capture.py b/tagcompare/capture.py index 89750e0..29b68ce 100644 --- a/tagcompare/capture.py +++ b/tagcompare/capture.py @@ -184,9 +184,12 @@ def __write_html(self, tag_html, output_path): class CaptureManager(object): MAX_REMOTE_JOBS = 6 - def __init__(self): + def __init__(self, domain=None): + self.domain = domain + if not self.domain: + self.domain = settings.DEFAULT.domain self.logger = logger.Logger(name="capture", writefile=True).get() - self.placelocal_api = placelocal.PlaceLocalApi() + self.placelocal_api = placelocal.PlaceLocalApi(domain=self.domain) def _capture_tags_for_configs(self, cids, pathbuilder, configs, diff --git a/tagcompare/image.py b/tagcompare/image.py index 6ccdf10..b731c9f 100644 --- a/tagcompare/image.py +++ b/tagcompare/image.py @@ -30,7 +30,8 @@ def generate_diff_img(file1, file2, diff_img_path): diff_img_path. """ import subprocess - subprocess.call(["compare", "-compose", "src", file1, file2, diff_img_path]) + subprocess.call( + ["compare", "-compose", "src", file1, file2, diff_img_path]) LOGGER.debug("diff image saved in build directory") return @@ -101,12 +102,7 @@ def crop(img_file, cropbox, backup=False): def normalize_img(img_file, greyscale=False): img = Image.open(img_file) - if not greyscale: - return img - - # TODO: Figure out ways to make font issues more prominent - # greyscale - return img.convert('LA') + return img def blank_compare_matrix(num_configs, width, height): @@ -129,7 +125,8 @@ def _get_color_distance(px1, px2): return math.sqrt(sum([abs(a - b) ** 2 for (a, b) in zip(px1, px2)])) -# In R8G8B8A8 space, this is white vs. black, so all distances must be at most this. +# In R8G8B8A8 space, this is white vs. black, so all distances must be at +# most this. _DIST_MAX = 2 * 256 @@ -174,4 +171,5 @@ def draw_visual_diff(canvas, img1, img2, position, cfgstring, overlay_mask): canvas.paste(normalized_distances, position, overlay_mask) # and finally label what the comparison is for. draw = ImageDraw.Draw(canvas) - draw.text(xy=(position[0] + 3, position[1] + 3), fill=(0, 0, 255), text=cfgstring) + draw.text(xy=(position[0] + 3, position[1] + 3), + fill=(0, 0, 255), text=cfgstring) diff --git a/tagcompare/logger.py b/tagcompare/logger.py index 2c9c100..04b6f8a 100644 --- a/tagcompare/logger.py +++ b/tagcompare/logger.py @@ -5,10 +5,6 @@ import time -def set_level_from_settings(): - logging.getLogger("tagcompare").setLevel(settings.DEFAULT.loglevel) - - def generate_timestamp(): return time.strftime("%Y%m%d-%H%M%S") diff --git a/tagcompare/test/test_capture.py b/tagcompare/test/test_capture.py index 219335a..89bb9bd 100644 --- a/tagcompare/test/test_capture.py +++ b/tagcompare/test/test_capture.py @@ -35,18 +35,18 @@ def test_capture_configs(): adtypes = ["iframe"] pb = output.create(build="capture_test") - cm = capture.CaptureManager() + cm = capture.CaptureManager(domain="www.placelocal.com") errors = cm._capture_tags_for_configs(cids=cids, pathbuilder=pb, configs=configs, tagsizes=adsizes, tagtypes=adtypes, capture_existing=True) - '''There should be a SEVERE error like: + '''There should be two SEVERE error like: 'http://fonts.googleapis.com/css?family=[object+Object]... Failed to load ''' assert errors - assert len(errors) == 1, "There should be one error!" + assert len(errors) == 2, "There should be two errors!" assert errors[0]['level'] == 'SEVERE' - pb.rmbuild() + assert "http://fonts.googleapis.com" in str(errors[0]['message']) def test_capture_tag():