Skip to content

Commit

Permalink
fix failing Travis tests #2 (TOX_ENV=py27-lint) and #6 (TOX_ENV=py27-…
Browse files Browse the repository at this point in the history
…lint-imports)
  • Loading branch information
anatskiy committed Oct 14, 2016
1 parent 4bbab51 commit ebaffa2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions config/plugins/webhooks/demo/phdcomics/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
log = logging.getLogger(__name__)


def get_latest_id():
url = 'http://phdcomics.com/gradfeed.php'
content = urllib.urlopen(url).read()
soap = BeautifulSoup(content, 'html.parser')
pattern = '(?:http://www\.phdcomics\.com/comics\.php\?f=)(\d+)'
return max([
int(re.search(pattern, link.text).group(1))
for link in soap.find_all('link', text=re.compile(pattern))
])


def main(trans, webhook):
error = ''
data = {}
Expand All @@ -29,8 +18,16 @@ def main(trans, webhook):
log.exception(e)
return {}

# Get latest id
if 'latest_id' not in webhook.config.keys():
webhook.config['latest_id'] = get_latest_id()
url = 'http://phdcomics.com/gradfeed.php'
content = urllib.urlopen(url).read()
soap = BeautifulSoup(content, 'html.parser')
pattern = '(?:http://www\.phdcomics\.com/comics\.php\?f=)(\d+)'
webhook.config['latest_id'] = max([
int(re.search(pattern, link.text).group(1))
for link in soap.find_all('link', text=re.compile(pattern))
])

random_id = random.randint(1, webhook.config['latest_id'])
url = 'http://www.phdcomics.com/comics/archive.php?comicid=%d' % \
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/api/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def get_random(self, trans, webhook_type, **kwd):
webhooks = [
webhook
for webhook in self.app.webhooks_registry.webhooks
if webhook_type in webhook.type \
and webhook.activate == True
if webhook_type in webhook.type and
webhook.activate is True
]
return random.choice(webhooks).to_dict() if webhooks else {}

Expand Down

0 comments on commit ebaffa2

Please sign in to comment.