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


Groups > comp.lang.python > #20835

How to handle calling functions from cli

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rodrick.brown@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.047
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'parser': 0.05; 'disable': 0.09; 'received:10.50': 0.09; 'received:209.85.214.174': 0.13; 'to:name:python-list@python.org': 0.15; 'temp': 0.16; "doesn't": 0.22; 'command': 0.24; 'code': 0.26; 'variable': 0.28; "i'm": 0.28; "skip:' 10": 0.29; 'skip:p 30': 0.29; 'servers.': 0.30; 'sub': 0.30; 'pretty': 0.31; 'message-id:@gmail.com': 0.31; 'like.': 0.32; 'too': 0.33; 'certain': 0.34; 'to:addr:python- list': 0.35; 'apply': 0.35; 'subject:How': 0.35; 'received:209.85.214': 0.36; 'checks': 0.37; 'run': 0.37; 'charset :us-ascii': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'bunch': 0.38; 'subject:from': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'header:Message-Id:1': 0.62; 'iphone': 0.68; 'subject:handle': 0.84
Received-SPF pass (google.com: domain of rodrick.brown@gmail.com designates 10.50.87.136 as permitted sender) client-ip=10.50.87.136;
Authentication-Results mr.google.com; spf=pass (google.com: domain of rodrick.brown@gmail.com designates 10.50.87.136 as permitted sender) smtp.mail=rodrick.brown@gmail.com; dkim=pass header.i=rodrick.brown@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:from:content-type:x-mailer:message-id:date:to :content-transfer-encoding:mime-version; bh=YTIpvHN03/0qkXBXv0kOMvcpeGdfwnMpIXBexVxBElE=; b=ffLx6LgDLVe3rcxG7/hmlhB02Mwrgb6b54ClySxS/+bczIfhN0Cfm7WTpXv0nBdhnN lk1nG4mcBPfRlsUvwkXUVCcx/bx3IwgwRR3N9qVjuZ5s8tkiKEqJUuwAnpADhM09wJGr sxYMXP6eLAOmkr6A9LKAEUUAbXOwbX6sjh/CY=
Subject How to handle calling functions from cli
From Rodrick Brown <rodrick.brown@gmail.com>
Content-Type text/plain; charset=us-ascii
X-Mailer iPhone Mail (9A405)
Date Fri, 24 Feb 2012 17:16:09 -0500
To "python-list@python.org" <python-list@python.org>
Content-Transfer-Encoding quoted-printable
Mime-Version 1.0 (1.0)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.140.1330121935.3037.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330121935 news.xs4all.nl 6859 [2001:888:2000:d::a6]:33164
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20835

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web