Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20835 > unrolled thread

How to handle calling functions from cli

Started byRodrick Brown <rodrick.brown@gmail.com>
First post2012-02-24 17:16 -0500
Last post2012-02-24 17:16 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  How to handle calling functions from cli  Rodrick Brown <rodrick.brown@gmail.com> - 2012-02-24 17:16 -0500

#20835 — How to handle calling functions from cli

FromRodrick Brown <rodrick.brown@gmail.com>
Date2012-02-24 17:16 -0500
SubjectHow to handle calling functions from cli
Message-ID<mailman.140.1330121935.3037.python-list@python.org>
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 I have 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web