/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:18:46 UTC
  • Revision ID: teddy@recompile.se-20140809131846-2emd272mf9c9wihe
mandos: Replace unicode() with str().

This is in preparation for the coming Python 3 conversion.

* mandos: Replace "str" with "unicode".  All callers changed.

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