Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make fastly_service.py work with python3 #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions library/fastly_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
response: Moved Permanently
'''

import httplib
import urllib
import http.client as httplib
import urllib.parse as urllib
import json
import os
import traceback
Expand Down Expand Up @@ -234,7 +234,7 @@ def read_config(self, config, validate_choices, param_name):
return value

def to_json(self):
return {k: v for k, v in self.__dict__.iteritems() if v or not self.schema[k].get('omit_empty', False)}
return {k: v for k, v in self.__dict__.items() if v or not self.schema[k].get('omit_empty', False)}

def __eq__(self, other):
return self.__dict__ == other.__dict__
Expand Down Expand Up @@ -717,15 +717,15 @@ def get_service_by_name(self, service_name):
return self.get_service(service_id)
if response.status == 404:
return None
raise Exception("Error searching for service '%s'" % service_name)
raise Exception("Error searching for service '%s' : %s" % (service_name, response.error()))

def get_service(self, service_id):
response = self._request('/service/%s/details' % urllib.quote(service_id, ''))
if response.status == 200:
return FastlyService(response.payload)
if response.status == 404:
return None
raise Exception("Error fetching service details for service '%s'" % service_id)
raise Exception("Error fetching service details for service '%s' : %s" % (service_id, response.error()))

def create_service(self, service_name):
response = self._request('/service', 'POST', {'name': service_name})
Expand Down Expand Up @@ -1315,7 +1315,7 @@ def run(self):
self.module.exit_json(changed=result.changed, service_id=result.service.id, actions=result.actions)

except Exception as err:
self.module.fail_json(msg=err.message, trace=traceback.format_exc())
self.module.fail_json(msg=str(err), trace=traceback.format_exc())


def main():
Expand Down