def install(self):
self.run('apt-get -y install trac', notify=True, exit_on_error=True)
self.run('apt-get -y install libapache2-svn', notify=True, exit_on_error=True)
self.run("a2enmod ssl")
self.run("a2enmod mod_python")
self.run("a2enmod dav_svn")
self.run("a2enmod rewrite")
# Make sure that boto.log is writable by everyone so that subversion post-commit hooks can
# write to it.
self.run("touch /var/log/boto.log")
self.run("chmod a+w /var/log/boto.log")
python类log()的实例源码
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception as e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path
def install(self):
self.run('apt-get -y install trac', notify=True, exit_on_error=True)
self.run('apt-get -y install libapache2-svn', notify=True, exit_on_error=True)
self.run("a2enmod ssl")
self.run("a2enmod mod_python")
self.run("a2enmod dav_svn")
self.run("a2enmod rewrite")
# Make sure that boto.log is writable by everyone so that subversion post-commit hooks can
# write to it.
self.run("touch /var/log/boto.log")
self.run("chmod a+w /var/log/boto.log")
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception as e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception, e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception, e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path
def install(self):
self.run('apt-get -y install trac', notify=True, exit_on_error=True)
self.run('apt-get -y install libapache2-svn', notify=True, exit_on_error=True)
self.run("a2enmod ssl")
self.run("a2enmod mod_python")
self.run("a2enmod dav_svn")
self.run("a2enmod rewrite")
# Make sure that boto.log is writable by everyone so that subversion post-commit hooks can
# write to it.
self.run("touch /var/log/boto.log")
self.run("chmod a+w /var/log/boto.log")
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception as e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path
def create_working_dir(self):
boto.log.info('Working directory: %s' % self.working_dir)
if not os.path.exists(self.working_dir):
os.mkdir(self.working_dir)
def load_boto(self):
update = boto.config.get('Boto', 'boto_update', 'svn:HEAD')
if update.startswith('svn'):
if update.find(':') >= 0:
method, version = update.split(':')
version = '-r%s' % version
else:
version = '-rHEAD'
location = boto.config.get('Boto', 'boto_location', '/usr/local/boto')
self.run('svn update %s %s' % (version, location))
elif update.startswith('git'):
location = boto.config.get('Boto', 'boto_location', '/usr/share/python-support/python-boto/boto')
num_remaining_attempts = 10
while num_remaining_attempts > 0:
num_remaining_attempts -= 1
try:
self.run('git pull', cwd=location)
num_remaining_attempts = 0
except Exception, e:
boto.log.info('git pull attempt failed with the following exception. Trying again in a bit. %s', e)
time.sleep(2)
if update.find(':') >= 0:
method, version = update.split(':')
else:
version = 'master'
self.run('git checkout %s' % version, cwd=location)
else:
# first remove the symlink needed when running from subversion
self.run('rm /usr/local/lib/python2.5/site-packages/boto')
self.run('easy_install %s' % update)
def fetch_s3_file(self, s3_file):
try:
from boto.utils import fetch_file
f = fetch_file(s3_file)
path = os.path.join(self.working_dir, s3_file.split("/")[-1])
open(path, "w").write(f.read())
except:
boto.log.exception('Problem Retrieving file: %s' % s3_file)
path = None
return path