Пример #1
0
def option_parser():
    try:
        from calibre.utils.config import OptionParser
        OptionParser
    except ImportError:
        from optparse import OptionParser
    parser = OptionParser(_('''\
%prog [options] [from to text]

Send mail using the SMTP protocol. %prog has two modes of operation. In the
compose mode you specify from to and text and these are used to build and
send an email message. In the filter mode, %prog reads a complete email
message from STDIN and sends it.

text is the body of the email message.
If text is not specified, a complete email message is read from STDIN.
from is the email address of the sender and to is the email address
of the recipient. When a complete email is read from STDIN, from and to
are only used in the SMTP negotiation, the message headers are not modified.
'''))
    c=parser.add_option_group('COMPOSE MAIL',
        _('Options to compose an email. Ignored if text is not specified')).add_option
    c('-a', '--attachment', help=_('File to attach to the email'))
    c('-s', '--subject', help=_('Subject of the email'))

    parser.add_option('-l', '--localhost',
                      help=_('Host name of localhost. Used when connecting '
                            'to SMTP server.'))
    r=parser.add_option_group('SMTP RELAY',
        _('Options to use an SMTP relay server to send mail. '
        'calibre will try to send the email directly unless --relay is '
        'specified.')).add_option
    r('-r', '--relay', help=_('An SMTP relay server to use to send mail.'))
    r('-p', '--port', default=-1,
      help=_('Port to connect to on relay server. Default is to use 465 if '
      'encryption method is SSL and 25 otherwise.'))
    r('-u', '--username', help=_('Username for relay'))
    r('-p', '--password', help=_('Password for relay'))
    r('-e', '--encryption-method', default='TLS',
      choices=['TLS', 'SSL', 'NONE'],
      help=_('Encryption method to use when connecting to relay. Choices are '
      'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure'))
    r('--dont-verify-server-certificate', help=_(
        'Do not verify the server certificate when connecting using TLS. This used'
        ' to be the default behavior in calibre versions before 3.27. If you are using'
        ' a relay with a self-signed or otherwise invalid certificate, you can use this option to restore'
        ' the pre 3.27 behavior'))
    r('--cafile', help=_(
        'Path to a file of concatenated CA certificates in PEM format, used to verify the'
        ' server certificate when using TLS. By default, the system CA certificates are used.'))
    parser.add_option('-o', '--outbox', help=_('Path to maildir folder to store '
                      'failed email messages in.'))
    parser.add_option('-f', '--fork', default=False, action='store_true',
                      help=_('Fork and deliver message in background. '
                      'If you use this option, you should also use --outbox '
                      'to handle delivery failures.'))
    parser.add_option('-t', '--timeout', help=_('Timeout for connection'))
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help=_('Be more verbose'))
    return parser
