~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup/setuputil.py

  • Committer: wagrant
  • Date: 2008-07-21 23:53:43 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:927
browser, console: Rewrite and extend the Help pages. How does Matt
      manage to conflict with this when they hadn't been edited for 3.5
      months before last night!?

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import shutil
27
27
import errno
28
28
import sys
 
29
import pysvn
29
30
import string
30
31
import stat
31
32
 
 
33
# Import modules from the website is tricky since they're in the www
 
34
# directory.
 
35
sys.path.append('lib')
 
36
import common.makeuser
 
37
 
32
38
# Determine which Python version (2.4 or 2.5, for example) we are running,
33
39
# and use that as the filename to the Python directory.
34
40
# Just get the first 3 characters of sys.version.
37
43
# Location of standard programs
38
44
RSYNC = '/usr/bin/rsync'
39
45
 
40
 
# UID of the Webserver
41
 
wwwuid = 33
42
 
 
43
46
def copy_file_to_jail(src, dry):
44
47
    """Copies a single file from an absolute location into the same location
45
48
    within the jail. src must begin with a '/'. The jail will be located
124
127
    try:
125
128
        action_runprog(RSYNC, ['-a','--delete',src + '/',dst], dry)
126
129
    except RunError:
 
130
        print "cp -r", src, dst
127
131
        if dry: return
128
132
        action_remove(dst, dry)
129
 
        print "cp -r", src, dst
130
133
        shutil.copytree(src, dst, True)
131
134
 
 
135
def action_linktree(src, dst, dry):
 
136
    """Hard-links an entire directory tree. Same as copytree but the created
 
137
    files are hard-links not actual copies. Removes the existing destination.
 
138
    """
 
139
    action_remove(dst, dry)
 
140
    print "<cp with hardlinks> -r", src, dst
 
141
    if dry: return
 
142
    common.makeuser.linktree(src, dst)
 
143
 
132
144
def action_copylist(srclist, dst, dry, srcdir="."):
133
145
    """Copies all files in a list to a new location. The files in the list
134
146
    are read relative to the current directory, and their destinations are the
205
217
        os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
206
218
            | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH)
207
219
 
208
 
def action_make_private(file, dry):
209
 
    """Ensures that a file is private to IVLE (chowns to www-data and chmod to 
210
 
    600)"""
211
 
    print "chown %s:%s %s"%(wwwuid, wwwuid, file)
212
 
    if not dry:
213
 
        os.chown(file, wwwuid, wwwuid)
214
 
    print "chmod 600", file
215
 
    if not dry:
216
 
        os.chmod(file, stat.S_IRUSR | stat.S_IWUSR)
217
 
 
218
220
def query_user(default, prompt):
219
221
    """Prompts the user for a string, which is read from a line of stdin.
220
222
    Exits silently if EOF is encountered. Returns the string, with spaces
249
251
 
250
252
def get_svn_revision():
251
253
    """Returns either the current SVN revision of this build, or None"""
252
 
    import pysvn
253
254
    try:
254
255
        svn = pysvn.Client()
255
256
        entry = svn.info('.')