# Path: mirror/pluginbase.py
# class PluginBase(Component):
# 
#     def __init__(self, name):
#         super(PluginBase, self).__init__(name)
#         self.name = name
#         log.debug("Plugin %s initialized...", self.name)
# 
#     def enable(self):
#         raise NotImplementedError("Need to define an enable method!")
# 
#     def disable(self):
#         raise NotImplementedError("Need to define a disable method!")


import os
import time
import json
import logging
import mirror.component as component
from mirror.pluginbase import PluginBase
from collections import OrderedDict as odict
                21:  "Some error returned by waitpid()",
                22:  "Error allocating core memory buffers",
                23:  "Partial transfer due to error",
                24:  "Partial transfer due to vanished source files",
                25:  "The --max-delete limit stopped deletions",
                30:  "Timeout in data send/receive",
                35:  "Timeout waiting for daemon connection",
               }

class Plugin(PluginBase):

    DEFAULT_STATUS_FILE = "/home/mirror/status/task_status.json"

    STATUS_INITIAL  = 0
    STATUS_RUNNING  = 1
    STATUS_FINISHED = 2

    DATE_FORMAT = "%Y-%m-%d %H:%M:%S"

    def enable(self):
        plugin_manager = component.get("PluginManager")
        config = plugin_manager.config

        try:
            self.status_file = config[_plugin_name]["status_file"]
        except:
            self.status_file = Plugin.DEFAULT_STATUS_FILE
            log.info(("Didn't set `status_file` in plugin.ini in `%s` section"
                      ", use default one: %s"), _plugin_name, self.status_file)


# Path: mirror/pluginbase.py
# class PluginBase(Component):
# 
#     def __init__(self, name):
#         super(PluginBase, self).__init__(name)
#         self.name = name
#         log.debug("Plugin %s initialized...", self.name)
# 
#     def enable(self):
#         raise NotImplementedError("Need to define an enable method!")
# 
#     def disable(self):
#         raise NotImplementedError("Need to define a disable method!")


# Path: mirror/plugins/TaskStatus/mirror/plugins/taskstatus/plugin.py
import os
import time
import json
import logging
import mirror.component as component
from mirror.pluginbase import PluginBase
from collections import OrderedDict as odict

                21:  "Some error returned by waitpid()",
                22:  "Error allocating core memory buffers",
                23:  "Partial transfer due to error",
                24:  "Partial transfer due to vanished source files",
                25:  "The --max-delete limit stopped deletions",
                30:  "Timeout in data send/receive",
                35:  "Timeout waiting for daemon connection",
               }

class Plugin(PluginBase):

    DEFAULT_STATUS_FILE = "/home/mirror/status/task_status.json"

    STATUS_INITIAL  = 0
    STATUS_RUNNING  = 1
    STATUS_FINISHED = 2

    DATE_FORMAT = "%Y-%m-%d %H:%M:%S"

    def enable(self):
        plugin_manager = component.get("PluginManager")
        config = plugin_manager.config

        try:
            self.status_file = config[_plugin_name]["status_file"]
        except:
            self.status_file = Plugin.DEFAULT_STATUS_FILE
            log.info(("Didn't set `status_file` in plugin.ini in `%s` section"
                      ", use default one: %s"), _plugin_name, self.status_file)


        self.enabled = True