mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-09 11:26:00 +00:00
Show error for Python 2 users (#441)
* Show error for Python 2 users The error can be disabled with a config option. See #219
This commit is contained in:
parent
3ac486cff1
commit
ea17f2ac01
4 changed files with 26 additions and 10 deletions
|
|
@ -15,6 +15,7 @@ Version 0.11.0
|
|||
- Discovery is no longer automatically done when running ``vdirsyncer sync``.
|
||||
``vdirsyncer discover`` now has to be explicitly called.
|
||||
- Add a ``.plist`` example for Mac OS X.
|
||||
- Usage under Python 2 now requires a special config parameter to be set.
|
||||
|
||||
Version 0.10.0
|
||||
==============
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def setup_logging():
|
|||
|
||||
@pytest.fixture(autouse=True)
|
||||
def suppress_py2_warning(monkeypatch):
|
||||
monkeypatch.setattr('vdirsyncer.cli._check_python2', lambda: None)
|
||||
monkeypatch.setattr('vdirsyncer.cli._check_python2', lambda _: None)
|
||||
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import click
|
|||
|
||||
import click_log
|
||||
|
||||
from .. import PROJECT_HOME, __version__
|
||||
from .. import PROJECT_HOME, __version__, exceptions
|
||||
from ..utils.compat import PY2
|
||||
|
||||
|
||||
|
|
@ -38,12 +38,27 @@ def catch_errors(f):
|
|||
return inner
|
||||
|
||||
|
||||
def _check_python2():
|
||||
if PY2:
|
||||
cli_logger.warning('Python 2 support will be dropped. Please switch '
|
||||
'to at least Python 3.3 as soon as possible. See '
|
||||
'{home}/issues/219 for more information.'
|
||||
.format(home=PROJECT_HOME))
|
||||
def _check_python2(config):
|
||||
# XXX: Py2
|
||||
if not PY2:
|
||||
return
|
||||
|
||||
msg = (
|
||||
'Python 2 support will be dropped. Please switch '
|
||||
'to at least Python 3.3 as soon as possible. See '
|
||||
'{home}/issues/219 for more information.'
|
||||
.format(home=PROJECT_HOME)
|
||||
)
|
||||
|
||||
if not config.general.get('python2', False):
|
||||
raise exceptions.UserError(
|
||||
msg + (
|
||||
'\nSet python2 = true in the [general] section to get rid of '
|
||||
'this error for now.'
|
||||
)
|
||||
)
|
||||
else:
|
||||
cli_logger.warning(msg)
|
||||
|
||||
|
||||
@click.group()
|
||||
|
|
@ -57,11 +72,11 @@ def app(ctx, config):
|
|||
'''
|
||||
vdirsyncer -- synchronize calendars and contacts
|
||||
'''
|
||||
_check_python2()
|
||||
from .config import load_config
|
||||
|
||||
if not ctx.config:
|
||||
ctx.config = load_config(config)
|
||||
_check_python2(ctx.config)
|
||||
|
||||
main = app
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ try:
|
|||
except ImportError:
|
||||
from configparser import RawConfigParser
|
||||
|
||||
GENERAL_ALL = frozenset(['status_path'])
|
||||
GENERAL_ALL = frozenset(['status_path', 'python2']) # XXX: Py2
|
||||
GENERAL_REQUIRED = frozenset(['status_path'])
|
||||
SECTION_NAME_CHARS = frozenset(chain(string.ascii_letters, string.digits, '_'))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue