Changeset 10288 for main/waeup.kofa/trunk
- Timestamp:
- 11 Jun 2013, 08:18:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/tools/reload_portraits.py
r9020 r10288 19 19 ## The folder where all source docs can be found (can be any folder) 20 20 #SRC_DIR = "/kofa/uniben/var/datacenter/media/students/reload" 21 SRC_DIR = "/ zope/instances/unibenpg-import/pictures_admitted_latest"21 SRC_DIR = "/kofa/uniben_passport_reload" 22 22 23 23 ## The students folder in Kofa where files should go to … … 70 70 71 71 def final_subfolder(stud_id): 72 # compute new folder name from stud_id (old stud_ids or new stud_ids 73 # but not new old stud_ids) 74 num = int(stud_id[1:]) 72 # compute new folder name from stud_id (old stud_ids or new stud_ids) 73 try: 74 num = int(stud_id[1:]) 75 except ValueError: 76 # new old stud_ids 77 num = int(stud_id[2:]) 75 78 num = num / 10000 * 10 76 79 return '%05d' % num … … 80 83 shutil.copyfile(file_src, file_dst) 81 84 set_perms(file_dst) 85 return 86 87 def create_path(path): 88 # create path with subdirs, if it does not exist (completely) 89 if os.path.exists(path): 90 return 91 parent = os.path.dirname(path) 92 if not os.path.exists(parent): 93 # create parent first 94 create_path(parent) 95 print "CREATE PATH ", path 96 os.mkdir(path) 97 set_perms(path) 82 98 return 83 99 … … 96 112 dst_folder = os.path.join(DST_DIR, subfolder, new_stud_id) 97 113 if not os.path.exists(dst_folder): 98 print "Destination folder does not exist: %s. Skipping" % (dst_folder) 99 continue 114 #print "Destination folder does not exist: %s. Skipping" % (dst_folder) 115 #continue 116 create_path(dst_folder) 100 117 dst_file = os.path.join(DST_DIR, subfolder, new_stud_id, 101 118 'passport_%s.jpg' % new_stud_id)
Note: See TracChangeset for help on using the changeset viewer.