I cannot set ctime/mtime on my file within python. First I get the orginal timestamp of the file through ftp
The only thing I want is to keep the original timestamp
From the os.utime() documentation:
Otherwise, times must be a 2-tuple of numbers, of the form
(atime, mtime)
which is used to set the access and modified times, respectively.
You are not giving it a tuple. In this case, just set both atime
and mtime
to the same value:
os.utime(fileName, (orgTime, orgTime))
fileName
is a string, so fileName.close()
won't work (you'll get an attribute error), just drop that line.
orgTime
must be an integer; you are giving it a time tuple; convert it to a timestamp in seconds since the epoch with time.mktime():
settime = time.mktime(ftime.timetuple())