/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2014-08-09 13:12:55 UTC
  • Revision ID: teddy@recompile.se-20140809131255-lp31j98u2pl0xpe6
mandos: Stop using str() and remove unnecessary unicode() calls.

* mandos (if_nametoindex): Use "bytes" literal instead of str().
  (initlogger): Use a unicode string for log device.
  (AvahiError.__unicode__): Removed.
  (DBusPropertyException.__unicode__): - '' -
  (ClientDBus.Secret_dbus_property): Use bytes() instead of str().
  (IPv6_TCPServer.server_bind): Use .encode() instead of str().
  (string_to_delta): Removed unnecessary unicode() call.
  (main): Use "isinstance(x, bytes)" instead of "type(x) is str", use
          .decode() instead of unicode(), and use .encode() instead of
          str().

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
    except ImportError:
89
89
        SO_BINDTODEVICE = None
90
90
 
91
 
if sys.version_info.major == 2:
92
 
    str = unicode
93
 
 
94
91
version = "1.6.8"
95
92
stored_state_file = "clients.pickle"
96
93
 
282
279
                            " after %i retries, exiting.",
283
280
                            self.rename_count)
284
281
            raise AvahiServiceError("Too many renames")
285
 
        self.name = str(self.server
286
 
                        .GetAlternativeServiceName(self.name))
 
282
        self.name = unicode(self.server
 
283
                            .GetAlternativeServiceName(self.name))
287
284
        logger.info("Changing Zeroconf service name to %r ...",
288
285
                    self.name)
289
286
        self.remove()
337
334
            self.rename()
338
335
        elif state == avahi.ENTRY_GROUP_FAILURE:
339
336
            logger.critical("Avahi: Error in group state changed %s",
340
 
                            str(error))
 
337
                            unicode(error))
341
338
            raise AvahiGroupError("State changed: {!s}"
342
339
                                  .format(error))
343
340
    
688
685
        if self.checker is None:
689
686
            # Escape attributes for the shell
690
687
            escaped_attrs = { attr:
691
 
                                  re.escape(str(getattr(self, attr)))
 
688
                                  re.escape(unicode(getattr(self,
 
689
                                                            attr)))
692
690
                              for attr in self.runtime_expansions }
693
691
            try:
694
692
                command = self.checker_command % escaped_attrs
1225
1223
        Client.__init__(self, *args, **kwargs)
1226
1224
        # Only now, when this client is initialized, can it show up on
1227
1225
        # the D-Bus
1228
 
        client_object_name = str(self.name).translate(
 
1226
        client_object_name = unicode(self.name).translate(
1229
1227
            {ord("."): ord("_"),
1230
1228
             ord("-"): ord("_")})
1231
1229
        self.dbus_object_path = (dbus.ObjectPath
1486
1484
    def Host_dbus_property(self, value=None):
1487
1485
        if value is None:       # get
1488
1486
            return dbus.String(self.host)
1489
 
        self.host = str(value)
 
1487
        self.host = unicode(value)
1490
1488
    
1491
1489
    # Created - property
1492
1490
    @dbus_service_property(_interface, signature="s", access="read")
1590
1588
    def Checker_dbus_property(self, value=None):
1591
1589
        if value is None:       # get
1592
1590
            return dbus.String(self.checker_command)
1593
 
        self.checker_command = str(value)
 
1591
        self.checker_command = unicode(value)
1594
1592
    
1595
1593
    # CheckerRunning - property
1596
1594
    @dbus_service_property(_interface, signature="b",
1652
1650
    def handle(self):
1653
1651
        with contextlib.closing(self.server.child_pipe) as child_pipe:
1654
1652
            logger.info("TCP connection from: %s",
1655
 
                        str(self.client_address))
 
1653
                        unicode(self.client_address))
1656
1654
            logger.debug("Pipe FD: %d",
1657
1655
                         self.server.child_pipe.fileno())
1658
1656