Changeset 00079cf
- Timestamp:
- Feb 26, 2012, 3:55:58 AM (14 years ago)
- Branches:
- master, space-access, stable, stage
- Children:
- 99747bd
- Parents:
- 41f8b1e
- git-author:
- Alex Dehnert <adehnert@…> (02/26/12 03:55:58)
- git-committer:
- Alex Dehnert <adehnert@…> (02/26/12 03:55:58)
- Location:
- asadb/groups
- Files:
-
- 1 added
- 1 edited
-
import_signatories.py (modified) (6 diffs)
-
migrations/0023_groupadmin.py (added)
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/import_signatories.py
r0653daa r00079cf 74 74 75 75 @transaction.commit_on_success 76 def perform_sync(stats, dj_map, wh_map, ):76 def perform_sync(stats, dj_map, wh_map, roles=None, dj_groups=None, ): 77 77 # Statistics 78 78 stats['loops'] = 0 … … 83 83 stats['added'] = 0 84 84 stats['missing_rg'] = 0 85 stats['missing_role'] = 0 85 86 86 87 today = datetime.date.today() 87 roles = load_roles() 88 dj_groups = load_groups() 88 if roles is None: 89 roles = load_roles() 90 if dj_groups is None: 91 dj_groups = load_groups() 89 92 for key in set(dj_map.keys()).union(wh_map.keys()): 90 93 stats['loops'] += 1 … … 130 133 stats['added'] += 1 131 134 else: 132 print "Missing role or group: person=%s, role=%s, group=%d, start=%s, expiry=%s" % ( 133 person, role_slug, group_id, start, expiry, 134 ) 135 stats['missing_rg'] += 1 135 if role_slug not in roles: 136 stats['missing_role'] += 1 137 else: 138 print "Missing role or group: person=%s, role=%s, group=%d, start=%s, expiry=%s" % ( 139 person, role_slug, group_id, start, expiry, 140 ) 141 stats['missing_rg'] += 1 142 136 143 137 144 if __name__ == '__main__': 138 stats = {} 145 stats = { 146 'group_ign': 0, 147 } 148 149 mode = 'all' 150 roles = None # default 151 if len(sys.argv) > 1: 152 if sys.argv[1] == 'squash': 153 mode = 'squash' 154 elif sys.argv[1] == 'all': 155 pass 156 else: 157 raise NotImplementedError 158 if mode == 'squash': 159 roles = load_roles() 160 repl = roles['temp-admin'] 161 for slug, role in roles.items(): 162 if slug in ('president', 'treasurer', 'financial', ): 163 roles[slug] = repl 164 else: 165 del roles[slug] 139 166 140 167 print "Phase 1: %s: Loading Django officer information" % (datetime.datetime.now(), ) … … 142 169 print "Phase 1: %s: Complete: Loading Django officer information" % (datetime.datetime.now(), ) 143 170 144 print "Phase 2: %s: Loading warehouse officer information" % (datetime.datetime.now(), ) 171 print "Phase 2: %s: Loading Django group information" % (datetime.datetime.now(), ) 172 dj_groups = load_groups() 173 if mode == 'squash': 174 for pk, group in dj_groups.items(): 175 if len(group.officers()) > 1: 176 stats['group_ign'] += 1 177 del dj_groups[pk] 178 else: 179 print "Keeping ", group 180 print "Phase 2: %s: Complete: Loading Django group information" % (datetime.datetime.now(), ) 181 182 print "Phase 3: %s: Loading warehouse officer information" % (datetime.datetime.now(), ) 145 183 wh_map = load_warehouse(stats) 146 print "Phase 2: %s: Complete: Loading warehouse officer information" % (datetime.datetime.now(), )147 148 print "Phase 3: %s: Performing sync" % (datetime.datetime.now(), )149 perform_sync(stats, dj_map, wh_map, )150 print "Phase 3: %s: Complete: Performing sync" % (datetime.datetime.now(), )184 print "Phase 3: %s: Complete: Loading warehouse officer information" % (datetime.datetime.now(), ) 185 186 print "Phase 4: %s: Performing sync" % (datetime.datetime.now(), ) 187 perform_sync(stats, dj_map, wh_map, roles, dj_groups, ) 188 print "Phase 4: %s: Complete: Performing sync" % (datetime.datetime.now(), ) 151 189 152 190 print """ … … 155 193 Django current: %(dj_total_current)6d 156 194 Django distinct: %(dj_distinct_current)6d 195 Django ignored groups: %(group_ign)6d 157 196 158 197 Warehouse p/r/g tuples: %(wh_size)6d … … 164 203 People expired: %(expired)6d 165 204 People missing from WH: %(missing_wh)6d 205 People in missing group:%(missing_rg)6d 206 People for missing role:%(missing_role)6d 166 207 People added: %(added)6d 167 208 """ % stats
Note: See TracChangeset
for help on using the changeset viewer.