How to handle calling functions from cli

R

Rodrick Brown

I have a bunch of sub routines that run independently to perform various system checks on my servers. I wanted to get an opinion on the following code Ihave about 25 independent checks and I'm adding the ability to disable certain checks that don't apply to certain hosts.


m = { 'a': 'checkDisks()',
'b': 'checkMemSize()',
'c': 'checkBondInterfaces()'
}

parser = argparse.ArgumentParser(description='Parse command line args.')
parser.add_argument('-x', action="store", dest="d")
r = parser.parse_args(sys.argv[1:])

runlist = [ c for c in m.keys() if c not in r.d ]
for runable in runlist:
eval(m[runable])

I'm using temp variable names for now until I find an approach I like.

Is this a good approach ? It doesn't look too pretty and to be honest feels awkward?

Sent from my iPhone
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top