From 4f9432eda306baabc9c7830c7536d6872acbae6b Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Fri, 16 Nov 2018 20:04:30 +0100 Subject: [PATCH 1/5] Buildbot changes --- .../source-python/core/command/__init__.py | 6 ++++++ .../packages/source-python/core/update.py | 18 ++++++++++-------- .../packages/source-python/core/version.py | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/addons/source-python/packages/source-python/core/command/__init__.py b/addons/source-python/packages/source-python/core/command/__init__.py index c26541901..71f6d6b8d 100644 --- a/addons/source-python/packages/source-python/core/command/__init__.py +++ b/addons/source-python/packages/source-python/core/command/__init__.py @@ -24,6 +24,7 @@ from core import SOURCE_ENGINE_BRANCH from core.update import do_full_update from core.version import get_last_successful_build_number +from core.version import is_download_page_updating from core.version import is_unversioned from core.version import VERSION from core.version import GIT_COMMIT @@ -166,6 +167,11 @@ def update_sp(info): """Update Source.Python to the latest version. A restart of the server is required. """ + if is_download_page_updating(): + core_command_logger.log_message( + 'Download page is currently being updated. Please try again later.') + return + if not is_unversioned() and VERSION >= get_last_successful_build_number(): core_command_logger.log_message('No new version available.') return diff --git a/addons/source-python/packages/source-python/core/update.py b/addons/source-python/packages/source-python/core/update.py index c9da3f9a3..1a3ed8f42 100644 --- a/addons/source-python/packages/source-python/core/update.py +++ b/addons/source-python/packages/source-python/core/update.py @@ -64,10 +64,14 @@ LOADER_UPDATE_FILE = UPDATE_PATH / 'addons' / f'source-python.{BINARY_EXT}' VDF_UPDATE_FILE = UPDATE_PATH / 'addons' / 'source-python.vdf' -CHECKSUM_URL = 'http://data.sourcepython.com/checksum.txt' -DATA_URL = 'http://data.sourcepython.com/source-python-data.zip' -ARTIFACTS_URL = 'http://builds.sourcepython.com/job/Source.Python/lastSuccessfulBuild/api/json?tree=artifacts[relativePath]' -BASE_DOWNLOAD_URL = 'http://builds.sourcepython.com/job/Source.Python/lastSuccessfulBuild/artifact/' +BASE_DATA_URL = 'http://data.sourcepython.com' +CHECKSUM_URL = f'{BASE_DATA_URL}/checksum.txt' +DATA_URL = f'{BASE_DATA_URL}/source-python-data.zip' + +BASE_DOWNLOAD_URL = 'http://downloads.sourcepython.com' +ARTIFACTS_URL = f'{BASE_DOWNLOAD_URL}/release/artifacts.txt' +UPDATING_URL = f'{BASE_DOWNLOAD_URL}/release/artifacts.txt' + DEFAULT_TIMEOUT = 3 #: Indicates, whether an update is in progress (stage 1 has been applied). @@ -140,9 +144,7 @@ def get_build_artifacts(timeout=DEFAULT_TIMEOUT): """ update_logger.log_debug('Getting artifacts...') with urlopen(ARTIFACTS_URL, timeout=timeout) as url: - data = json.loads(url.read()) - for d in data['artifacts']: - yield d['relativePath'] + return url.read().decode('utf-8').split('\n') def get_download_url(game=SOURCE_ENGINE_BRANCH, timeout=DEFAULT_TIMEOUT): """Get the latest Source.Python download URL for a specific game. @@ -157,7 +159,7 @@ def get_download_url(game=SOURCE_ENGINE_BRANCH, timeout=DEFAULT_TIMEOUT): """ for relative_path in get_build_artifacts(timeout): if f'-{game}-' in relative_path: - return BASE_DOWNLOAD_URL + relative_path + return f'{BASE_DOWNLOAD_URL}/{relative_path}' raise ValueError(f'Unable to find a download URL for game "{game}".') diff --git a/addons/source-python/packages/source-python/core/version.py b/addons/source-python/packages/source-python/core/version.py index 251acd2a5..3df93ba6e 100644 --- a/addons/source-python/packages/source-python/core/version.py +++ b/addons/source-python/packages/source-python/core/version.py @@ -18,6 +18,7 @@ __all__ = ('VERSION', 'GIT_COMMIT', 'get_last_successful_build_number', + 'is_download_page_updating', 'is_unversioned', ) @@ -32,8 +33,9 @@ GIT_COMMIT = None LAST_SUCCESSFUL_BUILD_NUMBER_URL = ( - 'http://builds.sourcepython.com/job/Source.Python' + - '/api/xml?xpath=/freeStyleProject/lastSuccessfulBuild/number') + 'http://downloads.sourcepython.com/release/version.txt') + +UPDATING_STATUS_URL = 'http://downloads.sourcepython.com/updating.txt' # ============================================================================= @@ -51,11 +53,19 @@ def get_last_successful_build_number(timeout=3): :param float timeout: Number of seconds that need to pass until a timeout occurs. :rtype: int + :raise urllib.error.HTTPError: + Raised if the download page is currently being updated. """ with urlopen(LAST_SUCCESSFUL_BUILD_NUMBER_URL, timeout=timeout) as url: - # Remove the tags, so we just have the build number - return int(url.read()[8:-9]) + return int(url.read().decode('utf-8')) + +def is_download_page_updating(timeout=3): + """Return ``True`` if the download page is currently being updated. + :rtype: bool + """ + with urlopen(UPDATING_STATUS_URL, timeout=timeout) as url: + return url.read().decode('utf-8') == '1' def is_unversioned(): """Return ``True`` if this Source.Python installation has no version. From fe70b665c87a63ba8e933c9ebf9f644a48b097b1 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Fri, 16 Nov 2018 20:09:27 +0100 Subject: [PATCH 2/5] Fixed a CP mistake --- addons/source-python/packages/source-python/core/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/packages/source-python/core/update.py b/addons/source-python/packages/source-python/core/update.py index 1a3ed8f42..8b8965480 100644 --- a/addons/source-python/packages/source-python/core/update.py +++ b/addons/source-python/packages/source-python/core/update.py @@ -70,7 +70,7 @@ BASE_DOWNLOAD_URL = 'http://downloads.sourcepython.com' ARTIFACTS_URL = f'{BASE_DOWNLOAD_URL}/release/artifacts.txt' -UPDATING_URL = f'{BASE_DOWNLOAD_URL}/release/artifacts.txt' +UPDATING_URL = f'{BASE_DOWNLOAD_URL}/updating.txt' DEFAULT_TIMEOUT = 3 From 9d8366271fc47a294bf37674a4f049ca3728c1c7 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Nov 2018 20:12:27 +0100 Subject: [PATCH 3/5] Removed updating status --- .../packages/source-python/core/command/__init__.py | 6 ------ .../packages/source-python/core/version.py | 13 ------------- 2 files changed, 19 deletions(-) diff --git a/addons/source-python/packages/source-python/core/command/__init__.py b/addons/source-python/packages/source-python/core/command/__init__.py index 71f6d6b8d..c26541901 100644 --- a/addons/source-python/packages/source-python/core/command/__init__.py +++ b/addons/source-python/packages/source-python/core/command/__init__.py @@ -24,7 +24,6 @@ from core import SOURCE_ENGINE_BRANCH from core.update import do_full_update from core.version import get_last_successful_build_number -from core.version import is_download_page_updating from core.version import is_unversioned from core.version import VERSION from core.version import GIT_COMMIT @@ -167,11 +166,6 @@ def update_sp(info): """Update Source.Python to the latest version. A restart of the server is required. """ - if is_download_page_updating(): - core_command_logger.log_message( - 'Download page is currently being updated. Please try again later.') - return - if not is_unversioned() and VERSION >= get_last_successful_build_number(): core_command_logger.log_message('No new version available.') return diff --git a/addons/source-python/packages/source-python/core/version.py b/addons/source-python/packages/source-python/core/version.py index 3df93ba6e..e805a7a1c 100644 --- a/addons/source-python/packages/source-python/core/version.py +++ b/addons/source-python/packages/source-python/core/version.py @@ -18,7 +18,6 @@ __all__ = ('VERSION', 'GIT_COMMIT', 'get_last_successful_build_number', - 'is_download_page_updating', 'is_unversioned', ) @@ -35,8 +34,6 @@ LAST_SUCCESSFUL_BUILD_NUMBER_URL = ( 'http://downloads.sourcepython.com/release/version.txt') -UPDATING_STATUS_URL = 'http://downloads.sourcepython.com/updating.txt' - # ============================================================================= # >> GLOBAL VARIABLES @@ -53,20 +50,10 @@ def get_last_successful_build_number(timeout=3): :param float timeout: Number of seconds that need to pass until a timeout occurs. :rtype: int - :raise urllib.error.HTTPError: - Raised if the download page is currently being updated. """ with urlopen(LAST_SUCCESSFUL_BUILD_NUMBER_URL, timeout=timeout) as url: return int(url.read().decode('utf-8')) -def is_download_page_updating(timeout=3): - """Return ``True`` if the download page is currently being updated. - - :rtype: bool - """ - with urlopen(UPDATING_STATUS_URL, timeout=timeout) as url: - return url.read().decode('utf-8') == '1' - def is_unversioned(): """Return ``True`` if this Source.Python installation has no version. From 532102482f31debdf9ddd7c1132aa584d65e6f3b Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Nov 2018 21:05:27 +0100 Subject: [PATCH 4/5] Fixed URL --- addons/source-python/packages/source-python/core/update.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/source-python/packages/source-python/core/update.py b/addons/source-python/packages/source-python/core/update.py index 8b8965480..2dc86fe91 100644 --- a/addons/source-python/packages/source-python/core/update.py +++ b/addons/source-python/packages/source-python/core/update.py @@ -69,8 +69,7 @@ DATA_URL = f'{BASE_DATA_URL}/source-python-data.zip' BASE_DOWNLOAD_URL = 'http://downloads.sourcepython.com' -ARTIFACTS_URL = f'{BASE_DOWNLOAD_URL}/release/artifacts.txt' -UPDATING_URL = f'{BASE_DOWNLOAD_URL}/updating.txt' +ARTIFACTS_URL = f'{BASE_DOWNLOAD_URL}/artifacts.txt' DEFAULT_TIMEOUT = 3 From c50960dd9620030f8e09c9abef864d9633f5f3ba Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Nov 2018 21:19:41 +0100 Subject: [PATCH 5/5] Fixed another URL --- addons/source-python/packages/source-python/core/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/packages/source-python/core/version.py b/addons/source-python/packages/source-python/core/version.py index e805a7a1c..a2ff96b09 100644 --- a/addons/source-python/packages/source-python/core/version.py +++ b/addons/source-python/packages/source-python/core/version.py @@ -32,7 +32,7 @@ GIT_COMMIT = None LAST_SUCCESSFUL_BUILD_NUMBER_URL = ( - 'http://downloads.sourcepython.com/release/version.txt') + 'http://downloads.sourcepython.com/version.txt') # =============================================================================