diff --git a/README.md b/README.md index b99e836..0abf9c6 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ The above command pulled the existing data out of Route53 and placed the results * ALIAS support varies a lot from provider to provider care should be taken to verify that your needs are met in detail. * Dyn's UI doesn't allow editing or view of TTL, but the API accepts and stores the value provided, this value does not appear to be used when served * Dnsimple's uses the configured TTL when serving things through the ALIAS, there's also a secondary TXT record created alongside the ALIAS that octoDNS ignores +* octoDNS itself supports non-ASCII character sets, but in testing Cloudflare is the only provider where that is currently functional end-to-end. Others have failures either in the client libraries or API calls ## Custom Sources and Providers diff --git a/octodns/cmds/report.py b/octodns/cmds/report.py index 06a4484..2b32e77 100755 --- a/octodns/cmds/report.py +++ b/octodns/cmds/report.py @@ -65,7 +65,7 @@ def main(): resolver = AsyncResolver(configure=False, num_workers=int(args.num_workers)) if not ip_addr_re.match(server): - server = str(query(server, 'A')[0]) + server = unicode(query(server, 'A')[0]) log.info('server=%s', server) resolver.nameservers = [server] resolver.lifetime = int(args.timeout) @@ -81,12 +81,12 @@ def main(): stdout.write(',') stdout.write(record._type) stdout.write(',') - stdout.write(str(record.ttl)) + stdout.write(unicode(record.ttl)) compare = {} for future in futures: stdout.write(',') try: - answers = [str(r) for r in future.result()] + answers = [unicode(r) for r in future.result()] except (NoAnswer, NoNameservers): answers = ['*no answer*'] except NXDOMAIN: diff --git a/octodns/provider/base.py b/octodns/provider/base.py index 3f8a5b8..6f67f1c 100644 --- a/octodns/provider/base.py +++ b/octodns/provider/base.py @@ -62,7 +62,7 @@ class BaseProvider(BaseSource): extra = self._extra_changes(existing, changes) if extra: self.log.info('plan: extra changes\n %s', '\n ' - .join([str(c) for c in extra])) + .join([unicode(c) for c in extra])) changes += extra if changes: diff --git a/octodns/provider/ns1.py b/octodns/provider/ns1.py index 80797d8..d214062 100644 --- a/octodns/provider/ns1.py +++ b/octodns/provider/ns1.py @@ -75,9 +75,9 @@ class Ns1Provider(BaseProvider): else: values.extend(answer['answer']) codes.append([]) - values = [str(x) for x in values] + values = [unicode(x) for x in values] geo = OrderedDict( - {str(k): [str(x) for x in v] for k, v in geo.items()} + {unicode(k): [unicode(x) for x in v] for k, v in geo.items()} ) data['values'] = values data['geo'] = geo diff --git a/octodns/provider/plan.py b/octodns/provider/plan.py index 9613809..5944d6e 100644 --- a/octodns/provider/plan.py +++ b/octodns/provider/plan.py @@ -140,11 +140,11 @@ class PlanLogger(_PlanOutput): def _value_stringifier(record, sep): try: - values = [str(v) for v in record.values] + values = [unicode(v) for v in record.values] except AttributeError: values = [record.value] for code, gv in sorted(getattr(record, 'geo', {}).items()): - vs = ', '.join([str(v) for v in gv.values]) + vs = ', '.join([unicode(v) for v in gv.values]) values.append('{}: {}'.format(code, vs)) return sep.join(values) @@ -181,7 +181,7 @@ class PlanMarkdown(_PlanOutput): fh.write(' | ') # TTL if existing: - fh.write(str(existing.ttl)) + fh.write(unicode(existing.ttl)) fh.write(' | ') fh.write(_value_stringifier(existing, '; ')) fh.write(' | |\n') @@ -189,7 +189,7 @@ class PlanMarkdown(_PlanOutput): fh.write('| | | | ') if new: - fh.write(str(new.ttl)) + fh.write(unicode(new.ttl)) fh.write(' | ') fh.write(_value_stringifier(new, '; ')) fh.write(' | ') @@ -197,7 +197,7 @@ class PlanMarkdown(_PlanOutput): fh.write(' |\n') fh.write('\nSummary: ') - fh.write(str(plan)) + fh.write(unicode(plan)) fh.write('\n\n') else: fh.write('## No changes were planned\n') @@ -243,7 +243,7 @@ class PlanHtml(_PlanOutput): # TTL if existing: fh.write(' ') - fh.write(str(existing.ttl)) + fh.write(unicode(existing.ttl)) fh.write('\n ') fh.write(_value_stringifier(existing, '
')) fh.write('\n \n \n') @@ -252,7 +252,7 @@ class PlanHtml(_PlanOutput): if new: fh.write(' ') - fh.write(str(new.ttl)) + fh.write(unicode(new.ttl)) fh.write('\n ') fh.write(_value_stringifier(new, '
')) fh.write('\n ') @@ -260,7 +260,7 @@ class PlanHtml(_PlanOutput): fh.write('\n \n') fh.write(' \n Summary: ') - fh.write(str(plan)) + fh.write(unicode(plan)) fh.write('\n \n\n') else: fh.write('No changes were planned') diff --git a/octodns/record.py b/octodns/record.py index b608ef6..82ee191 100644 --- a/octodns/record.py +++ b/octodns/record.py @@ -122,7 +122,7 @@ class Record(object): self.__class__.__name__, name) self.zone = zone # force everything lower-case just to be safe - self.name = str(name).lower() if name else name + self.name = unicode(name).lower() if name else name self.source = source self.ttl = int(data['ttl']) @@ -274,7 +274,8 @@ class _ValuesMixin(object): return ret def __repr__(self): - values = "['{}']".format("', '".join([str(v) for v in self.values])) + values = "['{}']".format("', '".join([unicode(v) + for v in self.values])) return '<{} {} {}, {}, {}>'.format(self.__class__.__name__, self._type, self.ttl, self.fqdn, values) diff --git a/octodns/zone.py b/octodns/zone.py index bbc38d0..a8a91ca 100644 --- a/octodns/zone.py +++ b/octodns/zone.py @@ -38,7 +38,7 @@ class Zone(object): raise Exception('Invalid zone name {}, missing ending dot' .format(name)) # Force everyting to lowercase just to be safe - self.name = str(name).lower() if name else name + self.name = unicode(name).lower() if name else name self.sub_zones = sub_zones # We're grouping by node, it allows us to efficently search for # duplicates and detect when CNAMEs co-exist with other records diff --git a/tests/test_octodns_provider_base.py b/tests/test_octodns_provider_base.py index 472b008..855efaf 100644 --- a/tests/test_octodns_provider_base.py +++ b/tests/test_octodns_provider_base.py @@ -177,7 +177,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -208,7 +208,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -234,7 +234,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -256,7 +256,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -282,7 +282,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -305,7 +305,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5' @@ -333,7 +333,7 @@ class TestBaseProvider(TestCase): }) for i in range(int(Plan.MIN_EXISTING_RECORDS)): - zone.add_record(Record.new(zone, str(i), { + zone.add_record(Record.new(zone, unicode(i), { 'ttl': 60, 'type': 'A', 'value': '2.3.4.5'