Point source updater to new url
This commit is contained in:
@@ -15,6 +15,7 @@ import tarfile
|
||||
import time
|
||||
import traceback
|
||||
import version
|
||||
import zipfile
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -253,6 +254,8 @@ class GitUpdater(BaseUpdater):
|
||||
|
||||
class SourceUpdater(BaseUpdater):
|
||||
|
||||
update_url = 'https://couchpota.to/updates/source.php?repo=%s&name=%s&branch=%s'
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# Create version file in cache
|
||||
@@ -260,14 +263,17 @@ class SourceUpdater(BaseUpdater):
|
||||
if not os.path.isfile(self.version_file):
|
||||
self.createFile(self.version_file, json.dumps(self.latestCommit()))
|
||||
|
||||
addEvent('app.load', self.doUpdate)
|
||||
|
||||
def doUpdate(self):
|
||||
|
||||
try:
|
||||
url = 'https://github.com/%s/%s/tarball/%s' % (self.repo_user, self.repo_name, self.branch)
|
||||
destination = os.path.join(Env.get('cache_dir'), self.update_version.get('hash') + '.tar.gz')
|
||||
extracted_path = os.path.join(Env.get('cache_dir'), 'temp_updater')
|
||||
url = self.update_url % (self.repo_user, self.repo_name, self.branch)
|
||||
download_data = json.loads(self.urlopen(url))
|
||||
destination = os.path.join(Env.get('cache_dir'), self.update_version.get('hash')) + '.' + download_data.get('type')
|
||||
|
||||
destination = fireEvent('file.download', url = url, dest = destination, single = True)
|
||||
extracted_path = os.path.join(Env.get('cache_dir'), 'temp_updater')
|
||||
destination = fireEvent('file.download', url = download_data.get('url'), dest = destination, single = True)
|
||||
|
||||
# Cleanup leftover from last time
|
||||
if os.path.isdir(extracted_path):
|
||||
@@ -275,9 +281,14 @@ class SourceUpdater(BaseUpdater):
|
||||
self.makeDir(extracted_path)
|
||||
|
||||
# Extract
|
||||
tar = tarfile.open(destination)
|
||||
tar.extractall(path = extracted_path)
|
||||
tar.close()
|
||||
if download_data.get('type') == 'zip':
|
||||
zip = zipfile.ZipFile(destination)
|
||||
zip.extractall(extracted_path)
|
||||
else:
|
||||
tar = tarfile.open(destination)
|
||||
tar.extractall(path = extracted_path)
|
||||
tar.close()
|
||||
|
||||
os.remove(destination)
|
||||
|
||||
if self.replaceWith(os.path.join(extracted_path, os.listdir(extracted_path)[0])):
|
||||
|
||||
Reference in New Issue
Block a user