Skip to content

Commit

Permalink
Add system information to global cfg.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Apr 1, 2015
1 parent 564a31d commit 29ddb62
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from conduct import loggers
from conduct.chain import Chain
from conduct.util import loadChainDefinition, loadChainConfig, \
chainPathToName, loadConductConf
chainPathToName, loadConductConf, analyzeSystem

def processGlobalArgs(parser, argv):
'''
Expand Down Expand Up @@ -144,6 +144,9 @@ def main(argv=None):
# configure logging
initLogging()

# collect some system information
conduct.cfg['system'] = analyzeSystem()

chainDef = loadChainDefinition(args.chain)

# load chain config if any
Expand Down
20 changes: 20 additions & 0 deletions conduct/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import logging
import subprocess
import platform

from collections import OrderedDict
from ConfigParser import SafeConfigParser
Expand Down Expand Up @@ -83,6 +84,25 @@ def __getattr__(self, name):

## Util funcs

def analyzeSystem():
conduct.log.info('Analyze current system ...')

info = platform.uname()
infoKeys = ('os',
'hostname',
'release',
'version',
'arch',
'processor')

info = dict(zip(infoKeys, info))

for key in infoKeys:
conduct.log.debug('{:<10}: {}'.format(key, info[key]))

return info


def loadConductConf(cfgPath=None):
if cfgPath is None:
cfgPath = getDefaultConfigPath()
Expand Down

0 comments on commit 29ddb62

Please sign in to comment.