-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version_checker refactor (#6018)
* Initial version_checker refactor * Final changes * Implement __str__ * Improve code * Fix git detection * Improve docs * Update Docker update msg * Update exceptions * Fix test * Use self.is_latest_version() only if branch is master * Revert unnecessary change * Review * Update CHANGELOG.md
- Loading branch information
Showing
16 changed files
with
1,138 additions
and
1,061 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# coding=utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# coding=utf-8 | ||
|
||
from __future__ import unicode_literals | ||
|
||
import logging | ||
|
||
from medusa import app | ||
from medusa.logger.adapters.style import BraceAdapter | ||
from medusa.updater.source_updater import SourceUpdateManager | ||
|
||
|
||
log = BraceAdapter(logging.getLogger(__name__)) | ||
log.logger.addHandler(logging.NullHandler()) | ||
|
||
|
||
class DockerUpdateManager(SourceUpdateManager): | ||
def __init__(self): | ||
super(DockerUpdateManager, self).__init__() | ||
|
||
def __str__(self): | ||
return 'Docker Updater' | ||
|
||
def need_update(self): | ||
if self.branch != self._find_installed_branch(): | ||
log.debug(u'Branch checkout: {0}->{1}', self._find_installed_branch(), self.branch) | ||
return True | ||
|
||
if self.branch == 'master' and not self.is_latest_version(): | ||
self._set_update_text() | ||
return True | ||
|
||
return False | ||
|
||
def can_update(self): | ||
"""Whether or not the update can be performed. | ||
:return: | ||
:rtype: bool | ||
""" | ||
return False | ||
|
||
def _set_update_text(self): | ||
"""Set an update text, when running in a Docker container.""" | ||
log.debug('There is an update available, Medusa is running in a Docker container,' | ||
' so auto updating is disabled.') | ||
|
||
url = 'http://github.com/' + self.github_org + '/' + self.github_repo + '/releases' | ||
newest_text = 'There is a <a href="' + url + '" onclick="window.open(this.href); return false;">newer version available</a>' | ||
newest_text += ' (' + self.newest_version + ') — Pull the latest Docker image and rebuild your container to update' | ||
app.NEWEST_VERSION_STRING = newest_text | ||
|
||
def update(self): | ||
"""Download the latest version.""" | ||
return False |
Oops, something went wrong.