Changeset 23:adc5b22efd7e in mailjam


Ignore:
Timestamp:
May 22, 2012, 7:31:12 PM (13 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Added the first version of the CLI client, which implements a shell-like
interface where users can interact with a mailjam server.

This first versions adds no "big" features, but contains the basis to build
a complete shell interface (including history saving support, completion,
help for commands, etc)

Added a custom configuration file (conf/mailjam-cli.conf) for the CLI
client.

Added a new mailjam.config class (CLIClientConfig) that is used by the CLI
client to load its configuration file.

Updated the package information (setup.py, MANIFEST) to include the CLI
client data.

Modified the behaviour of the XMLRPC methods registered in the *XMLRPC classes
within the daemon module. Now instead of raising exceptions directly, they
catch such exceptions, returning only a string representation of the error
to the XMLRPC client. If there is no error, a nice "ok" message is returned.

Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • MANIFEST

    r17 r23  
    22README
    33setup.py
     4bin/mailjam-cli
    45bin/mailjam-mta
    56bin/mailjam-server
    67mailjam/__init__.py
     8mailjam/cli.py
    79mailjam/config.py
    810mailjam/daemon.py
  • bin/mailjam-mta

    r21 r23  
    33# Run the Mailjam MTA client
    44
    5 import argparse, sys
     5import argparse
    66from mailjam.mta import MTAClient
    77
  • mailjam/config.py

    r20 r23  
    8989        return self.config[section]
    9090
     91
    9192class MTAClientConfig(DaemonConfig):
    9293    @property
     
    9798    def sections(self):
    9899        return ['server', 'archive']
     100
     101
     102class CLIClientConfig(DaemonConfig):
     103    @property
     104    def default_filename(self):
     105        return 'mailjam-cli.conf'
     106
     107    @property
     108    def sections(self):
     109        return ['server', 'archive', 'history']
    99110
    100111
  • mailjam/daemon.py

    r20 r23  
    163163    def _listMethods(self):
    164164        public_methods = []
    165         public_methods += ['lists.'+i for i in dir(MailingListXMLRPC) if '_' not in i]
    166         public_methods += ['members.'+i for i in dir(MemberXMLRPC) if '_' not in i]
     165        public_methods += ['lists.'+i for i in dir(MailingListXMLRPC) \
     166                           if '_' not in i]
     167        public_methods += ['members.'+i for i in dir(MemberXMLRPC) \
     168                           if '_' not in i]
    167169        return public_methods
    168170
     
    177179        self.mailjam.load()
    178180    def add(self, info={}):
    179         self.mailjam.add_mailing_list(info)
     181        try:
     182            self.mailjam.add_mailing_list(info)
     183        except IndexError, e:
     184            return str(e)
     185        return 'Added mailing list ' + info['address'] 
    180186    def addresses(self):
    181         return self.mailjam.mailings_addresses   
     187        return self.mailjam.mailings_addresses
    182188
    183189
     
    187193        self.mailjam.load()
    188194    def add(self, member_addr=None, list_addr=None):
    189         self.mailjam.add_mailing_member(member_addr, list_addr)
     195        try:
     196            self.mailjam.add_mailing_member(member_addr, list_addr)
     197        except IndexError, e:
     198            return str(e)
     199        return 'Added member ' + member_addr + ' to ' + list_addr
    190200    def list(self, mailing):
    191201        if mailing in self.mailjam.mailings_addresses:
  • mailjam/models.py

    r16 r23  
    3333    def _validate_address(self, address):
    3434        if not validate_email_address(address):
    35             raise ValueError(address, ' is not a valid email address')
     35            raise ValueError(str(address) + ' is not a valid email address')
    3636        return address
    3737
     
    6363    def _validate_member_object(self, member=None):
    6464        if not isinstance(member, Member):
    65             raise TypeError(member, ' is not a valid Member instance')
     65            raise TypeError(str(member) + ' is not a valid Member instance')
    6666        return member
    6767
     
    7272    def _validate_member_by_address(self, address=None):
    7373        if not validate_email_address(address):
    74             raise ValueError(address, ' is not a valid email address')
     74            raise ValueError(str(address) + ' is not a valid email address')
    7575        return address in self.members_addresses()
    7676
  • setup.py

    r16 r23  
    2323    description='Mailing lists management software',
    2424    long_description=open('README').read(),
    25     scripts=['bin/mailjam-server', 'bin/mailjam-mta'],
     25    scripts=['bin/mailjam-server', 'bin/mailjam-mta', 'bin/mailjam-cli'],
    2626    #data_files=[(proper_etc_path()+'mailjam', ['conf/mailjam.conf',
    2727    #                                           'conf/mailjam-mta.conf']),
Note: See TracChangeset for help on using the changeset viewer.