Changeset fb1c047 for asadb/groups
- Timestamp:
- Jan 22, 2012, 12:16:44 PM (14 years ago)
- Branches:
- master, space-access, stable, stage
- Children:
- 5e2645b
- Parents:
- 7ef7143
- git-author:
- Alex Dehnert <adehnert@…> (01/22/12 12:16:44)
- git-committer:
- Alex Dehnert <adehnert@…> (01/22/12 12:16:44)
- Location:
- asadb/groups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/gather_constitutions.py
r7ef7143 rfb1c047 9 9 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 10 10 11 import collections 11 12 import datetime 12 13 import subprocess … … 49 50 subprocess.check_call(['git', 'commit', '--allow-empty', '-a', '-m', msg, ], cwd=git_dir, ) 50 51 52 def webstat(): 53 constitutions = groups.models.GroupConstitution.objects.all() 54 codes = collections.defaultdict(list) 55 count = 0 56 for const in constitutions: 57 if count % 10 == 0: print count, 58 code = const.webstat() 59 codes[code].append(const) 60 count += 1 61 for code, gs in codes.items(): 62 print "\nCode: %s (count: %d)" % (code, len(gs), ) 63 for const in gs: 64 print const.group 65 for code, gs in codes.items(): 66 print "\nCode: %s (count: %d)" % (code, len(gs), ) 67 for const in gs: 68 print const.source_url 69 print "\n\n" 70 for code, gs in codes.items(): 71 print "%4d\t%s" % (len(gs), code, ) 72 51 73 if __name__ == '__main__': 52 additions, changed = gather_constitutions() 53 update_repo(additions, changed) 74 if len(sys.argv) == 1 or sys.argv[1] == "gather": 75 additions, changed = gather_constitutions() 76 update_repo(additions, changed) 77 elif sys.argv[1] == "webstat": 78 webstat() 79 else: 80 raise NotImplementedError -
asadb/groups/models.py
r7ef7143 rfb1c047 201 201 return path 202 202 203 def webstat(self, ): 204 url = self.source_url 205 if url: 206 try: 207 stream = urllib.urlopen(self.source_url) 208 return stream.getcode() 209 except: 210 return "IOError" 211 else: 212 return "no-url" 213 203 214 reversion.register(GroupConstitution) 204 215
Note: See TracChangeset
for help on using the changeset viewer.