Commit 5406f147 authored by Luca Falavigna's avatar Luca Falavigna

Port JSONLogger module to latest sbuild codebase

parent dbed2678
...@@ -64,30 +64,29 @@ class DebomaticModule_JSONLogger: ...@@ -64,30 +64,29 @@ class DebomaticModule_JSONLogger:
def _set_json_logfile_name(self, args): def _set_json_logfile_name(self, args):
"""If debomatic config file has section [jsonlogger] try to get """If debomatic config file has section [jsonlogger] try to get
'jsonfile' option and override the default value.""" 'jsonfile' option and override the default value."""
if 'opts' in args and \ if (args.opts.has_section('jsonlogger') and
args['opts'].has_section('jsonlogger') and \ args.opts.has_option('jsonlogger', 'jsonfile')):
args['opts'].has_option('jsonlogger', 'jsonfile'): self.jsonfile = args.opts.get('jsonlogger', 'jsonfile').strip()
self.jsonfile = args['opts'].get('jsonlogger', 'jsonfile').strip()
def _get_package_json_filename(self, args): def _get_package_json_filename(self, args):
"""Get the path of package JSON file""" """Get the path of package JSON file"""
return '%(directory)s/pool/%(package)s/%(package)s.json' % args return ('%(directory)s/pool/%(package)s/%(package)s.json' %
{'directory': args.directory, 'package': args.package})
def _get_distribution_status(self, args): def _get_distribution_status(self, args):
"""From args to distribution status""" """From args to distribution status"""
status = {} status = {}
status['status'] = args['cmd'] status['status'] = args.action
status['distribution'] = args['distribution'] status['distribution'] = args.distribution
if 'success' in args: status['success'] = args.success
status['success'] = args['success']
return status return status
def _get_package_status(self, args): def _get_package_status(self, args):
"""From args to package status""" """From args to package status"""
status = {} status = {}
for k in ['package', 'distribution', 'uploader']: status['package'] = args.package
if k in args: status['distribution'] = args.distribution
status[k] = args[k] status['uploader'] = args.uploader
return status return status
def _append_json_logfile(self, args, status): def _append_json_logfile(self, args, status):
...@@ -145,9 +144,9 @@ class DebomaticModule_JSONLogger: ...@@ -145,9 +144,9 @@ class DebomaticModule_JSONLogger:
def post_build(self, args): def post_build(self, args):
status = self._get_package_status(args) status = self._get_package_status(args)
status['status'] = 'build' status['status'] = 'build'
status['success'] = args['success'] status['success'] = args.success
status['files'] = {} status['files'] = {}
resultdir = os.path.join(args['directory'], 'pool', args['package']) resultdir = os.path.join(args.directory, 'pool', args.package)
for filename in os.listdir(resultdir): for filename in os.listdir(resultdir):
if filename.endswith('.json'): if filename.endswith('.json'):
continue continue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment