Parent: [529ea4] (diff)

Child: [f725a1] (diff)

Download this file

reactors.py    33 lines (27 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import errno, logging, os, stat, subprocess
from pylons import c
from pyforge.lib.decorators import audit, react
from pyforge import model as M
log = logging.getLogger(__name__)
@audit('scm.svn.init')
def init(routing_key, data):
repo = c.app.repo
repo_name = data['repo_name']
repo_path = data['repo_path']
if not repo_path.endswith('/'): repo_path += '/'
try:
os.makedirs(repo_path)
except OSError, e:
if e.errno != errno.EEXIST:
raise
# We may eventually require --template=...
log.info('svnadmin create '+repo_path+repo_name)
result = subprocess.call(['svnadmin', 'create', repo_name],
cwd=repo_path)
magic_file = repo_path + repo_name + '/.SOURCEFORGE-REPOSITORY'
with open(magic_file, 'w') as f:
f.write('svn')
os.chmod(magic_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
repo.status = 'ready'
M.Notification.post_user(c.user, repo, 'created',
text='Repository %s created' % repo_name)