Skip to content

Commit

Permalink
Provide JSONLogger debomatic module along with
Browse files Browse the repository at this point in the history
this interface.

Update README e config.js according with.
  • Loading branch information
LeoIannacone committed Mar 17, 2014
1 parent 68aa787 commit 4d9fec9
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 8 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ debomatic-webui
This interface is built up on [node](http://nodejs.org/) platform and uses intensely [socket.io](http://socket.io/) and [jquery](http://jquery.com/) technologies.
Whenever you want to leave a suggestion or file a bug report, please open a [new issue](https://github.com/LeoIannacone/debomatic-webui/issues).

## Installation
## Requirements

Installation is very simple.
You need **JSONLogger** debomatic module (provided along with this interface) to get installed in debomatic.
You can copy `debomatic-modules/JSONLogger.py` or link to the modules directory. In the most cases:
```
sudo cp debomatic-modules/JSONLogger.py /usr/share/debomatic/modules/
```
Restart debomatic service.

1. First of all, you need `npm` and `nodejs` installed on your system. On debian like systems type this in a command line:
```

Install **npm** and **nodejs** on your system. On debian like systems type this in a command line:
```
sudo apt-get install npm nodejs
```

2. Then move to `debomatic-webui/` directory and type:
## Installation

Move to **debomatic-webui/** directory and type:
```
npm install
```
That command downloads node depenences locally and creates the `user.config.js` file.
That command downloads node dependences locally and creates automatically user configuration file.

2. Take a look at `user.config.js`. Edit as you wish and then run service with:
Take a look at auto-generated **user.config.js**. Edit as you wish and then run service with:
```
nodejs index.js
```
Expand Down
63 changes: 63 additions & 0 deletions debomatic-modules/JSONLogger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Deb-o-Matic - JSON logger module
#
# Copyright (C) 2014 Leo Iannacone
#
# Authors: Leo Iannacone <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Log information about building packages in a JSON format.

import os
from json import dumps as toJSON


class DebomaticModule_JSONLogger:

def __init__(self):
self.logfile = '/var/log/debomatic-json.log'

def _set_logfile(self, args):
if args['opts'].has_section('jsonlogger'):
self.logfile = args['opts'].get('jsonlogger', 'jsonfile').strip()

def _get_info(self, args):
keys = ['package', 'distribution', 'uploader']
info = {}
for k in keys:
if args.has_key(k):
info[k] = args[k]
return info

def pre_build(self, args):
self._set_logfile(args)
with open(self.logfile, 'a') as fd:
package = self._get_info(args)
package['status'] = 'building'
json = toJSON(package)
fd.write(json + '\n')

def post_build(self, args):
self._set_logfile(args)
with open(self.logfile, 'a') as fd:
status = 'build-failed'
package = self._get_info(args)
resultdir = os.path.join(args['directory'], 'pool', args['package'])
for filename in os.listdir(resultdir):
if filename.endswith('.dsc'):
status = 'build-successed'
break
package['status'] = status
json = toJSON(package)
fd.write(json + '\n')
2 changes: 1 addition & 1 deletion debomatic-webui/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ config.socket.log = false

config.debomatic = {}
config.debomatic.path = '/srv/debomatic-amd64'
config.debomatic.jsonfile = '/var/log/debomatic.json'
config.debomatic.jsonfile = '/var/log/debomatic-json.log'

config.routes = {}
config.routes.debomatic = '/debomatic'
Expand Down

0 comments on commit 4d9fec9

Please sign in to comment.