Last active
August 29, 2015 14:00
-
-
Save ajithbh/11363599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import sys | |
enabled = [] | |
disabled = [] | |
class MethodWrapper(): | |
def __init__(self): | |
pass | |
def enable_apps(self): | |
print sys._getframe().f_code.co_name | |
def disable_apps(self): | |
print sys._getframe().f_code.co_name | |
def enable_eth(self): | |
print sys._getframe().f_code.co_name | |
def disable_eth(self): | |
print sys._getframe().f_code.co_name | |
def get_args(): | |
"""Get the command-line arguments""" | |
global enabled | |
global disabled | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-e', '--enable', help="Enable [apps] [eth]", action="append"); | |
parser.add_argument('-d', '--disable', help="Disable [apps] [eth]", action="append"); | |
args = parser.parse_args() | |
if args.enable: | |
enabled = args.enable | |
if args.disable: | |
disabled = args.disable | |
def main(): | |
get_args() | |
methods_instance = MethodWrapper() | |
for dis in disabled: | |
method_to_call = getattr(MethodWrapper, "disable_"+dis) | |
method_to_call(methods_instance) | |
for en in enabled: | |
method_to_call = getattr(MethodWrapper, "enable_"+en) | |
method_to_call(methods_instance) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment