52
58
os.path.join(get_junk_dir(parent), name))
56
store = get_store(config)
58
active_users = store.find(User, state=u'enabled').order_by(User.login)
60
print >>sys.stderr, "Refreshing active user jails..."
61
for user in active_users:
62
ivle.makeuser.make_jail(user, config)
65
login for login in os.listdir(config['paths']['jails']['src'])
66
if not (login.startswith('__') and login.endswith('__')))
68
print >>sys.stderr, "Junking extra user jails..."
69
for jail in present_jails - set(user.login for user in active_users):
71
junk(config['paths']['jails']['src'], jail)
73
repo_root = config['paths']['svn']['repo_path']
75
print >>sys.stderr, "Creating missing Subversion user repositories..."
76
present_user_repos= set(
77
login for login in os.listdir(os.path.join(repo_root, 'users')))
79
for repo in set(user.login for user in active_users) - present_user_repos:
81
ivle.makeuser.make_svn_repo(
82
os.path.join(repo_root, 'users', repo), throw_on_error=True)
84
print >>sys.stderr, "Junking extra Subversion user repositories..."
85
for repo in present_user_repos - set(user.login for user in active_users):
87
junk(os.path.join(repo_root, 'users'), repo)
90
print >>sys.stderr, "Creating missing Subversion group repositories..."
91
present_group_repos = set(
92
group for group in os.listdir(os.path.join(repo_root, 'groups')))
94
active_group_identifiers = set("_".join(
95
[group.project_set.offering.subject.short_name,
96
group.project_set.offering.semester.year,
97
group.project_set.offering.semester.semester,
98
group.name]) for group in store.find(ProjectGroup))
100
for repo in active_group_identifiers - present_group_repos:
102
ivle.makeuser.make_svn_repo(
103
os.path.join(repo_root, 'groups', repo), throw_on_error=True)
105
print >>sys.stderr, "Junking extra Subversion user repositories..."
106
for repo in present_group_repos - active_group_identifiers:
108
junk(os.path.join(repo_root, 'groups'), repo)
111
print >>sys.stderr, "Rebuilding Subversion user configuration..."
112
ivle.makeuser.rebuild_svn_config(store, config)
113
print >>sys.stderr, "Rebuilding Subversion group configuration..."
114
ivle.makeuser.rebuild_svn_group_config(store, config)
61
def refresh_filesystem(config, store):
62
active_users = store.find(User, state=u'enabled').order_by(User.login)
64
logging.info("Refreshing active user jails.")
65
for user in active_users:
66
ivle.makeuser.make_jail(user, config)
69
login for login in os.listdir(config['paths']['jails']['src'])
70
if not (login.startswith('__') and login.endswith('__')))
72
logging.info("Junking extra user jails...")
73
for jail in present_jails - set(user.login for user in active_users):
74
logging.info(' - %s' % jail)
75
junk(config['paths']['jails']['src'], jail)
77
repo_root = config['paths']['svn']['repo_path']
79
logging.info("Creating missing Subversion user repositories.")
80
present_user_repos = set(
81
login for login in os.listdir(os.path.join(repo_root, 'users')))
83
for repo in set(user.login for user in active_users) - present_user_repos:
84
logging.info(' - %s' % repo)
85
ivle.makeuser.make_svn_repo(
86
os.path.join(repo_root, 'users', repo), throw_on_error=True)
88
logging.info("Junking extra Subversion user repositories.")
89
for repo in present_user_repos - set(user.login for user in active_users):
90
logging.info(' - %s' % repo)
91
junk(os.path.join(repo_root, 'users'), repo)
94
logging.info("Creating missing Subversion group repositories.")
95
present_group_repos = set(
96
group for group in os.listdir(os.path.join(repo_root, 'groups')))
98
active_group_identifiers = set("_".join(
99
[group.project_set.offering.subject.short_name,
100
group.project_set.offering.semester.year,
101
group.project_set.offering.semester.semester,
102
group.name]) for group in store.find(ProjectGroup))
104
for repo in active_group_identifiers - present_group_repos:
105
logging.info(' - %s' % repo)
106
ivle.makeuser.make_svn_repo(
107
os.path.join(repo_root, 'groups', repo), throw_on_error=True)
109
logging.info("Junking extra Subversion user repositories.")
110
for repo in present_group_repos - active_group_identifiers:
111
logging.info(' - %s' % repo)
112
junk(os.path.join(repo_root, 'groups'), repo)
115
logging.info("Rebuilding Subversion user configuration.")
116
ivle.makeuser.rebuild_svn_config(store, config)
117
logging.info("Rebuilding Subversion group configuration.")
118
ivle.makeuser.rebuild_svn_group_config(store, config)
121
if __name__ == '__main__':
123
store = get_store(config)
124
refresh_filesystem(config, store)