summaryrefslogtreecommitdiff
path: root/ick-html
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-10-27 19:54:00 +0200
committerLars Wirzenius <liw@liw.fi>2015-10-27 19:54:00 +0200
commit68335c53d0360faacf3ce1c326a04345da2bcf33 (patch)
treee43b903ac56b56f329b998e4e7aef8f46b45c445 /ick-html
parentc96b7b8e73b07ffbd933bec303121aa0c62130b2 (diff)
downloadick-68335c53d0360faacf3ce1c326a04345da2bcf33.tar.gz
Keep mtimes of files consistent
Diffstat (limited to 'ick-html')
-rwxr-xr-xick-html18
1 files changed, 14 insertions, 4 deletions
diff --git a/ick-html b/ick-html
index 08510c6..2f26d51 100755
--- a/ick-html
+++ b/ick-html
@@ -79,20 +79,21 @@ class IckHTML(cliapp.Application):
for build in project.builds:
build_dir = os.path.join(
html_dir, project.name, str(build.build_number))
- os.makedirs(build_dir)
+ if not os.path.exists(build_dir):
+ os.makedirs(build_dir)
self.copy_build_log(build, build_dir)
self.copy_build_artifacts(statedir, project, build, build_dir)
def copy_build_log(self, build, build_dir):
orig = build.get_build_log_filename()
target = os.path.join(build_dir, 'build_log.txt')
- shutil.copy(orig, target)
+ shutil.copy2(orig, target)
def copy_build_artifacts(self, statedir, project, build, build_dir):
artifacts = build.get_artifacts_directory()
target = os.path.join(build_dir, 'build_log.txt')
for artifact in glob.glob(os.path.join(artifacts, '*')):
- shutil.copy(artifact, build_dir)
+ shutil.copy2(artifact, build_dir)
def create_project_html(self, statedir, project, env, html_dir):
@@ -101,9 +102,18 @@ class IckHTML(cliapp.Application):
}
template = env.get_template('project.j2')
- with open(os.path.join(html_dir, '%s.html' % project.name), 'w') as f:
+ html_file = os.path.join(html_dir, '%s.html' % project.name)
+ with open(html_file, 'w') as f:
f.write(template.render(**vars))
+ self.copy_mtime(
+ statedir.get_project_state_path(project.name),
+ html_file)
+
+ def copy_mtime(self, orig_filename, dest_filename):
+ st = os.lstat(orig_filename)
+ os.utime(dest_filename, (long(st.st_atime), long(st.st_mtime)))
+
if __name__ == '__main__':
IckHTML().run()