-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_plugins.py
More file actions
45 lines (32 loc) · 1.48 KB
/
example_plugins.py
File metadata and controls
45 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Example ox_herd plugins used by our app
"""
import requests
# Import base class so we can create plugins
from ox_herd.core.plugins import base
class CheckWeb(base.OxPlugTask):
"""Class to check on a web site.
This is meanly meant to serve as an example of a minimal plugin.
All we do is implement the main_call method.
"""
@classmethod
def main_call(cls, ox_herd_task):
"""Main method to check if web site is accesible.
:arg ox_herd_task: Instance of a CheckWeb task perhaps containing
additional data (e.g., ox_herd_task.name). If your
main_call does not need arguments, you can basically
just ignore ox_herd_task. If you do want to be able
to pass in arguments, see a more detailed discussion
of how to get arguments from the user and configure
a task in the full plugin documentation.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
:returns: Dictionary with 'return_value' and 'json_blob' as
required for OxPluginComponent.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
PURPOSE: Check if website is live.
"""
url = 'http://github.com'
result = requests.get(url)
return {
'return_value': 'Status=%s for checking url %s' % (
url, result.status_code)
}