=== modified file 'mandos' --- mandos 2014-07-25 23:16:04 +0000 +++ mandos 2014-07-25 23:32:04 +0000 @@ -338,7 +338,7 @@ elif state == avahi.ENTRY_GROUP_FAILURE: logger.critical("Avahi: Error in group state changed %s", unicode(error)) - raise AvahiGroupError("State changed: {0!s}" + raise AvahiGroupError("State changed: {!s}" .format(error)) def cleanup(self): @@ -395,7 +395,7 @@ """Add the new name to the syslog messages""" ret = AvahiService.rename(self) syslogger.setFormatter(logging.Formatter - ('Mandos ({0}) [%(process)d]:' + ('Mandos ({}) [%(process)d]:' ' %(levelname)s: %(message)s' .format(self.name))) return ret @@ -513,7 +513,7 @@ "rb") as secfile: client["secret"] = secfile.read() else: - raise TypeError("No secret or secfile for section {0}" + raise TypeError("No secret or secfile for section {}" .format(section)) client["timeout"] = string_to_delta(section["timeout"]) client["extended_timeout"] = string_to_delta( @@ -797,7 +797,7 @@ # "Set" method, so we fail early here: if byte_arrays and signature != "ay": raise ValueError("Byte arrays not supported for non-'ay'" - " signature {0!r}".format(signature)) + " signature {!r}".format(signature)) def decorator(func): func._dbus_is_property = True func._dbus_interface = dbus_interface @@ -882,7 +882,7 @@ If called like _is_dbus_thing("method") it returns a function suitable for use as predicate to inspect.getmembers(). """ - return lambda obj: getattr(obj, "_dbus_is_{0}".format(thing), + return lambda obj: getattr(obj, "_dbus_is_{}".format(thing), False) def _get_all_dbus_things(self, thing): @@ -938,7 +938,7 @@ # signatures other than "ay". if prop._dbus_signature != "ay": raise ValueError("Byte arrays not supported for non-" - "'ay' signature {0!r}" + "'ay' signature {!r}" .format(prop._dbus_signature)) value = dbus.ByteArray(b''.join(chr(byte) for byte in value)) @@ -1207,7 +1207,7 @@ attribute.func_closure))) if deprecate: # Deprecate all alternate interfaces - iname="_AlternateDBusNames_interface_annotation{0}" + iname="_AlternateDBusNames_interface_annotation{}" for interface_name in interface_names: @dbus_interface_annotations(interface_name) def func(self): @@ -1222,7 +1222,7 @@ if interface_names: # Replace the class with a new subclass of it with # methods, signals, etc. as created above. - cls = type(b"{0}Alternate".format(cls.__name__), + cls = type(b"{}Alternate".format(cls.__name__), (cls,), attr) return cls return wrapper @@ -1269,7 +1269,7 @@ to the D-Bus. Default: no transform variant_level: D-Bus variant level. Default: 1 """ - attrname = "_{0}".format(dbus_name) + attrname = "_{}".format(dbus_name) def setter(self, value): if hasattr(self, "dbus_object_path"): if (not hasattr(self, attrname) or @@ -2258,7 +2258,7 @@ elif suffix == "w": delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value) else: - raise ValueError("Unknown suffix {0!r}" + raise ValueError("Unknown suffix {!r}" .format(suffix)) except IndexError as e: raise ValueError(*(e.args)) @@ -2281,8 +2281,7 @@ # Close all standard open file descriptors null = os.open(os.devnull, os.O_NOCTTY | os.O_RDWR) if not stat.S_ISCHR(os.fstat(null).st_mode): - raise OSError(errno.ENODEV, - "{0} not a character device" + raise OSError(errno.ENODEV, "{} not a character device" .format(os.devnull)) os.dup2(null, sys.stdin.fileno()) os.dup2(null, sys.stdout.fileno()) @@ -2298,7 +2297,7 @@ parser = argparse.ArgumentParser() parser.add_argument("-v", "--version", action="version", - version = "%(prog)s {0}".format(version), + version = "%(prog)s {}".format(version), help="show version number and exit") parser.add_argument("-i", "--interface", metavar="IF", help="Bind to interface IF") @@ -2443,7 +2442,7 @@ if server_settings["servicename"] != "Mandos": syslogger.setFormatter(logging.Formatter - ('Mandos ({0}) [%(process)d]:' + ('Mandos ({}) [%(process)d]:' ' %(levelname)s: %(message)s' .format(server_settings ["servicename"]))) @@ -2583,7 +2582,7 @@ os.remove(stored_state_path) except IOError as e: if e.errno == errno.ENOENT: - logger.warning("Could not load persistent state: {0}" + logger.warning("Could not load persistent state: {}" .format(os.strerror(e.errno))) else: logger.critical("Could not load persistent state:", @@ -2625,14 +2624,14 @@ if datetime.datetime.utcnow() >= client["expires"]: if not client["last_checked_ok"]: logger.warning( - "disabling client {0} - Client never " + "disabling client {} - Client never " "performed a successful checker" .format(client_name)) client["enabled"] = False elif client["last_checker_status"] != 0: logger.warning( - "disabling client {0} - Client " - "last checker failed with error code {1}" + "disabling client {} - Client last" + " checker failed with error code {}" .format(client_name, client["last_checker_status"])) client["enabled"] = False @@ -2641,7 +2640,7 @@ .utcnow() + client["timeout"]) logger.debug("Last checker succeeded," - " keeping {0} enabled" + " keeping {} enabled" .format(client_name)) try: client["secret"] = ( @@ -2650,7 +2649,7 @@ ["secret"])) except PGPError: # If decryption fails, we use secret from new settings - logger.debug("Failed to decrypt {0} old secret" + logger.debug("Failed to decrypt {} old secret" .format(client_name)) client["secret"] = ( client_settings[client_name]["secret"]) @@ -2804,7 +2803,7 @@ except NameError: pass if e.errno in (errno.ENOENT, errno.EACCES, errno.EEXIST): - logger.warning("Could not save persistent state: {0}" + logger.warning("Could not save persistent state: {}" .format(os.strerror(e.errno))) else: logger.warning("Could not save persistent state:", === modified file 'mandos-ctl' --- mandos-ctl 2014-07-25 23:16:04 +0000 +++ mandos-ctl 2014-07-25 23:32:04 +0000 @@ -83,7 +83,7 @@ def milliseconds_to_string(ms): td = datetime.timedelta(0, 0, 0, ms) return ("{days}{hours:02}:{minutes:02}:{seconds:02}" - .format(days = "{0}T".format(td.days) if td.days else "", + .format(days = "{}T".format(td.days) if td.days else "", hours = td.seconds // 3600, minutes = (td.seconds % 3600) // 60, seconds = td.seconds % 60, @@ -277,7 +277,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument("--version", action="version", - version = "%(prog)s {0}".format(version), + version = "%(prog)s {}".format(version), help="show version number and exit") parser.add_argument("-a", "--all", action="store_true", help="Select all clients") @@ -382,7 +382,7 @@ clients[client_objc] = client break else: - print("Client not found on server: {0!r}" + print("Client not found on server: {!r}" .format(name), file=sys.stderr) sys.exit(1) === modified file 'mandos-monitor' --- mandos-monitor 2014-07-24 02:58:45 +0000 +++ mandos-monitor 2014-07-25 23:32:04 +0000 @@ -161,7 +161,7 @@ self.rejected, client_interface, byte_arrays=True)) - self.logger('Created client {0}' + self.logger('Created client {}' .format(self.properties["Name"]), level=0) def using_timer(self, flag): @@ -179,52 +179,52 @@ def checker_completed(self, exitstatus, condition, command): if exitstatus == 0: - self.logger('Checker for client {0} (command "{1}")' + self.logger('Checker for client {} (command "{}")' ' succeeded'.format(self.properties["Name"], command), level=0) self.update() return # Checker failed if os.WIFEXITED(condition): - self.logger('Checker for client {0} (command "{1}")' - ' failed with exit code {2}' + self.logger('Checker for client {} (command "{}") failed' + ' with exit code {}' .format(self.properties["Name"], command, os.WEXITSTATUS(condition))) elif os.WIFSIGNALED(condition): - self.logger('Checker for client {0} (command "{1}") was' - ' killed by signal {2}' + self.logger('Checker for client {} (command "{}") was' + ' killed by signal {}' .format(self.properties["Name"], command, os.WTERMSIG(condition))) elif os.WCOREDUMP(condition): - self.logger('Checker for client {0} (command "{1}")' - ' dumped core' - .format(self.properties["Name"], command)) + self.logger('Checker for client {} (command "{}") dumped' + ' core'.format(self.properties["Name"], + command)) else: - self.logger('Checker for client {0} completed' + self.logger('Checker for client {} completed' ' mysteriously' .format(self.properties["Name"])) self.update() def checker_started(self, command): """Server signals that a checker started.""" - self.logger('Client {0} started checker "{1}"' + self.logger('Client {} started checker "{}"' .format(self.properties["Name"], command), level=0) def got_secret(self): - self.logger('Client {0} received its secret' + self.logger('Client {} received its secret' .format(self.properties["Name"])) def need_approval(self, timeout, default): if not default: - message = 'Client {0} needs approval within {1} seconds' + message = 'Client {} needs approval within {} seconds' else: - message = 'Client {0} will get its secret in {1} seconds' + message = 'Client {} will get its secret in {} seconds' self.logger(message.format(self.properties["Name"], timeout/1000)) def rejected(self, reason): - self.logger('Client {0} was rejected; reason: {1}' + self.logger('Client {} was rejected; reason: {}' .format(self.properties["Name"], reason)) def selectable(self): @@ -274,9 +274,9 @@ else: timer = datetime.timedelta() if self.properties["ApprovedByDefault"]: - message = "Approval in {0}. (d)eny?" + message = "Approval in {}. (d)eny?" else: - message = "Denial in {0}. (a)pprove?" + message = "Denial in {}. (a)pprove?" message = message.format(str(timer).rsplit(".", 1)[0]) self.using_timer(True) elif self.properties["LastCheckerStatus"] != 0: @@ -290,13 +290,13 @@ timer = max(expires - datetime.datetime.utcnow(), datetime.timedelta()) message = ('A checker has failed! Time until client' - ' gets disabled: {0}' + ' gets disabled: {}' .format(str(timer).rsplit(".", 1)[0])) self.using_timer(True) else: message = "enabled" self.using_timer(False) - self._text = "{0}{1}".format(base, message) + self._text = "{}{}".format(base, message) if not urwid.supports_unicode(): self._text = self._text.encode("ascii", "replace") @@ -469,8 +469,8 @@ self.main_loop = gobject.MainLoop() def client_not_found(self, fingerprint, address): - self.log_message("Client with address {0} and fingerprint" - " {1} could not be found" + self.log_message("Client with address {} and fingerprint {}" + " could not be found" .format(address, fingerprint)) def rebuild(self): @@ -494,7 +494,7 @@ if level < self.log_level: return timestamp = datetime.datetime.now().isoformat() - self.log_message_raw("{0}: {1}".format(timestamp, message), + self.log_message_raw("{}: {}".format(timestamp, message), level=level) def log_message_raw(self, markup, level=1): @@ -513,7 +513,7 @@ """Toggle visibility of the log buffer.""" self.log_visible = not self.log_visible self.rebuild() - self.log_message("Log visibility changed to: {0}" + self.log_message("Log visibility changed to: {}" .format(self.log_visible), level=0) def change_log_display(self): @@ -525,7 +525,7 @@ self.log_wrap = "clip" for textwidget in self.log: textwidget.set_wrap_mode(self.log_wrap) - self.log_message("Wrap mode: {0}".format(self.log_wrap), + self.log_message("Wrap mode: {}".format(self.log_wrap), level=0) def find_and_remove_client(self, path, name): @@ -537,7 +537,7 @@ client = self.clients_dict[path] except KeyError: # not found? - self.log_message("Unknown client {0!r} ({1!r}) removed" + self.log_message("Unknown client {!r} ({!r}) removed" .format(name, path)) return client.delete()