Use tempfiles while rebuilding group and doc alias files. Fixes #3521. Commit ready for merge.
- Legacy-Id: 19949
This commit is contained in:
parent
358132dbfe
commit
d6298adacb
|
@ -9,6 +9,8 @@ import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from tempfile import mkstemp
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
@ -102,8 +104,13 @@ class Command(BaseCommand):
|
||||||
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
||||||
|
|
||||||
afile = io.open(settings.DRAFT_ALIASES_PATH, "w")
|
ahandle, aname = mkstemp()
|
||||||
vfile = io.open(settings.DRAFT_VIRTUAL_PATH, "w")
|
os.close(ahandle)
|
||||||
|
afile = io.open(aname,"w")
|
||||||
|
|
||||||
|
vhandle, vname = mkstemp()
|
||||||
|
os.close(vhandle)
|
||||||
|
vfile = io.open(vname,"w")
|
||||||
|
|
||||||
afile.write(signature)
|
afile.write(signature)
|
||||||
vfile.write(signature)
|
vfile.write(signature)
|
||||||
|
@ -160,4 +167,8 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
afile.close()
|
afile.close()
|
||||||
vfile.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 io
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from tempfile import mkstemp
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
@ -40,8 +42,13 @@ class Command(BaseCommand):
|
||||||
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
date = time.strftime("%Y-%m-%d_%H:%M:%S")
|
||||||
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
signature = '# Generated by %s at %s\n' % (os.path.abspath(__file__), date)
|
||||||
|
|
||||||
afile = io.open(settings.GROUP_ALIASES_PATH, "w")
|
ahandle, aname = mkstemp()
|
||||||
vfile = io.open(settings.GROUP_VIRTUAL_PATH, "w")
|
os.close(ahandle)
|
||||||
|
afile = io.open(aname,"w")
|
||||||
|
|
||||||
|
vhandle, vname = mkstemp()
|
||||||
|
os.close(vhandle)
|
||||||
|
vfile = io.open(vname,"w")
|
||||||
|
|
||||||
afile.write(signature)
|
afile.write(signature)
|
||||||
vfile.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']))
|
dump_sublist(afile, vfile, group.acronym+'-chairs', IETF_DOMAIN, settings.GROUP_VIRTUAL_DOMAIN, get_group_role_emails(group, ['chair', 'delegate']))
|
||||||
|
|
||||||
afile.close()
|
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