kopia lustrzana https://github.com/bellingcat/auto-archiver
Check for auto-archiver updates and present warning if there's a newer version available
rodzic
0eb112431b
commit
e6a578e60e
|
@ -15,6 +15,7 @@ from copy import copy
|
||||||
|
|
||||||
from rich_argparse import RichHelpFormatter
|
from rich_argparse import RichHelpFormatter
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
import requests
|
||||||
|
|
||||||
from .metadata import Metadata, Media
|
from .metadata import Metadata, Media
|
||||||
from auto_archiver.version import __version__
|
from auto_archiver.version import __version__
|
||||||
|
@ -349,6 +350,22 @@ class ArchivingOrchestrator:
|
||||||
|
|
||||||
return self.setup_complete_parser(basic_config, yaml_config, unused_args)
|
return self.setup_complete_parser(basic_config, yaml_config, unused_args)
|
||||||
|
|
||||||
|
def check_for_updates(self):
|
||||||
|
response = requests.get("https://pypi.org/pypi/auto-archiver/json").json()
|
||||||
|
latest_version = response['info']['version']
|
||||||
|
# check version compared to current version
|
||||||
|
if latest_version != __version__:
|
||||||
|
if os.environ.get('RUNNING_IN_DOCKER'):
|
||||||
|
update_cmd = "`docker pull bellingcat/auto-archiver:latest`"
|
||||||
|
else:
|
||||||
|
update_cmd = "`pip install --upgrade auto-archiver`"
|
||||||
|
logger.warning("")
|
||||||
|
logger.warning(f"********* IMPORTANT: UPDATE AVAILABLE ********")
|
||||||
|
logger.warning(f"A new version of auto-archiver is available (v{latest_version}, you have {__version__})")
|
||||||
|
logger.warning("Make sure to update to the latest version using: {update_cmd}")
|
||||||
|
logger.warning("")
|
||||||
|
|
||||||
|
|
||||||
def setup(self, args: list):
|
def setup(self, args: list):
|
||||||
"""
|
"""
|
||||||
Function to configure all setup of the orchestrator: setup configs and load modules.
|
Function to configure all setup of the orchestrator: setup configs and load modules.
|
||||||
|
@ -356,6 +373,8 @@ class ArchivingOrchestrator:
|
||||||
This method should only ever be called once
|
This method should only ever be called once
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.check_for_updates()
|
||||||
|
|
||||||
if self.setup_finished:
|
if self.setup_finished:
|
||||||
logger.warning("The `setup_config()` function should only ever be run once. \
|
logger.warning("The `setup_config()` function should only ever be run once. \
|
||||||
If you need to re-run the setup, please re-instantiate a new instance of the orchestrator. \
|
If you need to re-run the setup, please re-instantiate a new instance of the orchestrator. \
|
||||||
|
|
Ładowanie…
Reference in New Issue