Example #1
0
class SWAML(ConsoleUI):
    """
    Main class of SWAML project
    
    @author: Sergio Fdez
    @license: GPL
    """

    def parseArgs(self, argv):
        """
        Getting params of default input
        
        @param argv: arguments values array
        """
        
        if not self.config.parse(argv):
            self.usage()
            
        #self.config.show()
        
    def version(self):
        """
        Print program version
        """
        
        print "SWAML 0.1.0", #TODO: __init__.__version__
        sys.exit()

    def __init__(self, argv, base=None):
        """
        Main method
        @param argv: values of inline arguments
        """
        
        if (base == None):
            path = __file__.split('/')
            base = '/'.join(path[:-1]) + '/'
        
        ConsoleUI.__init__(self, 'swaml', base)
        
        self.config = Configuration()        
        
        for arg in argv:
            if arg == "-h" or arg == "--help":
                self.usage()
            elif arg == "-v" or arg == "--version":
                self.version()
                
        self.config.setAgent('http://swaml.berlios.de/doap#swaml') #TODO: how __init__.__agent__?
        self.parseArgs(argv)
        if (base == None):
            self.list = MailingList(self.config)
        else:
            self.list = MailingList(self.config, base)
        messages = self.list.publish()
        print str(messages), 'messages procesed'
Example #2
0
 def __init__(self, argv, base=None):
     """
     Main method
     @param argv: values of inline arguments
     """
     
     if (base == None):
         path = __file__.split('/')
         base = '/'.join(path[:-1]) + '/'
     
     ConsoleUI.__init__(self, 'swaml', base)
     
     self.config = Configuration()        
     
     for arg in argv:
         if arg == "-h" or arg == "--help":
             self.usage()
         elif arg == "-v" or arg == "--version":
             self.version()
             
     self.config.setAgent('http://swaml.berlios.de/doap#swaml') #TODO: how __init__.__agent__?
     self.parseArgs(argv)
     if (base == None):
         self.list = MailingList(self.config)
     else:
         self.list = MailingList(self.config, base)
     messages = self.list.publish()
     print str(messages), 'messages procesed'
class ConfigWizard(ConsoleUI):
    """
    SWAML's config wizard
    
    @author: Sergio Fdez
    @license: GPL
    """
    
    def requestData(self):
        """
        Queries the user a new configuration
        """
        
        self.config = Configuration()
        
        print 'Write your configuration options:'
        print '(default value goes between [...])'
        
        for var in self.config.config.keys():
            defaultValue = str(self.config.config[var])
            value = raw_input('\t - ' + var + '[' + defaultValue + ']: ')
            if (len(value) > 0):
                self.config.set(var, value)
    
    def printData(self):
        """
        Dump on hard disk the configuration
        """
        
        ini = ConfigParser.ConfigParser()
        
        ini.add_section(self.section)
        
        for var in self.config.config.keys():
            ini.set(self.section, var, str(self.config.config[var]))
                     
        try:
            file = open(self.output, 'w+')
            ini.write(file)
            file.flush()
            file.close()
            print 'new config file created in', self.output, 'with chosen parameters'
        except IOError, detail:
            print 'Error exporting coordinates config file: ' + str(detail)
 def requestData(self):
     """
     Queries the user a new configuration
     """
     
     self.config = Configuration()
     
     print 'Write your configuration options:'
     print '(default value goes between [...])'
     
     for var in self.config.config.keys():
         defaultValue = str(self.config.config[var])
         value = raw_input('\t - ' + var + '[' + defaultValue + ']: ')
         if (len(value) > 0):
             self.config.set(var, value)