(self)
| 31 | |
| 32 | class Plugin(object): |
| 33 | def __init__(self): |
| 34 | self.systemPlugin = False |
| 35 | |
| 36 | self._logger = logging.getLogger('Plugin::%s' % self.__class__.__name__) |
| 37 | self._definition = None |
| 38 | self._settings = settings() |
| 39 | self._pluginEventListeners = {} |
| 40 | self._profileManager = printerProfileManager() |
| 41 | |
| 42 | #Read it's definition file - plugin.yaml - |
| 43 | pluginPath = os.path.dirname(sys.modules[self.__module__].__file__) |
| 44 | definitionFile = os.path.join(pluginPath, 'plugin.yaml') |
| 45 | if os.path.exists(definitionFile): |
| 46 | try: |
| 47 | with open(definitionFile, "r") as f: |
| 48 | self._definition = yaml.safe_load(f) |
| 49 | |
| 50 | except Exception as e: |
| 51 | raise e #Raise parse exception here |
| 52 | |
| 53 | if all(key in self._definition for key in REQUIRED_PLUGIN_KEYS): |
| 54 | min_api_version = int(self._definition['min_api_version']) |
| 55 | |
| 56 | if PLUGIN_API_VERSION >= min_api_version: |
| 57 | self.initialize() |
| 58 | else: |
| 59 | raise Exception("AstroBox API version [%d] is lower than minimum required by %s [%d]" % (PLUGIN_API_VERSION, self._definition['id'], min_api_version)) |
| 60 | |
| 61 | else: |
| 62 | raise Exception("Invalid plugin definition found in %s" % definitionFile) |
| 63 | |
| 64 | else: |
| 65 | raise Exception("No plugin definition file exists in %s" % pluginPath) |
| 66 | |
| 67 | |
| 68 | @property |
nothing calls this directly
no test coverage detected