__________________
Senast redigerad av Sargaroth 2009-07-16 kl. 21:55.
Senast redigerad av Sargaroth 2009-07-16 kl. 21:55.
import os
import time
import zipfile
source = '/Users/Andrea/Documents/Code'
target_dir = '/Users/Andrea/Desktop/Backup'
today = target_dir + os.sep + time.strftime('%Y%m%d')
now = time.strftime('%H%M%S')
comment = input("You may here enter a comment which will then be added to the filename.\
\n\
\n\
Please note that spaces in the comment will be replaced with underscores.\
\n\
\n\
You may skip this step by pressing Return.\
\n\
\n\Please enter a comment: ")
if len(comment) ==0:
target = today + os.sep + now + 'zip'
else:
target = today + os.sep + now + '_' + \
comment.replace(' ', '_') + '.zip'
if not os.path.exists(today):
os.mkdir(today)
print('Successfully created directory', today)
#zipfile.ZipFile(file[, mode[, compression[, allowZip64]]])
zip = zipfile.ZipFile(target, 'w')#.format(target, ' '.join(source))
zip.write(source)
zip.close()
if zipfile(zip) ==0:
print('Successfully backed up to', target)
else:
print('Backup FAILED')
<<<<<<<<FELMEDDELANDE>>>>>>>>>>
Traceback (most recent call last):
File "/Users/Andrea/Documents/Code/backup_ver5_1.py", line 39, in <module>
if zipfile(zip) ==0:
TypeError: 'module' object is not callable
Du måste vara medlem för att kunna kommentera