From 06f65d0c35271dd73f0f44d8b591e6bd50708f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Thu, 9 Jun 2016 15:43:41 +0300 Subject: [PATCH] sample plugin formatted --- opt/ahenk/plugins/plugin1/command1.py | 24 --------------------- opt/ahenk/plugins/plugin1/command2.py | 0 opt/ahenk/plugins/plugin1/main.py | 8 ------- opt/ahenk/plugins/plugin1/policy.py | 9 -------- opt/ahenk/plugins/plugin1/safe.py | 7 ------ opt/ahenk/plugins/plugin2/main.py | 6 ------ opt/ahenk/plugins/sample/main.py | 5 +++++ opt/ahenk/plugins/sample/policy.py | 23 ++++++++++++++++++++ opt/ahenk/plugins/sample/safe.py | 22 +++++++++++++++++++ opt/ahenk/plugins/sample/task_command_id.py | 23 ++++++++++++++++++++ 10 files changed, 73 insertions(+), 54 deletions(-) delete mode 100644 opt/ahenk/plugins/plugin1/command1.py delete mode 100644 opt/ahenk/plugins/plugin1/command2.py delete mode 100644 opt/ahenk/plugins/plugin1/main.py delete mode 100644 opt/ahenk/plugins/plugin1/policy.py delete mode 100644 opt/ahenk/plugins/plugin1/safe.py delete mode 100644 opt/ahenk/plugins/plugin2/main.py create mode 100644 opt/ahenk/plugins/sample/main.py create mode 100644 opt/ahenk/plugins/sample/policy.py create mode 100644 opt/ahenk/plugins/sample/safe.py create mode 100644 opt/ahenk/plugins/sample/task_command_id.py diff --git a/opt/ahenk/plugins/plugin1/command1.py b/opt/ahenk/plugins/plugin1/command1.py deleted file mode 100644 index 0d6e479..0000000 --- a/opt/ahenk/plugins/plugin1/command1.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Author: İsmail BAŞARAN - -from base.plugin.AbstractCommand import AbstractCommand - -class MySamplePlugin(AbstractCommand): - """docstring for MySamplePlugin""" - def __init__(self, task): - super(MySamplePlugin, self).__init__() - self.task = task - - def handle_task(self): - print("This is command 1 ") - print("parameter map="+self.task.parameter_map) - - -def handle_task(task,context): - # Do what ever you want here - # You can create command class but it is not necessary - # You can use directly this method. - context.put('my_data_name','my data') - myPlugin = MySamplePlugin(task) - myPlugin.handle_task() diff --git a/opt/ahenk/plugins/plugin1/command2.py b/opt/ahenk/plugins/plugin1/command2.py deleted file mode 100644 index e69de29..0000000 diff --git a/opt/ahenk/plugins/plugin1/main.py b/opt/ahenk/plugins/plugin1/main.py deleted file mode 100644 index 59d591a..0000000 --- a/opt/ahenk/plugins/plugin1/main.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Author: İsmail BAŞARAN - - - -def info(): - return None diff --git a/opt/ahenk/plugins/plugin1/policy.py b/opt/ahenk/plugins/plugin1/policy.py deleted file mode 100644 index b7a9bf8..0000000 --- a/opt/ahenk/plugins/plugin1/policy.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Author: İsmail BAŞARAN - - -def handle_policy(profile_data,context): - context.put('data','dataa') - context.put('content_type','type') - print("This is policy file - plugin 1") diff --git a/opt/ahenk/plugins/plugin1/safe.py b/opt/ahenk/plugins/plugin1/safe.py deleted file mode 100644 index 062a10c..0000000 --- a/opt/ahenk/plugins/plugin1/safe.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Author: İsmail BAŞARAN - - -def handle_safe_mode(username,context): - pass \ No newline at end of file diff --git a/opt/ahenk/plugins/plugin2/main.py b/opt/ahenk/plugins/plugin2/main.py deleted file mode 100644 index e036c25..0000000 --- a/opt/ahenk/plugins/plugin2/main.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Author: İsmail BAŞARAN - -def run(val): - print("oo yeah plugin2 " + str(val)) diff --git a/opt/ahenk/plugins/sample/main.py b/opt/ahenk/plugins/sample/main.py new file mode 100644 index 0000000..de4527a --- /dev/null +++ b/opt/ahenk/plugins/sample/main.py @@ -0,0 +1,5 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +def info(): + return None diff --git a/opt/ahenk/plugins/sample/policy.py b/opt/ahenk/plugins/sample/policy.py new file mode 100644 index 0000000..56c91da --- /dev/null +++ b/opt/ahenk/plugins/sample/policy.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from base.plugin.abstract_plugin import AbstractPlugin + + +class Sample(AbstractPlugin): + def __init__(self, profile_data, context): + super(Sample, self).__init__() + self.profile_data = profile_data + self.context = context + self.logger = self.get_logger() + + def handle_policy(self): + # TODO Do what do you want to do! + # TODO Don't Forget returning response with + pass + + +def handle_policy(profile_data, context): + print('Sample Plugin Policy') + sample = Sample(profile_data, context) + sample.handle_policy() diff --git a/opt/ahenk/plugins/sample/safe.py b/opt/ahenk/plugins/sample/safe.py new file mode 100644 index 0000000..2d4cad5 --- /dev/null +++ b/opt/ahenk/plugins/sample/safe.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from base.plugin.abstract_plugin import AbstractPlugin + + +class Sample(AbstractPlugin): + def __init__(self, username, context): + super(Sample, self).__init__() + self.username = username + self.context = context + self.logger = self.get_logger() + + def handle_safe_mode(self): + # TODO Do what do you want to do! + pass + + +def handle_safe_mode(username, context): + print('Sample Plugin Safe') + sample = Sample(username, context) + sample.handle_safe_mode() diff --git a/opt/ahenk/plugins/sample/task_command_id.py b/opt/ahenk/plugins/sample/task_command_id.py new file mode 100644 index 0000000..50651f7 --- /dev/null +++ b/opt/ahenk/plugins/sample/task_command_id.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from base.plugin.abstract_plugin import AbstractPlugin + + +class Sample(AbstractPlugin): + def __init__(self, task, context): + super(Sample, self).__init__() + self.task = task + self.context = context + self.logger = self.get_logger() + + def handle_task(self): + # TODO Do what do you want to do! + # TODO Don't Forget returning response with + pass + + +def handle_task(task, context): + print('Sample Plugin Task') + sample = Sample(task, context) + sample.handle_task()