Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # protofilter.py
- #
- # Copyright 2011 Sergio López <sergio.lopez@drainware.com>
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- # General Sintax:
- # dwf = drainware func/méthod
- # dwv = drainware var
- # dwl = drainware list
- # dwc = drainware class
- #
- # dw?+Utilidad
- #
- # Debug Sintax:
- # #DBG+" "
- """
- * Protofilter version 22feb2011
- """
- try:
- import sys
- except ImportError:
- exit(1)
- # Funciones
- # ----------------------------------------------------------------------
- def dwfArgumentsManager():
- """dwfArgumentsManager: Manage program arguments.
- return list of arguments (1:)
- """
- dwlReturn = list()
- dwvArgumentCount = len(sys.argv)
- #DBG print dwvArgumentCount
- if dwvArgumentCount < 3:
- print "Error: No arguments"
- exit(1)
- else:
- for i in sys.argv[1:]:
- dwlReturn.append(i)
- return dwlReturn
- # ----------------------------------------------------------------------
- # Main class
- # ----------------------------------------------------------------------
- class dwcMain():
- """
- * Main class
- * Manage actions
- """
- def __init__(self, dwlArgument):
- self.dwlArgument = dwlArgument
- self.dwvAction = self.dwlArgument[0]
- self.dwlElement = list()
- for self.i in self.dwlArgument[1:]:
- self.dwlElement.append(self.i)
- #DBG print "Debug: >:", self.dwvAction
- #DBG print "Debug: >:", self.dwlElement
- self.dwfLanzadera()
- def dwfLanzadera(self):
- """
- * Calls methods depending the action
- """
- if self.dwvAction == "on":
- pass ############################ Implementar métodos
- elif self.dwvAction == "off":
- pass
- elif self.dwvAction == "status":
- pass
- else:
- print "Error:",self.dwvAction,"is not a valid attribute."
- exit(1)
- # ----------------------------------------------------------------------
- def main(dwlInput):
- dwlArgument = list() # Final list of arguments
- for i in dwlInput:
- dwlArgument.append(str(i.lower()))
- x = dwcMain(dwlArgument)
- return 0
- if __name__ == '__main__':
- main(dwfArgumentsManager())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement