Print "NV Local A timestamp : " + str(os.stat(local_file).st_atime) Print "NV Local M timestamp : " + str(os.stat(local_file).st_mtime) Download skipped"ÄownloadAndSetTimestamp(local_file,fi,nt) If int(nt)=int(os.stat(local_file).st_mtime): #print "Local A timestamp : " + str(os.stat(local_file).st_atime) #print "Local M timestamp : " + str(os.stat(local_file).st_mtime) Print "File " + local_file + " already exists." Local_file = os.path.join(Target_dir,item,fi) Os.makedirs(os.path.join(Target_dir,item)) If not os.path.isdir(os.path.join(Target_dir,item)): Target_bug="Streptococcus_pseudopneumoniae" Print "Connected and Dir list retrieved." Print "-> atime after change : "+ str(os.stat(local_file).st_atime) Print "-> mtime after change : "+ str(os.stat(local_file).st_mtime) Os.utime(local_file,( int(nt), int(nt) )) #set the modification time the same as server for future comparison Print "-> atime before change : " + str(os.stat(local_file).st_atime) Print "-> mtime before change : " + str(os.stat(local_file).st_mtime) import ftplibÄef DownloadAndSetTimestamp(local_file,fi,nt):į.retrbinary("RETR " + fi, lf.write, 8*1024) Thanks in advance for any help in this problem. You should be able to see the new utime table, sorted by SteamID64s, and you should be in it along with your old time. Change the map (ulx map from console, no going on the server yet) and wait until it has finished loading.If you run the code bellow twice it will show the problem in the debug comments as the files in the FTP server didn't change but the timestamps don't match the local ones that were correctly changed. Once you have edited it, save the file and re-upload it to your server. My problem is that as soon as I get out from the subroutine where I change the access and modification times they revert back to the original ones! I don't have anything running in background and I also tested the script on a linux server with the same results To achieve this goal I get the FTP file modification time, convert it to timestamp and then use os.utime to change the access and modification dates of the files downloaded to match the FTP server ones. If they don't match then I download the new copy. Since closing a file flushes the outstanding IO buffer contents, modification time will be updated as a side. Instead, the file is closed a bit later by the garbage collector after your call to os.utime. Without the parentheses, you're effectively not closing the file. I'm trying to develop a script that downloads files from an FTP that match certain criteria but if the file exists and I already have a copy of it on a local dir then I want to check file modification times. You're missing the parentheses in lf.close it should be lf.close (). On most systems, this will set the file's access and modification times to the current time (i.e.I've came across a problem in python 2.7.1 (running on Mac OS X 10.7.5) with the os.utime command Utime $atime, $mtime, Perl 5.8.0, if the first two elements of the list are undef, the utime(2) syscall from your C library is called with a null second argument. For example, this code has the same effect as the Unix touch(1) command when the files already exist and belong to the user running the program: #!/usr/bin/perl The inode change time of each file is set to the current time. Returns the number of files successfully changed. The first two elements of the list must be the NUMERIC access and modification times, in that order. Changes the access and modification times on each file of a list of files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |