mirror of
https://github.com/SickGear/SickGear.git
synced 2025-03-15 09:07:43 +00:00
More fixes for checkout/updating issues.
This commit is contained in:
parent
ad39ac8772
commit
39fe8e8477
3 changed files with 30 additions and 15 deletions
|
@ -49,7 +49,6 @@ from sickbeard.common import SD, SKIPPED, NAMING_REPEAT
|
||||||
from sickbeard.databases import mainDB, cache_db, failed_db
|
from sickbeard.databases import mainDB, cache_db, failed_db
|
||||||
|
|
||||||
from lib.configobj import ConfigObj
|
from lib.configobj import ConfigObj
|
||||||
import xml.etree.ElementTree as ElementTree
|
|
||||||
|
|
||||||
PID = None
|
PID = None
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ VERSION_NOTIFY = False
|
||||||
AUTO_UPDATE = False
|
AUTO_UPDATE = False
|
||||||
NOTIFY_ON_UPDATE = False
|
NOTIFY_ON_UPDATE = False
|
||||||
CUR_COMMIT_HASH = None
|
CUR_COMMIT_HASH = None
|
||||||
BRANCH = None
|
BRANCH = ''
|
||||||
|
|
||||||
INIT_LOCK = Lock()
|
INIT_LOCK = Lock()
|
||||||
started = False
|
started = False
|
||||||
|
|
|
@ -22,12 +22,8 @@ import platform
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from sickbeard import version
|
|
||||||
|
|
||||||
INSTANCE_ID = str(uuid.uuid1())
|
INSTANCE_ID = str(uuid.uuid1())
|
||||||
USER_AGENT = ('SickRage/' + version.SICKBEARD_VERSION.replace(' ', '-') +
|
USER_AGENT = ('SickRage/(' + platform.system() + '; ' + platform.release() + '; ' + INSTANCE_ID + ')')
|
||||||
' (' + platform.system() + '; ' + platform.release() +
|
|
||||||
'; ' + INSTANCE_ID + ')')
|
|
||||||
|
|
||||||
mediaExtensions = ['avi', 'mkv', 'mpg', 'mpeg', 'wmv',
|
mediaExtensions = ['avi', 'mkv', 'mpg', 'mpeg', 'wmv',
|
||||||
'ogm', 'mp4', 'iso', 'img', 'divx',
|
'ogm', 'mp4', 'iso', 'img', 'divx',
|
||||||
|
|
|
@ -37,6 +37,7 @@ from sickbeard import encodingKludge as ek
|
||||||
|
|
||||||
from subprocess import check_output, PIPE, Popen
|
from subprocess import check_output, PIPE, Popen
|
||||||
|
|
||||||
|
|
||||||
class CheckVersion():
|
class CheckVersion():
|
||||||
"""
|
"""
|
||||||
Version check class meant to run as a thread object with the sr scheduler.
|
Version check class meant to run as a thread object with the sr scheduler.
|
||||||
|
@ -115,7 +116,11 @@ class CheckVersion():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.updater.need_update() or self.updater.branch != sickbeard.BRANCH:
|
# update branch with current config branch value
|
||||||
|
self.updater.branch == sickbeard.BRANCH
|
||||||
|
|
||||||
|
# check for updates
|
||||||
|
if self.updater.need_update():
|
||||||
return self.updater.update()
|
return self.updater.update()
|
||||||
|
|
||||||
def list_remote_branches(self):
|
def list_remote_branches(self):
|
||||||
|
@ -124,6 +129,7 @@ class CheckVersion():
|
||||||
def get_branch(self):
|
def get_branch(self):
|
||||||
return self.updater.branch
|
return self.updater.branch
|
||||||
|
|
||||||
|
|
||||||
class UpdateManager():
|
class UpdateManager():
|
||||||
def get_github_repo_user(self):
|
def get_github_repo_user(self):
|
||||||
return 'echel0n'
|
return 'echel0n'
|
||||||
|
@ -134,6 +140,7 @@ class UpdateManager():
|
||||||
def get_update_url(self):
|
def get_update_url(self):
|
||||||
return sickbeard.WEB_ROOT + "/home/update/?pid=" + str(sickbeard.PID)
|
return sickbeard.WEB_ROOT + "/home/update/?pid=" + str(sickbeard.PID)
|
||||||
|
|
||||||
|
|
||||||
class WindowsUpdateManager(UpdateManager):
|
class WindowsUpdateManager(UpdateManager):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.github_repo_user = self.get_github_repo_user()
|
self.github_repo_user = self.get_github_repo_user()
|
||||||
|
@ -189,11 +196,14 @@ class WindowsUpdateManager(UpdateManager):
|
||||||
return int(match.group(1))
|
return int(match.group(1))
|
||||||
|
|
||||||
def need_update(self):
|
def need_update(self):
|
||||||
|
if self.branch != self._find_installed_branch():
|
||||||
|
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
|
||||||
|
return True
|
||||||
|
|
||||||
self._cur_version = self._find_installed_version()
|
self._cur_version = self._find_installed_version()
|
||||||
self._newest_version = self._find_newest_version()
|
self._newest_version = self._find_newest_version()
|
||||||
|
|
||||||
logger.log(u"newest version: " + repr(self._newest_version), logger.DEBUG)
|
logger.log(u"newest version: " + repr(self._newest_version), logger.DEBUG)
|
||||||
|
|
||||||
if self._newest_version and self._newest_version > self._cur_version:
|
if self._newest_version and self._newest_version > self._cur_version:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -269,7 +279,7 @@ class WindowsUpdateManager(UpdateManager):
|
||||||
new_update_path = os.path.join(sickbeard.PROG_DIR, u'updater.exe')
|
new_update_path = os.path.join(sickbeard.PROG_DIR, u'updater.exe')
|
||||||
logger.log(u"Copying new update.exe file from " + old_update_path + " to " + new_update_path)
|
logger.log(u"Copying new update.exe file from " + old_update_path + " to " + new_update_path)
|
||||||
shutil.move(old_update_path, new_update_path)
|
shutil.move(old_update_path, new_update_path)
|
||||||
|
|
||||||
# Notify update successful
|
# Notify update successful
|
||||||
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
|
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
|
||||||
|
|
||||||
|
@ -282,6 +292,7 @@ class WindowsUpdateManager(UpdateManager):
|
||||||
def list_remote_branches(self):
|
def list_remote_branches(self):
|
||||||
return ['windows_binaries']
|
return ['windows_binaries']
|
||||||
|
|
||||||
|
|
||||||
class GitUpdateManager(UpdateManager):
|
class GitUpdateManager(UpdateManager):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._git_path = self._find_working_git()
|
self._git_path = self._find_working_git()
|
||||||
|
@ -500,8 +511,12 @@ class GitUpdateManager(UpdateManager):
|
||||||
sickbeard.NEWEST_VERSION_STRING = newest_text
|
sickbeard.NEWEST_VERSION_STRING = newest_text
|
||||||
|
|
||||||
def need_update(self):
|
def need_update(self):
|
||||||
self._find_installed_version()
|
|
||||||
|
|
||||||
|
if self.branch != self._find_installed_branch():
|
||||||
|
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
|
||||||
|
return True
|
||||||
|
|
||||||
|
self._find_installed_version()
|
||||||
if not self._cur_commit_hash:
|
if not self._cur_commit_hash:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
@ -522,7 +537,7 @@ class GitUpdateManager(UpdateManager):
|
||||||
on the call's success.
|
on the call's success.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if sickbeard.BRANCH == self._find_installed_branch():
|
if self.branch == self._find_installed_branch():
|
||||||
output, err, exit_status = self._run_git(self._git_path, 'pull -f origin ' + self.branch) # @UnusedVariable
|
output, err, exit_status = self._run_git(self._git_path, 'pull -f origin ' + self.branch) # @UnusedVariable
|
||||||
else:
|
else:
|
||||||
output, err, exit_status = self._run_git(self._git_path, 'checkout -f ' + self.branch) # @UnusedVariable
|
output, err, exit_status = self._run_git(self._git_path, 'checkout -f ' + self.branch) # @UnusedVariable
|
||||||
|
@ -541,6 +556,7 @@ class GitUpdateManager(UpdateManager):
|
||||||
return re.findall('\S+\Wrefs/heads/(.*)', branches)
|
return re.findall('\S+\Wrefs/heads/(.*)', branches)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
class SourceUpdateManager(UpdateManager):
|
class SourceUpdateManager(UpdateManager):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.github_repo_user = self.get_github_repo_user()
|
self.github_repo_user = self.get_github_repo_user()
|
||||||
|
@ -570,6 +586,10 @@ class SourceUpdateManager(UpdateManager):
|
||||||
|
|
||||||
def need_update(self):
|
def need_update(self):
|
||||||
|
|
||||||
|
if self.branch != self._find_installed_branch():
|
||||||
|
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
|
||||||
|
return True
|
||||||
|
|
||||||
self._find_installed_version()
|
self._find_installed_version()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -710,8 +730,8 @@ class SourceUpdateManager(UpdateManager):
|
||||||
old_path = os.path.join(content_dir, dirname, curfile)
|
old_path = os.path.join(content_dir, dirname, curfile)
|
||||||
new_path = os.path.join(sickbeard.PROG_DIR, dirname, curfile)
|
new_path = os.path.join(sickbeard.PROG_DIR, dirname, curfile)
|
||||||
|
|
||||||
#Avoid DLL access problem on WIN32/64
|
# Avoid DLL access problem on WIN32/64
|
||||||
#These files needing to be updated manually
|
# These files needing to be updated manually
|
||||||
#or find a way to kill the access from memory
|
#or find a way to kill the access from memory
|
||||||
if curfile in ('unrar.dll', 'unrar64.dll'):
|
if curfile in ('unrar.dll', 'unrar64.dll'):
|
||||||
try:
|
try:
|
||||||
|
@ -733,7 +753,7 @@ class SourceUpdateManager(UpdateManager):
|
||||||
|
|
||||||
# Notify update successful
|
# Notify update successful
|
||||||
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
|
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def list_remote_branches(self):
|
def list_remote_branches(self):
|
||||||
|
|
Loading…
Reference in a new issue