Пример #2
0
def option_parser():
    try:
        from calibre.utils.config import OptionParser
        OptionParser
    except ImportError:
        from optparse import OptionParser
    parser = OptionParser(_('''\
%prog [options] [from to text]

Send mail using the SMTP protocol. %prog has two modes of operation. In the
compose mode you specify from to and text and these are used to build and
send an email message. In the filter mode, %prog reads a complete email
message from STDIN and sends it.

text is the body of the email message.
If text is not specified, a complete email message is read from STDIN.
from is the email address of the sender and to is the email address
of the recipient. When a complete email is read from STDIN, from and to
are only used in the SMTP negotiation, the message headers are not modified.
'''))
    c=parser.add_option_group('COMPOSE MAIL',
        _('Options to compose an email. Ignored if text is not specified')).add_option
    c('-a', '--attachment', help=_('File to attach to the email'))
    c('-s', '--subject', help=_('Subject of the email'))

    parser.add_option('-l', '--localhost',
                      help=_('Host name of localhost. Used when connecting '
                            'to SMTP server.'))
    r=parser.add_option_group('SMTP RELAY',
        _('Options to use an SMTP relay server to send mail. '
        'calibre will try to send the email directly unless --relay is '
        'specified.')).add_option
    r('-r', '--relay', help=_('An SMTP relay server to use to send mail.'))
    r('-p', '--port', default=-1,
      help=_('Port to connect to on relay server. Default is to use 465 if '
      'encryption method is SSL and 25 otherwise.'))
    r('-u', '--username', help=_('Username for relay'))
    r('-p', '--password', help=_('Password for relay'))
    r('-e', '--encryption-method', default='TLS',
      choices=['TLS', 'SSL', 'NONE'],
      help=_('Encryption method to use when connecting to relay. Choices are '
      'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure'))
    r('--dont-verify-server-certificate', help=_(
        'Do not verify the server certificate when connecting using TLS. This used'
        ' to be the default behavior in calibre versions before 3.27. If you are using'
        ' a relay with a self-signed or otherwise invalid certificate, you can use this option to restore'
        ' the pre 3.27 behavior'))
    r('--cafile', help=_(
        'Path to a file of concatenated CA certificates in PEM format, used to verify the'
        ' server certificate when using TLS. By default, the system CA certificates are used.'))
    parser.add_option('-o', '--outbox', help=_('Path to maildir folder to store '
                      'failed email messages in.'))
    parser.add_option('-f', '--fork', default=False, action='store_true',
                      help=_('Fork and deliver message in background. '
                      'If you use this option, you should also use --outbox '
                      'to handle delivery failures.'))
    parser.add_option('-t', '--timeout', help=_('Timeout for connection'))
    parser.add_option('-v', '--verbose', default=0, action='count',
                      help=_('Be more verbose'))
    return parser
Пример #3
0
    def option_parser(self, user_defaults=None, usage='', gui_mode=False):
        from calibre.utils.config import OptionParser
        parser = OptionParser(usage, gui_mode=gui_mode)
        groups = defaultdict(lambda: parser)
        for group, desc in self.groups.items():
            groups[group] = parser.add_option_group(group.upper(), desc)

        for pref in self.preferences:
            if not pref.switches:
                continue
            g = groups[pref.group]
            action = pref.action
            if action is None:
                action = 'store'
                if pref.default is True or pref.default is False:
                    action = 'store_' + ('false' if pref.default else 'true')
            args = dict(
                dest=pref.name,
                help=pref.help,
                metavar=pref.metavar,
                type=pref.type,
                choices=pref.choices,
                default=getattr(user_defaults, pref.name, pref.default),
                action=action,
            )
            g.add_option(*pref.switches, **args)

        return parser
Пример #4
0
    def option_parser(self, user_defaults=None, usage='', gui_mode=False):
        from calibre.utils.config import OptionParser
        parser = OptionParser(usage, gui_mode=gui_mode)
        groups = defaultdict(lambda : parser)
        for group, desc in self.groups.items():
            groups[group] = parser.add_option_group(group.upper(), desc)

        for pref in self.preferences:
            if not pref.switches:
                continue
            g = groups[pref.group]
            action = pref.action
            if action is None:
                action = 'store'
                if pref.default is True or pref.default is False:
                    action = 'store_' + ('false' if pref.default else 'true')
            args = dict(
                        dest=pref.name,
                        help=pref.help,
                        metavar=pref.metavar,
                        type=pref.type,
                        choices=pref.choices,
                        default=getattr(user_defaults, pref.name, pref.default),
                        action=action,
                        )
            g.add_option(*pref.switches, **args)

        return parser
