Ignore:
Timestamp:
Nov 26, 2009, 9:45:03 AM (15 years ago)
Author:
broder
Message:

Replace NamedTemporaryFile? with mkstemp in invirt-build-conf and
invirt-submit-build.

NamedTemporaryFile? lacks the delete kwarg in Python 2.5, meaning that
files are always deleted when the fd is closed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-dev/invirt-build-conf

    r2566 r2567  
    3030    # a temporary path and moved to its final resting place on
    3131    # .close(). Oh well.
    32     conf = tempfile.NamedTemporaryFile(delete=False)
     32    conf_fd, conf_name = tempfile.mkstemp()
     33    conf = os.fdopen(conf_fd)
    3334    build_handler = '/usr/sbin/invirt-submit-build'
    3435
     
    3637        acl = authz.expandAdmin(getattr(config.git.pockets, pocket).acl, None)
    3738
    38         acl_fd = tempfile.NamedTemporaryFile(delete=False)
     39        acl_fd, acl_name = tempfile.mkstemp()
     40        acl_fd = os.fdopen(acl_fd)
    3941        print >>acl_fd, '\n'.join(user(a) for a in acl)
    4042
    4143        acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket)
    4244
    43         os.rename(acl_fd.name, acl_path)
     45        os.rename(acl_name, acl_path)
    4446        print >>conf, 'build %s %s %s' % (pocket, build_handler, acl_path)
    4547
    46     os.rename(conf, '/etc/remctl/conf.d/build')
     48    os.rename(conf_name, '/etc/remctl/conf.d/build')
    4749
    4850
Note: See TracChangeset for help on using the changeset viewer.