Browse Source

Set correct mtime of zip file

Since we are writing the zip file with python, the original mdate, on
which is_zip_uptodate() relies gets lost. Therefore overwrite it with
value of "Last-Modified" HTTP header
develop
Jonathan Golder 6 years ago
parent
commit
b14c0fa3a7
  1. 10
      euroexange/euroexange.py

10
euroexange/euroexange.py

@ -24,6 +24,7 @@ import datetime
import zipfile
import shlex
import subprocess
import email.utils
import pywikibot
@ -167,6 +168,15 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
shutil.copyfileobj(response, out_file)
# Extract original change date from http header
# We need to set it later, since we write a new file
mdate = email.utils.parsedate_to_datetime(
response.info()["Last-Modified"])
# Set ctime to value from http header
os.utime( os.path.join(self.wdir, type(self).zip_file),
(datetime.datetime.now().timestamp(), mdate.timestamp()) )
def extract_csv( self ):
"""
Extract csv file from zip archive

Loading…
Cancel
Save