1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

Merge pull request #10 from JaviMerino/notify2

Use notify2 as it's available in pypi
This commit is contained in:
setrofim 2015-04-16 13:13:53 +01:00
commit a26a50941b
2 changed files with 7 additions and 6 deletions

View File

@ -78,6 +78,7 @@ params = dict(
'other': ['jinja2', 'pandas>=0.13.1'], 'other': ['jinja2', 'pandas>=0.13.1'],
'test': ['nose'], 'test': ['nose'],
'mongodb': ['pymongo'], 'mongodb': ['pymongo'],
'notify': ['notify2'],
'doc': ['sphinx'], 'doc': ['sphinx'],
}, },
# https://pypi.python.org/pypi?%3Aaction=list_classifiers # https://pypi.python.org/pypi?%3Aaction=list_classifiers

View File

@ -21,9 +21,9 @@ from wlauto.core.result import IterationResult
from wlauto.exceptions import ResultProcessorError from wlauto.exceptions import ResultProcessorError
try: try:
import pynotify import notify2
except ImportError: except ImportError:
pynotify = None notify2 = None
class NotifyProcessor(ResultProcessor): class NotifyProcessor(ResultProcessor):
@ -41,10 +41,10 @@ class NotifyProcessor(ResultProcessor):
if sys.platform != 'linux2': if sys.platform != 'linux2':
raise ResultProcessorError('Notifications are only supported in linux') raise ResultProcessorError('Notifications are only supported in linux')
if not pynotify: if not notify2:
raise ResultProcessorError('pynotify not installed. Please install the python-notify package') raise ResultProcessorError('notify2 not installed. Please install the notify2 package')
pynotify.init("Workload Automation") notify2.init("Workload Automation")
def process_run_result(self, result, context): def process_run_result(self, result, context):
num_iterations = sum(context.job_iteration_counts.values()) num_iterations = sum(context.job_iteration_counts.values())
@ -61,7 +61,7 @@ class NotifyProcessor(ResultProcessor):
summary = 'Workload Automation run finised' summary = 'Workload Automation run finised'
body = 'Ran a total of {} iterations: '.format(num_iterations) body = 'Ran a total of {} iterations: '.format(num_iterations)
body += ', '.join(score_board) body += ', '.join(score_board)
notification = pynotify.Notification(summary, body) notification = notify2.Notification(summary, body)
if not notification.show(): if not notification.show():
self.logger.warning('Notification failed to show') self.logger.warning('Notification failed to show')