diff --git a/humbug/settings.py b/humbug/settings.py index fb8d84bf64..142e3c7e57 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -577,6 +577,12 @@ if DEPLOYED: FILE_UPLOAD_MAX_MEMORY_SIZE = 0 +# We are not currently using embedly due to some performance issues, but +# we are keeping the code on master for now, behind this launch flag. +# If you turn this back on for dev, you will want it to be still False +# for running the tests, or you will need to ensure that embedly_client.is_supported() +# gets called before the tests run. +USING_EMBEDLY = False EMBEDLY_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" if DEPLOYED: diff --git a/zephyr/lib/bugdown/__init__.py b/zephyr/lib/bugdown/__init__.py index af8f249043..faf8f346f2 100644 --- a/zephyr/lib/bugdown/__init__.py +++ b/zephyr/lib/bugdown/__init__.py @@ -24,9 +24,11 @@ from zephyr.lib.bugdown import codehilite, fenced_code from zephyr.lib.bugdown.fenced_code import FENCE_RE from zephyr.lib.timeout import timeout, TimeoutExpired from zephyr.lib.cache import cache_with_key, cache_get_many, cache_set_many -from embedly import Embedly -embedly_client = Embedly(settings.EMBEDLY_KEY, timeout=2.5) + +if settings.USING_EMBEDLY: + from embedly import Embedly + embedly_client = Embedly(settings.EMBEDLY_KEY, timeout=2.5) # Format version of the bugdown rendering; stored along with rendered # messages so that we can efficiently determine what needs to be re-rendered @@ -211,14 +213,14 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): return None def do_embedly(self, root, supported_urls): - # embed.ly support disabled on prod/staging until it can be + # embed.ly support is disabled until it can be # properly debugged. # # We're not deleting the code for now, since we expect to # restore it and want to be able to update it along with # future refactorings rather than keeping it as a separate # branch. - if settings.DEPLOYED: + if not settings.USING_EMBEDLY: return # We want this to be able to easily reverse the hashing later @@ -311,9 +313,10 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): div.set("class", "inline-preview-twitter") div.insert(0, twitter_data) continue - if embedly_client.is_supported(url): - embedly_urls.append(url) - continue + if settings.USING_EMBEDLY: + if embedly_client.is_supported(url): + embedly_urls.append(url) + continue # NOTE: The youtube code below is inactive at least on # staging because embedy.ly is currently handling those youtube = self.youtube_image(url) @@ -321,7 +324,8 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): add_a(root, youtube, url) continue - self.do_embedly(root, embedly_urls) + if settings.USING_EMBEDLY: + self.do_embedly(root, embedly_urls) class Gravatar(markdown.inlinepatterns.Pattern): def handleMatch(self, match): diff --git a/zephyr/tests.py b/zephyr/tests.py index e841fb52d7..c32696f1ec 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -2209,12 +2209,14 @@ xxxxxxx
\nxxxxxxx xxxxx xxxx xxxxx:
\nxxxxxx: xxx
self.assertEqual(converted, '
Google logo today: https://www.google.com/images/srpr/logo4w.png
\nKinda boringGoogle logo today: https://www.google.com/images/srpr/logo4w.png
\nKinda boring
Check out the debate: http://www.youtube.com/watch?v=hx1mjT73xYE
\n') + if settings.USING_EMBEDLY: + self.assertEqual(converted, 'Check out the debate: http://www.youtube.com/watch?v=hx1mjT73xYE
\n') + else: + self.assertEqual(converted, 'Check out the debate: http://www.youtube.com/watch?v=hx1mjT73xYE
\n') def test_inline_dropbox(self): msg = 'Look at how hilarious our old office was: https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG' @@ -2700,7 +2702,6 @@ class BeanstalkHookTests(AuthedTestCase): * [e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df): add some stuff """) - @slow(1.3, 'talks to beanstalk') def test_git_multiple(self): msg = self.send_beanstalk_message('git_multiple') self.assertEqual(msg.subject, "work-test")