Permalink
Browse files

yaml configuration

  • Loading branch information...
1 parent c15119a commit c620d90c931e78440ef7c6238d39522268e1238a @Eyjafjallajokull committed Jan 21, 2013
Showing with 38 additions and 37 deletions.
  1. +0 −33 config.json
  2. +33 −0 config.yml
  3. +4 −3 core/config.py
  4. +1 −1 core/widgetmanager.py
View
@@ -1,33 +0,0 @@
-{
- "core": {
- "logging": "DEBUG",
- "updateInterval": 2
- },
- "widgets": [
- {"id": "ProcessorWidget"},
- {"id": "MemoryWidget"},
- {"id": "UptimeWidget"},
- {"id": "NetworkWidget"},
- {"id": "KeeperWidget", "config": {
- "title":"System monitor",
- "monitor":[
- {"type":"process","value":"sbin/apache"},
- {"type":"process","value":"quake"},
- {"type":"file", "value":"/not/existing/file"},
- {"type":"file", "value":"/etc/passwd"},
- {"type":"command","value":"ls"},
- {"type":"command","value":"ls /not/existing/file"}
- ]}},
- {"id": "DisksWidget"},
- {"id": "ProcessesWidget"},
- {"id": "CommanderWidget", "config": {
- "title":"Aboco git history",
- "command":"git log -n 3 --shortstat",
- "classes":"doubleWidth doubleHeight"}}
- ],
- "http": {
- "threads": 1,
- "port": 2468,
- "address": "0.0.0.0"
- }
-}
View
@@ -0,0 +1,33 @@
+core:
+ logging: DEBUG
+ updateInterval: 2
+
+http:
+ threads: 1
+ port: 2468
+ address: 0.0.0.0
+
+widgets:
+ - {id: ProcessorWidget }
+ - {id: MemoryWidget }
+ - {id: UptimeWidget }
+ - {id: NetworkWidget }
+ - id: KeeperWidget
+ config:
+ title: System monitor
+ monitor:
+ - {type: process, value: sbin/apache }
+ - {type: process, value: quake }
+ - {type: file, value: /not/existing/file }
+ - {type: file, value: /etc/passwd }
+ - {type: command, value: ls }
+ - {type: command, value: ls /not/existing/file }
+ - {id: DisksWidget}
+ - {id: ProcessesWidget}
+ - id: CommanderWidget
+ config:
+ title: Aboco git history
+ command: git log -n 3 --shortstat
+ classes: doubleWidth doubleHeight
+
+
View
@@ -1,6 +1,7 @@
import os
import json
import logging
+import yaml
class Config:
defaults = {
@@ -18,7 +19,7 @@ class Config:
}
}
}
- fileName = 'config.json'
+ fileName = 'config.yml'
__config = None
__shared_state = {}
@@ -30,13 +31,13 @@ def __init__(self):
def save(self):
logging.debug('save config file')
cf = open(self.fileName, 'w')
- json.dump(self.__config, cf, indent=2)
+ yaml.dump(self.__config, cf, indent=2)
cf.close()
def load(self):
if os.path.isfile(self.fileName):
cf = file(self.fileName,'r')
- self.__config = json.load(cf)
+ self.__config = yaml.load(cf)
cf.close()
self.__config = dict(self.defaults, **self.__config)
View
@@ -67,7 +67,7 @@ def collectData(self):
try:
widgetData = widget.collectData()
except Exception as e:
- logging.error(str(e)+''.join(traceback.format_stack()))
+ logging.error(widget.__class__.__name__+': '+str(e)+'\n'+(''.join(traceback.format_stack())))
newData.append(widgetData)
found = True
if not found:

0 comments on commit c620d90

Please sign in to comment.