mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
Plugin management facility added
This commit is contained in:
parent
eb1a462721
commit
5bbb481629
2
gpoa/plugin/__init__.py
Normal file
2
gpoa/plugin/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .plugin_manager import plugin_manager
|
||||
|
19
gpoa/plugin/adp.py
Normal file
19
gpoa/plugin/adp.py
Normal file
@ -0,0 +1,19 @@
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
from util.rpm import is_rpm_installed
|
||||
from .exceptions import PluginInitError
|
||||
|
||||
class adp:
|
||||
def __init__(self):
|
||||
if not is_rpm_installed('adp'):
|
||||
raise PluginInitError('adp is not installed - plugin cannot be initialized')
|
||||
logging.info('ADP plugin initialized')
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
loggging.info('Running ADP plugin')
|
||||
subprocess.call(['/usr/sbin/adp-fetch'])
|
||||
except Exception as exc:
|
||||
logging.error('Error running ADP')
|
||||
|
7
gpoa/plugin/exceptions.py
Normal file
7
gpoa/plugin/exceptions.py
Normal file
@ -0,0 +1,7 @@
|
||||
class PluginInitError(Exception):
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return self.message
|
||||
|
20
gpoa/plugin/plugin_manager.py
Normal file
20
gpoa/plugin/plugin_manager.py
Normal file
@ -0,0 +1,20 @@
|
||||
import logging
|
||||
|
||||
from .adp import adp
|
||||
from .exceptions import PluginInitError
|
||||
|
||||
class plugin_manager:
|
||||
def __init__(self):
|
||||
self.plugins = dict()
|
||||
logging.info('Starting plugin manager')
|
||||
try:
|
||||
self.plugins['adp'] = adp()
|
||||
logging.info('ADP plugin initialized')
|
||||
except PluginInitError as exc:
|
||||
self.plugins['adp'] = None
|
||||
logging.error(exc)
|
||||
|
||||
def run(self):
|
||||
if self.plugins['adp']:
|
||||
self.plugins['adp'].run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user