Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<webhook name="Plugin 1" type="topbar"> | ||
<params></params> | ||
<template></template> | ||
</webhook> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<webhook name="Plugin 2" type="mainview"> | ||
<params></params> | ||
<template></template> | ||
</webhook> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: Plugin 1 | ||
type: topbar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: Plugin 2 | ||
type: mainview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
API Controller providing Galaxy Webhooks | ||
""" | ||
|
||
import logging | ||
|
||
from galaxy.web.base.controller import BaseAPIController | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class WebhooksController(BaseAPIController): | ||
def __init__(self, app): | ||
super(WebhooksController, self).__init__(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
""" | ||
This module manages loading of Galaxy webhooks. | ||
""" | ||
|
||
import os | ||
import yaml | ||
import logging | ||
|
||
from galaxy.util import galaxy_root_path | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class WebhooksRegistry(object): | ||
webhooks = {} | ||
|
||
def __init__(self, webhooks_directories): | ||
path = os.path.join(galaxy_root_path, webhooks_directories) | ||
self.webhooks_directories = \ | ||
[os.path.join(path, name) | ||
for name in os.listdir(webhooks_directories)] | ||
self.load_webhooks() | ||
|
||
def load_webhooks(self): | ||
for directory in self.webhooks_directories: | ||
config_dir = os.path.join(directory, 'config') | ||
|
||
if not os.path.exists(config_dir): | ||
log.warning('directory not found: %s', config_dir) | ||
continue | ||
|
||
config_file = [conf for conf in os.listdir(config_dir) | ||
if conf.endswith('.yml') or | ||
conf.endswith('.yaml')][0] | ||
|
||
if config_file: | ||
self.load_webhook_from_config( | ||
os.path.join(config_dir, config_file)) | ||
|
||
def load_webhook_from_config(self, config_file): | ||
try: | ||
with open(config_file) as f: | ||
config = yaml.load(f) | ||
if config['type'] not in self.webhooks.keys(): | ||
self.webhooks[config['type']] = [] | ||
self.webhooks[config['type']].append({ | ||
'name': config['name'] | ||
}) | ||
except Exception as e: | ||
log.exception(e) |