Changeset 77bf72ffc703e0c38bd368f20c9eb99ac02ff316
- Timestamp:
- 11/18/10 17:27:03 (18 months ago)
- Children:
- 36ddc5be7316607eb8f7801ba2f59b4dd331d05c
- Parents:
- 6e701d84a43b80d129ed34ee062f6f6abe14a7b7
- git-committer:
- Luper Rouch <luper.rouch@…> (11/18/10 17:27:03)
- Location:
- pyflu
- Files:
-
- 19 added
- 6 edited
-
pyflu/__init__.py (modified) (1 diff)
-
pyflu/tests/test_update/__init__.py (modified) (3 diffs)
-
pyflu/tests/test_update/data/patches/files/patch-0.1-0.1_10.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-0.1_10-0.1_15.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-0.1_15-0.3.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-0.5-0.6.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-1.0-1.0.2.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-1.0.2-1.0.2_256.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-1.0.2_256-1.1.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/files/patch-2.0pre-2.0pre_128.tar.bz2 (added)
-
pyflu/tests/test_update/data/patches/index.html (added)
-
pyflu/tests/test_update/data/patches/versions/1.0.2/a (added)
-
pyflu/tests/test_update/data/patches/versions/1.0.2_256/a (added)
-
pyflu/tests/test_update/data/patches/versions/1.0.2_256/b (added)
-
pyflu/tests/test_update/data/patches/versions/1.0/a (added)
-
pyflu/tests/test_update/data/patches/versions/1.1/a (added)
-
pyflu/tests/test_update/data/tmp/test_qt_work_dir/target/a (added)
-
pyflu/tests/test_update/data/tmp/test_qt_work_dir/target/b (added)
-
pyflu/tests/test_update/test_qt.py (added)
-
pyflu/update/__init__.py (modified) (2 diffs)
-
pyflu/update/qt.py (added)
-
pyflu/update/remote.py (modified) (2 diffs)
-
pyflu/update/signals.py (added)
-
pyflu/update/version.py (modified) (3 diffs)
-
setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyflu/pyflu/__init__.py
rd784e4c r77bf72f 5 5 6 6 def version(): 7 return "0. 6.7"7 return "0.7" 8 8 -
pyflu/pyflu/tests/test_update/__init__.py
rfd03e3e r77bf72f 1 1 import os 2 from nose.tools import assert_true 2 3 from os.path import dirname, join, isdir, isfile 3 4 from pyflu.update import patch, diff, sub_path, control_sum, \ 4 5 InvalidOriginalFile, InvalidResultingFile, IncompatiblePatchFormat, \ 5 6 archive_path 7 from pyflu.update.version import Version 6 8 import shutil 7 9 … … 18 20 19 21 20 def one_way_compare(d1, d2, visited): 22 def one_way_compare(d1, d2, visited=None): 23 """ 24 Compare directory *d2* against *d1* for removal and changes. 25 26 Raise an error if a file present in *d1* is not found or is different from 27 the one found in *d2*, but ignores files present in *d2* and not in *d1*. 28 """ 29 if visited is None: 30 visited = {} 21 31 for base, dirs, files in os.walk(d1): 22 32 sub_dir = sub_path(base, d1) … … 91 101 92 102 93 def teardown(): 103 def test_version(): 104 version_groups = [[ 105 "1.0", 106 "1.0a", 107 "1.0beta", 108 "1.0pre", 109 "1.0pre2", 110 "1.1", 111 "1.1.2", 112 "1.1.2_3", 113 "1.1.2_10", 114 ], 115 [ 116 "r1-flap" 117 "r1234" 118 "r12345-final" 119 ]] 120 for group in version_groups: 121 prev = None 122 for version in group: 123 obj = Version(version) 124 if prev is not None: 125 assert_true(obj > prev) 126 prev = obj 127 128 129 def setup(): 94 130 if isdir(tmp_dir): 95 131 shutil.rmtree(tmp_dir) -
pyflu/pyflu/update/__init__.py
r231ef65 r77bf72f 2 2 import os 3 3 import hashlib 4 from os.path import join, commonprefix, isfile, isdir, dirname 4 from os.path import join, commonprefix, isfile, isdir, dirname, basename 5 5 from pyflu.path import sub_path 6 6 import bsdiff … … 343 343 344 344 345 if __name__ == "__main__": 346 if len(sys.argv) != 5: 347 usage() 345 def makepatch(): 346 """ 347 Entry points for the create patch command line script. 348 """ 349 try: 350 olddir, newdir, patchfile = sys.argv[1:] 351 except: 352 print >>sys.stderr, ("usage: %s olddir newdir patchfile" 353 % basename(sys.argv[0])) 348 354 sys.exit(1) 349 if sys.argv[1] == "diff": 350 diff(*sys.argv[2:]) 351 elif sys.argv[1] == "patch": 352 patch(*sys.argv[2:]) 353 else: 354 usage() 355 sys.exit(1) 355 diff(patchfile, olddir, newdir) 356 sys.exit(0) -
pyflu/pyflu/update/remote.py
rf0cace8 r77bf72f 3 3 from lxml import etree 4 4 from os.path import join, basename 5 from urlparse import urljoin 5 6 from pyflu.update.version import Version 6 from urlparse import urljoin7 from pyflu.odict import odict 7 8 8 9 9 def patches_chain(url, updates_pattern):10 def find_patches_groups(url, updates_pattern): 10 11 """ 11 Retrieves the list of _consecutive_ patches on an HTML page.12 Retrieves groups of _consecutive_ patches in an HTML page. 12 13 13 The links are parsed from the HTML page found at ``url``. Links not14 matching the regular expression ``updates_pattern``are filtered.15 ``updates_pattern``must define two groups named 'from' and 'to', isolating16 the version snumbers of the update.14 The links are parsed from the HTML page found at *url*. Links not 15 matching the regular expression *updates_pattern* are filtered. 16 *updates_pattern* must define two groups named 'from' and 'to', isolating 17 the version numbers of the update. 17 18 18 Returns a list of tuples containing 'from' and 'to' versions and theupdate19 file URL.20 21 A ValueError is raised if the chain of versions is not continuous.19 Returns an :class:`~pyflu.odict.odict` object, containing lists of update 20 chains (updates that can be applied successively to update from a version 21 to another), indexed by the first :class:`~pyflu.update.version.Version` 22 object of the chain. 22 23 """ 23 # Make sure the url has a trailing slash 24 if not url.endswith("/"): 25 url += "/" 26 # Get links 24 # Get links from the HTML update page 27 25 parser = etree.HTMLParser() 28 26 doc = etree.parse(urllib2.urlopen(url), parser) … … 38 36 Version(match.group("to")), 39 37 href)) 40 # Verify updates chain continuity38 # Create version groups 41 39 updates.sort(key=lambda x: x[0]) 42 40 last_version = None 43 missing_updates = [] 41 groups = odict() 42 current_group = [] 44 43 for from_version, to_version, url in updates: 45 44 if last_version is not None: 46 45 if from_version != last_version: 47 missing_updates.append((last_version, from_version)) 46 groups[current_group[0][0]] = current_group 47 current_group = [] 48 48 last_version = to_version 49 if missing_updates:50 raise ValueError("missing udpates:\n%s" %51 "\n".join(["%s => %s" % (f, t) for f, t in missing_updates]))52 return updates49 current_group.append((from_version, to_version, url)) 50 if current_group: 51 groups[current_group[0][0]] = current_group 52 return groups -
pyflu/pyflu/update/version.py
r8e8dabb r77bf72f 16 16 1.1 17 17 1.1.2 18 1.1.2_3 19 1.1.2_10 18 20 * snapshot versions, composed by a revision number and an optional branch 19 21 specifier. The branch specifier is ignored in comparisons: … … 34 36 if match: 35 37 self.is_release = True 36 self.release_numbers = [int(n) for n in37 match.group("release").split(".") ]38 self.release_numbers = tuple(int(n) for n in 39 match.group("release").split(".")) 38 40 self.release_suffix = match.group("suffix") 41 if "_" in self.release_suffix: 42 pre, rev = self.release_suffix.rsplit("_", 1) 43 rev = int(rev) 44 else: 45 pre = self.release_suffix 46 rev = 0 47 self.release_suffix = (pre, rev) 39 48 else: 40 49 match = self.snapshot_pattern.match(version_string) … … 75 84 def __str__(self): 76 85 return self.version_string 86 87 def __hash__(self): 88 if self.is_release: 89 return hash((self.release_numbers, self.release_suffix)) 90 return hash(self.snapshot_revision) -
pyflu/setup.py
r3532e9f r77bf72f 31 31 32 32 packages = find_packages(), 33 34 entry_points = { 35 "console_scripts": ["pyflu-makepatch = pyflu.update:makepatch"], 36 }, 33 37 )
Note: See TracChangeset
for help on using the changeset viewer.
