Beispiel #1
0
    '-m', '--maildir', metavar='DIR', help=
    'Override the setting of the $MAILDIR environment variable (or '
    '~/Maildir if $MAILDIR is not defined) with DIR.')
parser.add_option(
    '-t', '--template', default='%s', help=
    'Folder names are expanded using TEMPLATE, a Python string '
    'template, before processing [default: %default]')
parser.add_option(
    '-i', '--inbox', default='INBOX', metavar='STRING', help=
    'Substitute STRING for the INBOX folder [default: %default]')
parser.add_option(
    '-c', '--checker', type="string", action='callback',
    callback=check.get_checker, metavar='ENTRYPOINT', help=
    'Check folder using the checker at the stuptools ENTRYPOINT when '
    'folders are modified')
parse.add_options(parser, check.parser, 'Checkers')

class Watcher(object):
    __doc__ = __doc__

    def __init__(self, maildir=parser.defaults['maildir'],
                 template=parser.defaults['template'],
                 inbox=parser.defaults['inbox'],
                 checker=parser.defaults['checker'](), **kw):
        args = ['watch_maildirs']
        if maildir is not None:
            args.append('--maildir=%s' % maildir)
        logger.info("Running '%s'" % ' '.join(args))
        self.watcher = subprocess.Popen(
            args , stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        self.template = template
Beispiel #2
0
            'emacsclient', '--eval',
            '(%s (quote (%s)))' % (self.elisp_func, folders)
        ]


class SSHChecker(Checker):
    """Run the specified checker on a remote host using SSH."""

    parser = optparse.OptionParser(description=__doc__)
    parser.add_option('-a', '--host', help='Connect to HOST via SSH.')
    parser.add_option('-s',
                      '--ssh-checker',
                      type="string",
                      action='callback',
                      callback=get_checker,
                      metavar='ENTRYPOINT',
                      help='Run the checker at the stuptools ENTRYPOINT')

    def __init__(self, host, ssh_checker=EmacsclientChecker(), **kw):
        self.host = host
        self.checker = ssh_checker

    def getArgs(self, *folders):
        command = ["'%s'" % arg for arg in self.checker.getArgs(*folders)]
        return ["ssh", self.host] + command


parser = optparse.OptionParser(description=Checker.__doc__)
parse.add_options(parser, EmacsclientChecker.parser, 'Emacsclient Checker')
parse.add_options(parser, SSHChecker.parser, 'SSH Checker')
Beispiel #3
0
    def getArgs(self, *folders):
        folders = ' '.join(
            ('"%s"' % folder.replace('/', '.') for folder in folders))
        return ['emacsclient', '--eval',
                '(%s (quote (%s)))' % (self.elisp_func, folders)]

class SSHChecker(Checker):
    """Run the specified checker on a remote host using SSH."""

    parser = optparse.OptionParser(description=__doc__)
    parser.add_option(
        '-a', '--host', help='Connect to HOST via SSH.')
    parser.add_option(
        '-s', '--ssh-checker', type="string", action='callback',
        callback=get_checker, metavar='ENTRYPOINT', help=
        'Run the checker at the stuptools ENTRYPOINT')

    def __init__(self, host, ssh_checker=EmacsclientChecker(), **kw):
        self.host = host
        self.checker = ssh_checker

    def getArgs(self, *folders):
        command = ["'%s'" % arg
                   for arg in self.checker.getArgs(*folders)]
        return ["ssh", self.host] + command

parser = optparse.OptionParser(description=Checker.__doc__)
parse.add_options(
    parser, EmacsclientChecker.parser, 'Emacsclient Checker')
parse.add_options(parser, SSHChecker.parser, 'SSH Checker')