2

I am trying to update my rackspace dns with my IP using a python script.

My script works when I manually enter an IP in it, but dosen't when I get it from the outside, why?

This WORKS:

#!/usr/bin/env python
import clouddns
import requests
r= requests.get(r'http://curlmyip.com/')
ip= '4.4.4.4'
dns = clouddns.connection.Connection('******','********************')
domain = dns.get_domain(name='reazem.net')
record = domain.get_record(name='ssh.reazem.net')
record.update(data=ip, ttl=600)

This DOESN'T:

#!/usr/bin/env python
import clouddns
import requests
r= requests.get(r'http://curlmyip.com/')
**ip= '{}'.format(r.text)**
dns = clouddns.connection.Connection('******','********************')
domain = dns.get_domain(name='reazem.net')
record = domain.get_record(name='ssh.reazem.net')
record.update(data=ip, ttl=600)

Note: print '{}'.format(r.text) succesfully outputs my ip.

Helping you helping me: I just noticed that print '{}'.format(r.text) adds an extra line, how do I avoid that?

For those interested: https://github.com/rackspace/python-clouddns

asked Feb 17, 2013 at 0:45

1 Answer 1

2

Try ip = r.text.strip() to remove the extra newline.

answered Feb 17, 2013 at 0:47
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.