pyappify 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyappify-1.0.0 → pyappify-1.0.2}/PKG-INFO +1 -1
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify/__init__.py +24 -3
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/PKG-INFO +1 -1
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/SOURCES.txt +2 -1
- {pyappify-1.0.0 → pyappify-1.0.2}/pyproject.toml +1 -1
- pyappify-1.0.2/tests/TestVersion.py +33 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify/main.py +0 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/dependency_links.txt +0 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/entry_points.txt +0 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/requires.txt +0 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/pyappify.egg-info/top_level.txt +0 -0
- {pyappify-1.0.0 → pyappify-1.0.2}/setup.cfg +0 -0
|
@@ -74,7 +74,7 @@ def hide_pyappify():
|
|
|
74
74
|
pass
|
|
75
75
|
|
|
76
76
|
def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None):
|
|
77
|
-
if not pyappify_upgradeable or (to_version
|
|
77
|
+
if not pyappify_upgradeable or not is_greater_version(to_version, pyappify_version):
|
|
78
78
|
if logger:
|
|
79
79
|
logger.info(f"pyappify no need to upgrade {pyappify_upgradeable} {to_version} {executable_sha256} {executable_zip_urls}")
|
|
80
80
|
return
|
|
@@ -137,7 +137,7 @@ def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None)
|
|
|
137
137
|
for byte_block in iter(lambda: f.read(4096), b""):
|
|
138
138
|
sha256_hash.update(byte_block)
|
|
139
139
|
|
|
140
|
-
if sha256_hash.hexdigest() != executable_sha256:
|
|
140
|
+
if executable_sha256 and sha256_hash.hexdigest() != executable_sha256:
|
|
141
141
|
if logger:
|
|
142
142
|
logger.error("pyappify SHA256 checksum mismatch.")
|
|
143
143
|
return
|
|
@@ -155,4 +155,25 @@ def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None)
|
|
|
155
155
|
|
|
156
156
|
thread = threading.Thread(target=_do_upgrade)
|
|
157
157
|
thread.daemon = True
|
|
158
|
-
thread.start()
|
|
158
|
+
thread.start()
|
|
159
|
+
|
|
160
|
+
def is_greater_version(version1, version2):
|
|
161
|
+
"""
|
|
162
|
+
Compares two semantic version strings.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
version1 (str): The first version string.
|
|
166
|
+
version2 (str): The second version string.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
bool: True if version1 is strictly greater than version2,
|
|
170
|
+
False otherwise or if parsing fails.
|
|
171
|
+
"""
|
|
172
|
+
try:
|
|
173
|
+
version1 = version1.lstrip('v')
|
|
174
|
+
version2 = version2.lstrip('v')
|
|
175
|
+
v1_parts = [int(p) for p in version1.split('.')]
|
|
176
|
+
v2_parts = [int(p) for p in version2.split('.')]
|
|
177
|
+
return v1_parts > v2_parts
|
|
178
|
+
except (ValueError, AttributeError):
|
|
179
|
+
return False
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# filename: test_pyappify.is_greater_version.py
|
|
2
|
+
import unittest
|
|
3
|
+
import pyappify
|
|
4
|
+
|
|
5
|
+
class TestIsGreaterVersion(unittest.TestCase):
|
|
6
|
+
|
|
7
|
+
def test_version1_is_greater(self):
|
|
8
|
+
self.assertTrue(pyappify.is_greater_version("2.0.0", "1.9.9"))
|
|
9
|
+
self.assertTrue(pyappify.is_greater_version("1.2.0", "v1.1.9"))
|
|
10
|
+
self.assertTrue(pyappify.is_greater_version("v1.1.2", "1.1.1"))
|
|
11
|
+
self.assertTrue(pyappify.is_greater_version("1.1.0", "1.1"))
|
|
12
|
+
self.assertTrue(pyappify.is_greater_version("v10.0.0", "9.0.0"))
|
|
13
|
+
|
|
14
|
+
def test_version1_is_not_greater(self):
|
|
15
|
+
self.assertFalse(pyappify.is_greater_version("v1.0.0", "2.0.0"))
|
|
16
|
+
self.assertFalse(pyappify.is_greater_version("1.1.0", "v1.2.0"))
|
|
17
|
+
self.assertFalse(pyappify.is_greater_version("1.1.1", "1.1.2"))
|
|
18
|
+
self.assertFalse(pyappify.is_greater_version("1.1", "1.1.0"))
|
|
19
|
+
|
|
20
|
+
def test_versions_are_equal(self):
|
|
21
|
+
self.assertFalse(pyappify.is_greater_version("qwer", "1.0.0"))
|
|
22
|
+
self.assertFalse(pyappify.is_greater_version("1.2.3", "1.2.3"))
|
|
23
|
+
|
|
24
|
+
def test_invalid_or_edge_cases(self):
|
|
25
|
+
self.assertFalse(pyappify.is_greater_version(None, "1.0.0"))
|
|
26
|
+
self.assertFalse(pyappify.is_greater_version("1.0.0", None))
|
|
27
|
+
self.assertFalse(pyappify.is_greater_version(None, None))
|
|
28
|
+
self.assertFalse(pyappify.is_greater_version("v1.a.0", "1.0.0"))
|
|
29
|
+
self.assertFalse(pyappify.is_greater_version("1.0.0", "invalid"))
|
|
30
|
+
self.assertFalse(pyappify.is_greater_version("", "1.0.0"))
|
|
31
|
+
|
|
32
|
+
if __name__ == '__main__':
|
|
33
|
+
unittest.main(argv=['first-arg-is-ignored'], exit=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|