Small enhancements to mtime handling
* Use directories mtime (so deleted or renamed files are taken into account) * Set the tarfile mtime close to the version
This commit is contained in:
parent
de1326fcb2
commit
863a32b96e
2 changed files with 8 additions and 3 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from time import mktime, strptime
|
||||||
import tarfile
|
import tarfile
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
@ -110,6 +111,8 @@ class WeboobRepos(ReplApplication):
|
||||||
print 'Create archive for %s' % name
|
print 'Create archive for %s' % name
|
||||||
with closing(tarfile.open(tarname, 'w:gz')) as tar:
|
with closing(tarfile.open(tarname, 'w:gz')) as tar:
|
||||||
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
||||||
|
tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M'))
|
||||||
|
os.utime(tarname, (tar_mtime, tar_mtime))
|
||||||
|
|
||||||
# Copy icon.
|
# Copy icon.
|
||||||
icon_path = os.path.join(module_path, 'favicon.png')
|
icon_path = os.path.join(module_path, 'favicon.png')
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ class Repository(object):
|
||||||
try:
|
try:
|
||||||
module = Module(__import__(name, fromlist=[str(name)]))
|
module = Module(__import__(name, fromlist=[str(name)]))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print 'ERROR: %s' % e
|
print >>sys.stderr, 'ERROR: %s' % e
|
||||||
else:
|
else:
|
||||||
m = ModuleInfo(module.name)
|
m = ModuleInfo(module.name)
|
||||||
m.version = self.get_tree_mtime(module_path)
|
m.version = self.get_tree_mtime(module_path)
|
||||||
|
|
@ -227,8 +227,10 @@ class Repository(object):
|
||||||
self.save(filename)
|
self.save(filename)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_tree_mtime(path):
|
def get_tree_mtime(path, include_root=False):
|
||||||
mtime = 0
|
mtime = 0
|
||||||
|
if include_root:
|
||||||
|
mtime = int(datetime.fromtimestamp(os.path.getmtime(path)).strftime('%Y%m%d%H%M'))
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith('.pyc'):
|
if f.endswith('.pyc'):
|
||||||
|
|
@ -453,7 +455,7 @@ class Repositories(object):
|
||||||
try:
|
try:
|
||||||
repository.retrieve_index(dest_path)
|
repository.retrieve_index(dest_path)
|
||||||
except RepositoryUnavailable, e:
|
except RepositoryUnavailable, e:
|
||||||
print 'Error: %s' % e
|
print >>sys.stderr, 'Error: %s' % e
|
||||||
else:
|
else:
|
||||||
self.repositories.append(repository)
|
self.repositories.append(repository)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue