Commit f03386a3 authored by Marco Mariani's avatar Marco Mariani

grid: logger usage % -> ,

parent 0018e9a2
...@@ -124,7 +124,7 @@ class Software(object): ...@@ -124,7 +124,7 @@ class Software(object):
""" Fetches binary cache if possible. """ Fetches binary cache if possible.
Installs from buildout otherwise. Installs from buildout otherwise.
""" """
self.logger.info("Installing software release %s..." % self.url) self.logger.info('Installing software release %s...', self.url)
cache_dir = tempfile.mkdtemp() cache_dir = tempfile.mkdtemp()
try: try:
tarpath = os.path.join(cache_dir, self.software_url_hash) tarpath = os.path.join(cache_dir, self.software_url_hash)
...@@ -263,10 +263,10 @@ class Software(object): ...@@ -263,10 +263,10 @@ class Software(object):
func(path) func(path)
try: try:
if os.path.exists(self.software_path): if os.path.exists(self.software_path):
self.logger.info('Removing path %r' % self.software_path) self.logger.info('Removing path %r', self.software_path)
shutil.rmtree(self.software_path, onerror=retry) shutil.rmtree(self.software_path, onerror=retry)
else: else:
self.logger.info('Path %r does not exists, no need to remove.' % self.logger.info('Path %r does not exist, no need to remove.',
self.software_path) self.software_path)
except IOError as exc: except IOError as exc:
raise IOError("I/O error while removing software (%s): %s" % (self.url, exc)) raise IOError("I/O error while removing software (%s): %s" % (self.url, exc))
...@@ -334,9 +334,9 @@ class Partition(object): ...@@ -334,9 +334,9 @@ class Partition(object):
if old_content != new_content: if old_content != new_content:
if old_content is None: if old_content is None:
self.logger.info('Missing %s file. Creating %r' % (name, path)) self.logger.info('Missing %s file. Creating %r', name, path)
else: else:
self.logger.info('Changed %s content. Updating %r' % (name, path)) self.logger.info('Changed %s content. Updating %r', name, path)
with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o400), 'wb') as fout: with os.fdopen(os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o400), 'wb') as fout:
fout.write(new_content) fout.write(new_content)
...@@ -391,8 +391,8 @@ class Partition(object): ...@@ -391,8 +391,8 @@ class Partition(object):
""" Creates configuration file from template in software_path, then """ Creates configuration file from template in software_path, then
installs the software partition with the help of buildout installs the software partition with the help of buildout
""" """
self.logger.info("Installing Computer Partition %s..." self.logger.info('Installing Computer Partition %s...',
% self.computer_partition.getId()) self.computer_partition.getId())
# Checks existence and permissions of Partition directory # Checks existence and permissions of Partition directory
# Note : Partitions have to be created and configured before running slapgrid # Note : Partitions have to be created and configured before running slapgrid
if not os.path.isdir(self.instance_path): if not os.path.isdir(self.instance_path):
...@@ -430,7 +430,7 @@ class Partition(object): ...@@ -430,7 +430,7 @@ class Partition(object):
self.software_release_url, instance_cfg)) self.software_release_url, instance_cfg))
buildout_cfg = os.path.join(self.instance_path, 'buildout.cfg') buildout_cfg = os.path.join(self.instance_path, 'buildout.cfg')
self.logger.debug("Copying %r to %r" % (instance_cfg, buildout_cfg)) self.logger.debug('Copying %r to %r', instance_cfg, buildout_cfg)
with open(buildout_cfg, 'w') as fout: with open(buildout_cfg, 'w') as fout:
fout.write(open(instance_cfg).read()) fout.write(open(instance_cfg).read())
...@@ -462,8 +462,7 @@ class Partition(object): ...@@ -462,8 +462,7 @@ class Partition(object):
os.chown(buildout_cfg, -1, int(gid)) os.chown(buildout_cfg, -1, int(gid))
if len(bootstrap_candidate_list) == 0: if len(bootstrap_candidate_list) == 0:
buildout_binary = os.path.join(self.software_path, 'bin', 'buildout') buildout_binary = os.path.join(self.software_path, 'bin', 'buildout')
self.logger.warning("Falling back to default buildout %r" % self.logger.warning('Falling back to default buildout %r', buildout_binary)
buildout_binary)
else: else:
if len(bootstrap_candidate_list) != 1: if len(bootstrap_candidate_list) != 1:
raise ValueError('More than one bootstrap candidate found.') raise ValueError('More than one bootstrap candidate found.')
...@@ -477,8 +476,8 @@ class Partition(object): ...@@ -477,8 +476,8 @@ class Partition(object):
invocation_list = first_line[2:].split() invocation_list = first_line[2:].split()
invocation_list.append(bootstrap_file) invocation_list.append(bootstrap_file)
self.logger.debug('Invoking %r in %r' % (' '.join(invocation_list), self.logger.debug('Invoking %r in %r', ' '.join(invocation_list),
self.instance_path)) self.instance_path)
process_handler = SlapPopen(invocation_list, process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid, logger=self.logger), preexec_fn=lambda: dropPrivileges(uid, gid, logger=self.logger),
cwd=self.instance_path, cwd=self.instance_path,
...@@ -526,7 +525,7 @@ class Partition(object): ...@@ -526,7 +525,7 @@ class Partition(object):
if os.path.isdir(self.service_path): if os.path.isdir(self.service_path):
service_list = os.listdir(self.service_path) service_list = os.listdir(self.service_path)
if len(runner_list) == 0 and len(service_list) == 0: if len(runner_list) == 0 and len(service_list) == 0:
self.logger.warning('No runners nor services found for partition %r' % self.logger.warning('No runners nor services found for partition %r',
self.partition_id) self.partition_id)
if os.path.exists(self.supervisord_partition_configuration_path): if os.path.exists(self.supervisord_partition_configuration_path):
os.unlink(self.supervisord_partition_configuration_path) os.unlink(self.supervisord_partition_configuration_path)
...@@ -557,10 +556,9 @@ class Partition(object): ...@@ -557,10 +556,9 @@ class Partition(object):
supervisor.startProcessGroup(partition_id, False) supervisor.startProcessGroup(partition_id, False)
except xmlrpclib.Fault as exc: except xmlrpclib.Fault as exc:
if exc.faultString.startswith('BAD_NAME:'): if exc.faultString.startswith('BAD_NAME:'):
self.logger.info("Nothing to start on %s..." % self.logger.info('Nothing to start on %s...', self.computer_partition.getId())
self.computer_partition.getId())
else: else:
self.logger.info("Requested start of %s..." % self.computer_partition.getId()) self.logger.info('Requested start of %s...', self.computer_partition.getId())
def stop(self): def stop(self):
"""Asks supervisord to stop the instance.""" """Asks supervisord to stop the instance."""
...@@ -570,9 +568,9 @@ class Partition(object): ...@@ -570,9 +568,9 @@ class Partition(object):
supervisor.stopProcessGroup(partition_id, False) supervisor.stopProcessGroup(partition_id, False)
except xmlrpclib.Fault as exc: except xmlrpclib.Fault as exc:
if exc.faultString.startswith('BAD_NAME:'): if exc.faultString.startswith('BAD_NAME:'):
self.logger.info('Partition %s not known in supervisord, ignoring' % partition_id) self.logger.info('Partition %s not known in supervisord, ignoring', partition_id)
else: else:
self.logger.info("Requested stop of %s..." % self.computer_partition.getId()) self.logger.info('Requested stop of %s...', self.computer_partition.getId())
def _pre_destroy(self, destroy_binary): def _pre_destroy(self, destroy_binary):
uid, gid = self.getUserGroupId() uid, gid = self.getUserGroupId()
...@@ -593,8 +591,8 @@ class Partition(object): ...@@ -593,8 +591,8 @@ class Partition(object):
def destroy(self): def destroy(self):
"""Destroys the partition and makes it available for subsequent use." """Destroys the partition and makes it available for subsequent use."
""" """
self.logger.info("Destroying Computer Partition %s..." self.logger.info('Destroying Computer Partition %s...',
% self.computer_partition.getId()) self.computer_partition.getId())
# Launches "destroy" binary if exists # Launches "destroy" binary if exists
destroy_binary = os.path.join(self.instance_path, 'sbin', 'destroy') destroy_binary = os.path.join(self.instance_path, 'sbin', 'destroy')
...@@ -644,21 +642,21 @@ class Partition(object): ...@@ -644,21 +642,21 @@ class Partition(object):
fails = [res for res in results fails = [res for res in results
if res['status'] == xmlrpc.Faults.FAILED] if res['status'] == xmlrpc.Faults.FAILED]
if fails: if fails:
self.logger.warning('Problem while stopping process %r, will try later' % gname) self.logger.warning('Problem while stopping process %r, will try later', gname)
else: else:
self.logger.info('Stopped %r' % gname) self.logger.info('Stopped %r', gname)
supervisor.removeProcessGroup(gname) supervisor.removeProcessGroup(gname)
self.logger.info('Removed %r' % gname) self.logger.info('Removed %r', gname)
for gname in changed: for gname in changed:
results = supervisor.stopProcessGroup(gname) results = supervisor.stopProcessGroup(gname)
self.logger.info('Stopped %r' % gname) self.logger.info('Stopped %r', gname)
supervisor.removeProcessGroup(gname) supervisor.removeProcessGroup(gname)
supervisor.addProcessGroup(gname) supervisor.addProcessGroup(gname)
self.logger.info('Updated %r' % gname) self.logger.info('Updated %r', gname)
for gname in added: for gname in added:
supervisor.addProcessGroup(gname) supervisor.addProcessGroup(gname)
self.logger.info('Updated %r' % gname) self.logger.info('Updated %r', gname)
self.logger.debug('Supervisord updated') self.logger.debug('Supervisord updated')
...@@ -426,9 +426,9 @@ class Slapgrid(object): ...@@ -426,9 +426,9 @@ class Slapgrid(object):
fout.write(time.asctime()) fout.write(time.asctime())
elif state == 'destroyed': elif state == 'destroyed':
if os.path.exists(software_path): if os.path.exists(software_path):
self.logger.info('Destroying %r...' % software_release_uri) self.logger.info('Destroying %r...', software_release_uri)
software.destroy() software.destroy()
self.logger.info('Destroyed %r.' % software_release_uri) self.logger.info('Destroyed %r.', software_release_uri)
# Send log before exiting # Send log before exiting
except (SystemExit, KeyboardInterrupt): except (SystemExit, KeyboardInterrupt):
software_release.error(traceback.format_exc(), logger=self.logger) software_release.error(traceback.format_exc(), logger=self.logger)
...@@ -540,7 +540,7 @@ class Slapgrid(object): ...@@ -540,7 +540,7 @@ class Slapgrid(object):
(computer_partition_id not in self.computer_partition_filter_list): (computer_partition_id not in self.computer_partition_filter_list):
return return
self.logger.info('Processing Computer Partition %s.' % computer_partition_id) self.logger.info('Processing Computer Partition %s.', computer_partition_id)
instance_path = os.path.join(self.instance_root, computer_partition_id) instance_path = os.path.join(self.instance_root, computer_partition_id)
...@@ -606,9 +606,9 @@ class Slapgrid(object): ...@@ -606,9 +606,9 @@ class Slapgrid(object):
os.remove(timestamp_path) os.remove(timestamp_path)
self.logger.exception('') self.logger.exception('')
self.logger.info(' Software URL: %s' % software_url) self.logger.info(' Software URL: %s', software_url)
self.logger.info(' Software path: %s' % software_path) self.logger.info(' Software path: %s', software_path)
self.logger.info(' Instance path: %s' % instance_path) self.logger.info(' Instance path: %s', instance_path)
local_partition = Partition( local_partition = Partition(
software_path=software_path, software_path=software_path,
...@@ -791,8 +791,8 @@ class Slapgrid(object): ...@@ -791,8 +791,8 @@ class Slapgrid(object):
try: try:
document = etree.fromstring(to_be_validated) document = etree.fromstring(to_be_validated)
except (etree.XMLSyntaxError, etree.DocumentInvalid) as exc: except (etree.XMLSyntaxError, etree.DocumentInvalid) as exc:
self.logger.info('Failed to parse this XML report : %s\n%s' % self.logger.info('Failed to parse this XML report : %s\n%s',
(to_be_validated, _formatXMLError(exc))) to_be_validated, _formatXMLError(exc))
self.logger.error(_formatXMLError(exc)) self.logger.error(_formatXMLError(exc))
return False return False
...@@ -823,11 +823,11 @@ class Slapgrid(object): ...@@ -823,11 +823,11 @@ class Slapgrid(object):
try: try:
root = etree.fromstring(computer_partition_usage.usage) root = etree.fromstring(computer_partition_usage.usage)
except UnicodeError as exc: except UnicodeError as exc:
self.logger.info("Failed to read %s." % computer_partition_usage.usage) self.logger.info('Failed to read %s.', computer_partition_usage.usage)
self.logger.error(UnicodeError) self.logger.error(UnicodeError)
raise UnicodeError("Failed to read %s: %s" % (computer_partition_usage.usage, exc)) raise UnicodeError("Failed to read %s: %s" % (computer_partition_usage.usage, exc))
except (etree.XMLSyntaxError, etree.DocumentInvalid) as exc: except (etree.XMLSyntaxError, etree.DocumentInvalid) as exc:
self.logger.info("Failed to parse %s." % (computer_partition_usage.usage)) self.logger.info('Failed to parse %s.', computer_partition_usage.usage)
self.logger.error(exc) self.logger.error(exc)
raise _formatXMLError(exc) raise _formatXMLError(exc)
except Exception as exc: except Exception as exc:
...@@ -934,12 +934,12 @@ class Slapgrid(object): ...@@ -934,12 +934,12 @@ class Slapgrid(object):
if process_handler.returncode != 0: if process_handler.returncode != 0:
clean_run = False clean_run = False
failed_script_list.append("Script %r failed." % script) failed_script_list.append("Script %r failed." % script)
self.logger.warning('Failed to run %r' % invocation_list) self.logger.warning('Failed to run %r', invocation_list)
if len(failed_script_list): if len(failed_script_list):
computer_partition.error('\n'.join(failed_script_list), logger=self.logger) computer_partition.error('\n'.join(failed_script_list), logger=self.logger)
# Whatever happens, don't stop processing other instances # Whatever happens, don't stop processing other instances
except Exception: except Exception:
self.logger.exception('Cannot run usage script(s) for %r:' % self.logger.exception('Cannot run usage script(s) for %r:',
computer_partition.getId()) computer_partition.getId())
#Now we loop through the different computer partitions to report #Now we loop through the different computer partitions to report
...@@ -968,7 +968,7 @@ class Slapgrid(object): ...@@ -968,7 +968,7 @@ class Slapgrid(object):
if not self.validateXML(usage, partition_consumption_model): if not self.validateXML(usage, partition_consumption_model):
self.logger.info('WARNING: The XML file %s generated by slapreport is ' self.logger.info('WARNING: The XML file %s generated by slapreport is '
'not valid - This report is left as is at %s where you can ' 'not valid - This report is left as is at %s where you can '
'inspect what went wrong ' % (filename, dir_reports)) 'inspect what went wrong', filename, dir_reports)
# Warn the SlapOS Master that a partition generates corrupted xml # Warn the SlapOS Master that a partition generates corrupted xml
# report # report
else: else:
...@@ -978,7 +978,7 @@ class Slapgrid(object): ...@@ -978,7 +978,7 @@ class Slapgrid(object):
computer_partition_usage_list.append(computer_partition_usage) computer_partition_usage_list.append(computer_partition_usage)
filename_delete_list.append(filename) filename_delete_list.append(filename)
else: else:
self.logger.debug('Usage report %r not found, ignored' % file_path) self.logger.debug('Usage report %r not found, ignored', file_path)
#After sending the aggregated file we remove all the valid xml reports #After sending the aggregated file we remove all the valid xml reports
for filename in filename_delete_list: for filename in filename_delete_list:
...@@ -986,12 +986,13 @@ class Slapgrid(object): ...@@ -986,12 +986,13 @@ class Slapgrid(object):
# Whatever happens, don't stop processing other instances # Whatever happens, don't stop processing other instances
except Exception: except Exception:
self.logger.exception('Cannot run usage script(s) for %r:' % self.logger.exception('Cannot run usage script(s) for %r:',
computer_partition.getId()) computer_partition.getId())
for computer_partition_usage in computer_partition_usage_list: for computer_partition_usage in computer_partition_usage_list:
self.logger.info('computer_partition_usage_list: %s - %s' % self.logger.info('computer_partition_usage_list: %s - %s',
(computer_partition_usage.usage, computer_partition_usage.getId())) computer_partition_usage.usage,
computer_partition_usage.getId())
#If there is, at least, one report #If there is, at least, one report
if computer_partition_usage_list != []: if computer_partition_usage_list != []:
...@@ -999,7 +1000,7 @@ class Slapgrid(object): ...@@ -999,7 +1000,7 @@ class Slapgrid(object):
#We generate the final XML report with asXML method #We generate the final XML report with asXML method
computer_consumption = self.asXML(computer_partition_usage_list) computer_consumption = self.asXML(computer_partition_usage_list)
self.logger.info('Final xml report: %s' % computer_consumption) self.logger.info('Final xml report: %s', computer_consumption)
#We test the XML report before sending it #We test the XML report before sending it
if self.validateXML(computer_consumption, computer_consumption_model): if self.validateXML(computer_consumption, computer_consumption_model):
...@@ -1052,7 +1053,7 @@ class Slapgrid(object): ...@@ -1052,7 +1053,7 @@ class Slapgrid(object):
except Exception: except Exception:
pass pass
if computer_partition.getId() in report_usage_issue_cp_list: if computer_partition.getId() in report_usage_issue_cp_list:
self.logger.info('Ignoring destruction of %r, as no report usage was sent' % self.logger.info('Ignoring destruction of %r, as no report usage was sent',
computer_partition.getId()) computer_partition.getId())
continue continue
local_partition.destroy() local_partition.destroy()
...@@ -1068,12 +1069,13 @@ class Slapgrid(object): ...@@ -1068,12 +1069,13 @@ class Slapgrid(object):
computer_partition.destroyed() computer_partition.destroyed()
except NotFoundError: except NotFoundError:
self.logger.debug('Ignored slap error while trying to inform about ' self.logger.debug('Ignored slap error while trying to inform about '
'destroying not fully configured Computer Partition %r' % 'destroying not fully configured Computer Partition %r',
computer_partition.getId()) computer_partition.getId())
except ServerError as server_error: except ServerError as server_error:
self.logger.debug('Ignored server error while trying to inform about ' self.logger.debug('Ignored server error while trying to inform about '
'destroying Computer Partition %r. Error is:\n%r' % 'destroying Computer Partition %r. Error is:\n%r',
(computer_partition.getId(), server_error.args[0])) computer_partition.getId(),
server_error.args[0])
self.logger.info('Finished usage reports.') self.logger.info('Finished usage reports.')
......
...@@ -92,7 +92,7 @@ def launchSupervisord(socket, configuration_file, logger): ...@@ -92,7 +92,7 @@ def launchSupervisord(socket, configuration_file, logger):
result = supervisord_popen.communicate()[0] result = supervisord_popen.communicate()[0]
if supervisord_popen.returncode: if supervisord_popen.returncode:
logger.warning('Supervisord unknown problem: %s' % result) logger.warning('Supervisord unknown problem: %s', result)
return return
try: try:
...@@ -107,13 +107,13 @@ def launchSupervisord(socket, configuration_file, logger): ...@@ -107,13 +107,13 @@ def launchSupervisord(socket, configuration_file, logger):
if status['statename'] == 'RUNNING' and status['statecode'] == 1: if status['statename'] == 'RUNNING' and status['statecode'] == 1:
return return
logger.warning('Wrong status name %(statename)r and code ' logger.warning('Wrong status name %(statename)r and code '
'%(statecode)r, trying again' % status) '%(statecode)r, trying again', status)
trynum += 1 trynum += 1
except Exception: except Exception:
current_timeout = 5 * trynum current_timeout = 5 * trynum
trynum += 1 trynum += 1
else: else:
logger.info('Supervisord started correctly in try %s.' % trynum) logger.info('Supervisord started correctly in try %s.', trynum)
return return
logger.warning('Issue while checking supervisord.') logger.warning('Issue while checking supervisord.')
finally: finally:
......
...@@ -130,8 +130,8 @@ def getCleanEnvironment(logger, home_path='/tmp'): ...@@ -130,8 +130,8 @@ def getCleanEnvironment(logger, home_path='/tmp'):
removed_env.append(k) removed_env.append(k)
changed_env['HOME'] = env['HOME'] = home_path changed_env['HOME'] = env['HOME'] = home_path
for k in sorted(changed_env.iterkeys()): for k in sorted(changed_env.iterkeys()):
logger.debug('Overridden %s = %r' % (k, changed_env[k])) logger.debug('Overridden %s = %r', k, changed_env[k])
logger.debug('Removed from environment: %s' % ', '.join(sorted(removed_env))) logger.debug('Removed from environment: %s', ', '.join(sorted(removed_env)))
return env return env
...@@ -146,9 +146,9 @@ def setRunning(logger, pidfile): ...@@ -146,9 +146,9 @@ def setRunning(logger, pidfile):
# XXX This could use psutil library. # XXX This could use psutil library.
if pid and os.path.exists("/proc/%s" % pid): if pid and os.path.exists("/proc/%s" % pid):
logger.info('New slapos process started, but another slapos ' logger.info('New slapos process started, but another slapos '
'process is aleady running with pid %s, exiting.' % pid) 'process is aleady running with pid %s, exiting.', pid)
sys.exit(10) sys.exit(10)
logger.info('Existing pid file %r was stale, overwritten' % pidfile) logger.info('Existing pid file %r was stale, overwritten', pidfile)
# Start new process # Start new process
write_pid(logger, pidfile) write_pid(logger, pidfile)
...@@ -165,7 +165,7 @@ def write_pid(logger, pidfile): ...@@ -165,7 +165,7 @@ def write_pid(logger, pidfile):
with open(pidfile, 'w') as fout: with open(pidfile, 'w') as fout:
fout.write('%s' % os.getpid()) fout.write('%s' % os.getpid())
except (IOError, OSError): except (IOError, OSError):
logger.critical('slapgrid could not write pidfile %s' % pidfile) logger.critical('slapgrid could not write pidfile %s', pidfile)
raise raise
...@@ -185,7 +185,7 @@ def dropPrivileges(uid, gid, logger): ...@@ -185,7 +185,7 @@ def dropPrivileges(uid, gid, logger):
'gid = %r is too dangerous' % (uid, gid)) 'gid = %r is too dangerous' % (uid, gid))
if current_uid or current_gid: if current_uid or current_gid:
logger.debug('Running as uid = %r, gid = %r, dropping ' logger.debug('Running as uid = %r, gid = %r, dropping '
'not needed and not possible' % (current_uid, current_gid)) 'not needed and not possible', current_uid, current_gid)
return return
# drop privileges # drop privileges
user_name = pwd.getpwuid(uid)[0] user_name = pwd.getpwuid(uid)[0]
...@@ -224,7 +224,7 @@ def dropPrivileges(uid, gid, logger): ...@@ -224,7 +224,7 @@ def dropPrivileges(uid, gid, logger):
else: else:
raise ValueError('%s it was possible to go back to uid = %r and gid = ' raise ValueError('%s it was possible to go back to uid = %r and gid = '
'%r which is fatal.' % (message_pre, current_uid, current_gid)) '%r which is fatal.' % (message_pre, current_uid, current_gid))
logger.debug('Succesfully dropped privileges to uid=%r gid=%r' % (uid, gid)) logger.debug('Succesfully dropped privileges to uid=%r gid=%r', uid, gid)
def bootstrapBuildout(path, logger, buildout=None, def bootstrapBuildout(path, logger, buildout=None,
...@@ -260,9 +260,8 @@ def bootstrapBuildout(path, logger, buildout=None, ...@@ -260,9 +260,8 @@ def bootstrapBuildout(path, logger, buildout=None,
invocation_list.append('bootstrap') invocation_list.append('bootstrap')
try: try:
umask = os.umask(SAFE_UMASK) umask = os.umask(SAFE_UMASK)
logger.debug('Set umask from %03o to %03o' % (umask, SAFE_UMASK)) logger.debug('Set umask from %03o to %03o', umask, SAFE_UMASK)
logger.debug('Invoking: %r in directory %r' % (' '.join(invocation_list), logger.debug('Invoking: %r in directory %r', ' '.join(invocation_list), path)
path))
process_handler = SlapPopen(invocation_list, process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid, logger=logger), preexec_fn=lambda: dropPrivileges(uid, gid, logger=logger),
cwd=path, cwd=path,
...@@ -274,11 +273,11 @@ def bootstrapBuildout(path, logger, buildout=None, ...@@ -274,11 +273,11 @@ def bootstrapBuildout(path, logger, buildout=None,
logger.error(message) logger.error(message)
raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output)) raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output))
except OSError as exc: except OSError as exc:
logger.exception(exc) logger.exception('')
raise BuildoutFailedError(exc) raise BuildoutFailedError(exc)
finally: finally:
old_umask = os.umask(umask) old_umask = os.umask(umask)
logger.debug('Restore umask from %03o to %03o' % (old_umask, umask)) logger.debug('Restore umask from %03o to %03o', old_umask, umask)
def launchBuildout(path, buildout_binary, logger, def launchBuildout(path, buildout_binary, logger,
...@@ -302,9 +301,8 @@ def launchBuildout(path, buildout_binary, logger, ...@@ -302,9 +301,8 @@ def launchBuildout(path, buildout_binary, logger,
invocation_list.extend(additional_buildout_parameter_list) invocation_list.extend(additional_buildout_parameter_list)
try: try:
umask = os.umask(SAFE_UMASK) umask = os.umask(SAFE_UMASK)
logger.debug('Set umask from %03o to %03o' % (umask, SAFE_UMASK)) logger.debug('Set umask from %03o to %03o', umask, SAFE_UMASK)
logger.debug('Invoking: %r in directory %r' % (' '.join(invocation_list), logger.debug('Invoking: %r in directory %r', ' '.join(invocation_list), path)
path))
process_handler = SlapPopen(invocation_list, process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid, logger=logger), preexec_fn=lambda: dropPrivileges(uid, gid, logger=logger),
cwd=path, cwd=path,
...@@ -318,11 +316,11 @@ def launchBuildout(path, buildout_binary, logger, ...@@ -318,11 +316,11 @@ def launchBuildout(path, buildout_binary, logger,
logger.error(message) logger.error(message)
raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output)) raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output))
except OSError as exc: except OSError as exc:
logger.exception(exc) logger.exception('')
raise BuildoutFailedError(exc) raise BuildoutFailedError(exc)
finally: finally:
old_umask = os.umask(umask) old_umask = os.umask(umask)
logger.debug('Restore umask from %03o to %03o' % (old_umask, umask)) logger.debug('Restore umask from %03o to %03o', old_umask, umask)
def updateFile(file_path, content, mode=0o600): def updateFile(file_path, content, mode=0o600):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment