update check at startup
This commit is contained in:
parent
edbe1af3fa
commit
9247c0d3f3
@ -15,17 +15,18 @@ DFT_PLUGINS = ''
|
|||||||
|
|
||||||
DFT_CONFIG = {'papers_dir' : os.path.expanduser('~/.papers'),
|
DFT_CONFIG = {'papers_dir' : os.path.expanduser('~/.papers'),
|
||||||
'doc_dir' : 'doc',
|
'doc_dir' : 'doc',
|
||||||
'import_copy' : 'yes',
|
'import_copy' : True,
|
||||||
'import_move' : 'no',
|
'import_move' : False,
|
||||||
'color' : 'yes',
|
'color' : True,
|
||||||
'version' : 3,
|
'version' : 3,
|
||||||
|
'version_warning' : True,
|
||||||
|
|
||||||
'open_cmd' : 'open',
|
'open_cmd' : 'open',
|
||||||
'edit_cmd' : DFT_EDIT_CMD,
|
'edit_cmd' : DFT_EDIT_CMD,
|
||||||
'plugins' : DFT_PLUGINS
|
'plugins' : DFT_PLUGINS
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEANS = {'import_copy', 'import_move', 'color'}
|
BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'}
|
||||||
|
|
||||||
|
|
||||||
# package-shared config that can be accessed using :
|
# package-shared config that can be accessed using :
|
||||||
|
@ -9,6 +9,7 @@ from .ui import UI
|
|||||||
from . import configs
|
from . import configs
|
||||||
from . import commands
|
from . import commands
|
||||||
from . import plugins
|
from . import plugins
|
||||||
|
from .__init__ import __version__
|
||||||
|
|
||||||
cmds = collections.OrderedDict([
|
cmds = collections.OrderedDict([
|
||||||
('init', commands.init_cmd),
|
('init', commands.init_cmd),
|
||||||
@ -25,6 +26,26 @@ cmds = collections.OrderedDict([
|
|||||||
('update', commands.update_cmd),
|
('update', commands.update_cmd),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def _update_check(config, ui):
|
||||||
|
if config.version_warning:
|
||||||
|
code_version = int(__version__)
|
||||||
|
repo_version = int(config.version)
|
||||||
|
|
||||||
|
if repo_version > code_version:
|
||||||
|
ui.print_('warning: your repository was generated with an newer version'
|
||||||
|
' of papers (v{}) than the one you are using (v{}).\n'.format(
|
||||||
|
repo_version, code_version) +
|
||||||
|
' you should not use papers until you install the '
|
||||||
|
'newest version. (use version_warning in you papersrc '
|
||||||
|
'to bypass this error)')
|
||||||
|
sys.exit()
|
||||||
|
elif repo_version < code_version:
|
||||||
|
ui.print_(
|
||||||
|
'warning: your repository version (v{})'.format(repo_version)
|
||||||
|
+ 'must be updated to version {}.\n'.format(code_version)
|
||||||
|
+ "run 'papers update'.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def execute(raw_args = sys.argv):
|
def execute(raw_args = sys.argv):
|
||||||
# loading config
|
# loading config
|
||||||
@ -34,6 +55,8 @@ def execute(raw_args = sys.argv):
|
|||||||
|
|
||||||
ui = UI(config)
|
ui = UI(config)
|
||||||
|
|
||||||
|
_update_check(config, ui)
|
||||||
|
|
||||||
# Extend with plugin commands
|
# Extend with plugin commands
|
||||||
plugins.load_plugins(ui, config.plugins.split())
|
plugins.load_plugins(ui, config.plugins.split())
|
||||||
for p in plugins.get_plugins().values():
|
for p in plugins.get_plugins().values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user