Пример #5
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=_(
            'Path to the calibre library. Default is to use the path stored in the settings.'
            ' You can also connect to a calibre Content server to perform actions on'
            ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
            ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
            ' of the library you want to connect to on the Content server. You can use'
            ' the special library_id value of - to get a list of library ids available'
            ' on the server. For details on how to setup access via a Content server, see'
            ' {}.'
        ).format(localize_user_manual_link(
            'https://manual.calibre-ebook.com/generated/en/calibredb.html'
        ))
    )
    go.add_option(
        '-h', '--help', help=_('show this help message and exit'), action='help'
    )
    go.add_option(
        '--version',
        help=_("show program's version number and exit"),
        action='version'
    )
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server')
    )
    go.add_option(
        '--password',
        help=_('Password for connecting to a calibre Content server.'
               ' To read the password from standard input, use the special value: {0}.'
               ' To read the password from a file, use: {1} (i.e. <f: followed by the full path to the file and a trailing >).'
               ' The angle brackets in the above are required, remember to escape them or use quotes'
               ' for your shell.').format(
                   '<stdin>', '<f:C:/path/to/file>' if iswindows else '<f:/path/to/file>')
    )
    go.add_option(
        '--timeout',
        type=float,
        default=120,
        help=_('The timeout, in seconds, when connecting to a calibre library over the network. The default is'
               ' two minutes.')
    )

    return parser
Пример #6
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=_(
            'Path to the calibre library. Default is to use the path stored in the settings.'
            ' You can also connect to a calibre Content server to perform actions on'
            ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
            ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
            ' of the library you want to connect to on the Content server. You can use'
            ' the special library_id value of - to get a list of library ids available'
            ' on the server. For details on how to setup access via a Content server, see'
            ' {}.'
        ).format(localize_user_manual_link(
            'https://manual.calibre-ebook.com/generated/en/calibredb.html'
        ))
    )
    go.add_option(
        '-h', '--help', help=_('show this help message and exit'), action='help'
    )
    go.add_option(
        '--version',
        help=_("show program's version number and exit"),
        action='version'
    )
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server')
    )
    go.add_option(
        '--password',
        help=_('Password for connecting to a calibre Content server.'
               ' To read the password from standard input, use the special value: {0}.'
               ' To read the password from a file, use: {1} (i.e. <f: followed by the full path to the file and a trailing >).'
               ' The angle brackets in the above are required, remember to escape them or use quotes'
               ' for your shell.').format(
                   '<stdin>', '<f:C:/path/to/file>' if iswindows else '<f:/path/to/file>')
    )

    return parser
Пример #7
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.is_global_options = True
    go.add_option(
        '--library-path',
        '--with-library',
        default=None,
        help=
        _('Path to the calibre library. Default is to use the path stored in the settings.'
          ' You can also connect to a calibre Content server to perform actions on'
          ' remote libraries. To do so use a URL of the form: http://hostname:port/#library_id'
          ' for example, http://localhost:8080/#mylibrary. library_id is the library id'
          ' of the library you want to connect to on the Content server. You can use'
          ' the special library_id value of - to get a list of library ids available'
          ' on the server. For details on how to setup access via a Content server, see'
          ' {}.').
        format(
            localize_user_manual_link(
                'https://manual.calibre-ebook.com/generated/en/calibredb.html')
        ))
    go.add_option('-h',
                  '--help',
                  help=_('show this help message and exit'),
                  action='help')
    go.add_option('--version',
                  help=_("show program's version number and exit"),
                  action='version')
    go.add_option(
        '--username',
        help=_('Username for connecting to a calibre Content server'))
    go.add_option(
        '--password',
        help=_(
            'Password for connecting to a calibre Content server.'
            ' To read the password from standard input, use the special value: {}.'
            ' To read the password from a file, use: {}.)').format(
                '<stdin>', '<f:/path/to/file>'))

    return parser
Пример #8
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.add_option('--library-path', '--with-library', default=None, help=_('Path to the calibre library. Default is to use the path stored in the settings.'))

    return parser
Пример #9
0
def get_parser(usage):
    parser = OptionParser(usage)
    go = parser.add_option_group(_('GLOBAL OPTIONS'))
    go.add_option('--library-path', '--with-library', default=None, help=_('Path to the calibre library. Default is to use the path stored in the settings.'))

    return parser