WebFaction
Community site: login faq

I am writing a python script to update a domain on a website, with the API, update_website. however, this seems to fail silently. Other API calls work for me, so I know I'm connected and able to log in. This is following up on my previous question that seanf assisted with.

Here's the code:

TO_SITE = 'example_site'
DOMAINS_TO_MOVE = ['example.com']
webfaction = xmlrpclib.ServerProxy('https://api.webfaction.com/')
session_id, account = webfaction.login(WEBFACTION_USER_NAME, WEBFACTION_USER_PASS, WEBFACTION_SERVER_NAME, 2)
sites = webfaction.list_websites(session_id)
for site in sites:
    if (site['name'] == TO_SITE):
        new_site = site
new_site['subdomains'] += DOMAINS_TO_MOVE
webfaction.update_website(
            session_id, 
            new_site['name'],
            new_site['ip'], 
            new_site['https'], 
            new_site['subdomains'],
            new_site['certificate'], 
            *new_site['website_apps']
            )

The code does not throw any errors, but the website is not being updated.

I pretty-printed the result of the update_website() call, which correctly shows what I sent (sanitized here):

{'certificate': '',
 'https': False,
 'id': [redacted],
 'ip': '207.38.86.154',
 'name': 'my_website',
 'site_apps': [['my_website', '/'],
               ['my_website_static', '/static'],
               ['my_website_media', '/media']],
 'subdomains': ['blue.example.com', 'proxy.example.com']}

And then immediately called list_websites() to see if the website had actually changed:

{'certificate': '',
 'https': False,
 'id': [redacted, but identical],
 'ip': '207.38.86.154',
 'name': 'my_website',
 'subdomains': ['blue.example.com'],
 'website_apps': [['my_website', '/'],
                  ['my_website_static', '/static'],
                  ['my_website_media', '/media']]}

A manual check of my dashboard confirms that the website was not updated.

I notice that the result of the update_website() call shows 'site_apps' as an attribute, but the list_websites() call shows 'website_apps', but it doesn't seem relevant to my problem.

asked 02 Jun, 15:45

bobtiki's gravatar image

bobtiki
297
accept rate: 50%

I notice that the result of the update_website() call shows 'site_apps' as an attribute, but the list_websites() call shows 'website_apps', but it doesn't seem relevant to my problem.

That's correct.

I've conducted several tests on another account using the code you've provided, and it works every time. If you're still having this issue, then please open a support ticket and include the complete unredacted script so that we may investigate further.

(05 Jun, 20:27) seanf ♦♦ seanf's gravatar image

Okay, I'll open a support ticket then. At the moment, the API is giving an SSL error, though, so I can't even test.

(05 Jun, 20:49) bobtiki bobtiki's gravatar image

Just to follow up, for anyone reading this question: It appears that this was a glitch with the one domain, and after deleting and re-creating the domain in my account, it now works.

permanent link

answered 25 Jun, 18:15

bobtiki's gravatar image

bobtiki
297
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×72
×4

question asked: 02 Jun, 15:45

question was seen: 300 times

last updated: 25 Jun, 18:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM