My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
ReportingTemplate  
A basic reporting template
Phase-Implementation
Updated Oct 6, 2014 by Robby@Zeitfuchs.org

All reporting-plugins are and should be placed inside the folder at /reporting/.

Every plugin should also have a dedicated section in the file config/reporting.conf: for this example if you create a module module/reporting/mymodul.py you will have to append the following section to config/processing.conf:

[hpfriends]
enabled = no
channel = ragpicker.reports
host = hpfriends.honeycloud.net
port = 20000
ident = my_ident
secret = my_secret

Every additional option you add to your section will be available to your processing plugin in the self.options dictionary.

A basic reporting plugin could look like:

 import json
 import logging
 from core.abstracts import Report
 

try: from yapsy.IPlugin import IPlugin except ImportError: raise ImportError, 'Yapsy (Yet Another Plugin System) is required to run this program : http://yapsy.sourceforge.net'

try: import utils.hpfeeds as hpfeeds except ImportError: raise ImportError, 'Unable to import HPFeeds library: https://github.com/rep/hpfeeds'

log = logging.getLogger("ReportingHPFriends")

class HPFriends(IPlugin, Report):

def run(self, results, objfile): host = self.options.get("host", "hpfriends.honeycloud.net") port = self.options.get("port", 20000) ident = self.options.get("ident") secret = self.options.get("secret") channel_reports = self.options.get("channel_reports") channel_files = self.options.get("channel_files") if not ident or not secret: raise Exception("HPFriends Identifier and Secret not configurated") try: #Connect to HPFriends hpc = hpfeeds.HPC(host, port, ident, secret, timeout=60) if channel_reports: #publish JSON-Report on the HPFriends channel log.info("publish JSON-Report on the HPFriends channel %s" % channel_reports) hpc.publish(channel_reports, json.dumps(results, default=self.date_handler, sort_keys=False, indent=4)) if channel_files: #publish RAW-File as BASE64 on the HPFriends channel log.info("publish BASE64 on the HPFriends channel %s" % channel_files) hpc.publish(channel_files, json.dumps(objfile.get_fileB64encode(), sort_keys=False, indent=4)) except hpfeeds.FeedException as e: raise Exception("publish on the channel failed: %s" % e) finally: hpc.close()

Powered by Google Project Hosting