Merged in [19949] from rjsparks@nostrum.com:
Use tempfiles while rebuilding group and doc alias files. Fixes #3521.
- Legacy-Id: 19958
Note: SVN reference [19949] has been migrated to Git commit d6298adacb
This commit is contained in:
commit
3fa90e7517
|
@ -9,6 +9,8 @@ import io
|
|||
import os
|
||||
import re
|
||||
import time
|
||||
|
||||
from tempfile import mkstemp
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
|
@ -102,8 +104,13 @@ class Command(BaseCommand):
|
|||
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
||||
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
||||
|
||||
afile = io.open(settings.DRAFT_ALIASES_PATH, "w")
|
||||
vfile = io.open(settings.DRAFT_VIRTUAL_PATH, "w")
|
||||
ahandle, aname = mkstemp()
|
||||
os.close(ahandle)
|
||||
afile = io.open(aname,"w")
|
||||
|
||||
vhandle, vname = mkstemp()
|
||||
os.close(vhandle)
|
||||
vfile = io.open(vname,"w")
|
||||
|
||||
afile.write(signature)
|
||||
vfile.write(signature)
|
||||
|
@ -160,4 +167,8 @@ class Command(BaseCommand):
|
|||
|
||||
afile.close()
|
||||
vfile.close()
|
||||
|
||||
os.rename(aname, settings.DRAFT_ALIASES_PATH)
|
||||
os.rename(vname, settings.DRAFT_VIRTUAL_PATH)
|
||||
|
||||
|
|
@ -8,6 +8,8 @@ import datetime
|
|||
import io
|
||||
import os
|
||||
import time
|
||||
|
||||
from tempfile import mkstemp
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
|
@ -40,8 +42,13 @@ class Command(BaseCommand):
|
|||
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
||||
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
||||
|
||||
afile = io.open(settings.GROUP_ALIASES_PATH, "w")
|
||||
vfile = io.open(settings.GROUP_VIRTUAL_PATH, "w")
|
||||
ahandle, aname = mkstemp()
|
||||
os.close(ahandle)
|
||||
afile = io.open(aname,"w")
|
||||
|
||||
vhandle, vname = mkstemp()
|
||||
os.close(vhandle)
|
||||
vfile = io.open(vname,"w")
|
||||
|
||||
afile.write(signature)
|
||||
vfile.write(signature)
|
||||
|
@ -86,4 +93,7 @@ class Command(BaseCommand):
|
|||
dump_sublist(afile, vfile, group.acronym+'-chairs', IETF_DOMAIN, settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(group, ['chair', 'delegate']))
|
||||
|
||||
afile.close()
|
||||
vfile.close()
|
||||
vfile.close()
|
||||
|
||||
os.rename(aname, settings.GROUP_ALIASES_PATH)
|
||||
os.rename(vname, settings.GROUP_VIRTUAL_PATH)
|
||||
|
|
Loading…
Reference in a new issue