Changeset 3039 for trunk/packages/invirt-dev/invirt-build-conf
- Timestamp:
- Jul 6, 2010, 12:28:05 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-dev/invirt-build-conf
r2766 r3039 7 7 the git user that developers can push through. 8 8 """ 9 from __future__ import with_statement 9 10 10 11 import contextlib 11 12 import os 12 13 import tempfile … … 27 28 return princ.replace('.', '/') + '@' + realm 28 29 30 def acl_path(pocket): 31 return '/etc/remctl/acl/build-%s' % pocket 32 33 @contextlib.contextmanager 34 def atomic_write(file): 35 tmp_fd, tmp_name = tempfile.mkstemp() 36 tmp = os.fdopen(tmp_fd, 'r+') 37 yield tmp 38 tmp.close() 39 os.rename(tmp_name, file) 29 40 30 41 def main(): 31 42 all_devs = set() 32 33 # Python could really use a file-like object that gets written to34 # a temporary path and moved to its final resting place on35 # .close(). Oh well.36 conf_fd, conf_name = tempfile.mkstemp()37 conf = os.fdopen(conf_fd, 'r+')38 43 build_handler = '/usr/bin/invirt-submit-build' 39 44 40 45 for pocket in config.build.pockets: 41 46 acl = authz.expandAdmin(getattr(config.build.pockets, pocket).acl, None) 47 with atomic_write(acl_path(pocket)) as f: 48 princs = [userToPrinc(a) for a in acl] 49 print >>f, '\n'.join(princs) 50 all_devs.update(set(princs)) 42 51 43 acl_fd, acl_name = tempfile.mkstemp() 44 acl_fd = os.fdopen(acl_fd, 'r+') 45 print >>acl_fd, '\n'.join(userToPrinc(a) for a in acl) 46 47 all_devs.update(set(userToPrinc(a) for a in acl)) 48 49 acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket) 50 51 os.rename(acl_name, acl_path) 52 print >>conf, 'build %s %s %s' % (pocket, build_handler, acl_path) 52 with atomic_write('/etc/remctl/conf.d/build') as f: 53 for pocket in config.build.pockets: 54 print >>f, 'build %s %s %s' % (pocket, build_handler, acl_path(pocket)) 53 55 54 56 os.rename(conf_name, '/etc/remctl/conf.d/build') … … 58 60 print >>k5login, '\n'.join(all_devs) 59 61 60 os.rename(k5login_name, os.path.join(builder._REPO_DIR, '.k5login')) 62 with atomic_write(os.path.join(builder._REPO_DIR, '.k5login')) as f: 63 print >>f, '\n'.join(all_devs) 61 64 62 65
Note: See TracChangeset
for help on using the changeset viewer.