some random bug fixes
This commit is contained in:
@@ -23,7 +23,6 @@ import uuid
|
||||
from threading import Thread
|
||||
import signal
|
||||
|
||||
from credentials import PlainPasswordCredential
|
||||
from agentdomain import AgentDomain, EventQueue
|
||||
from regiondomain import Region
|
||||
from agent import Agent
|
||||
@@ -94,7 +93,6 @@ def login():
|
||||
agent.firstname = args[0]
|
||||
agent.lastname = args[1]
|
||||
agent.password = password
|
||||
#agent.credentials = PlainPasswordCredential(agent.firstname, agent.lastname, agent.password)
|
||||
|
||||
# let's log in an agent to the agentdomain shall we
|
||||
agent.login(options.loginuri, options.regionuri)
|
||||
|
||||
@@ -25,10 +25,11 @@ from exc import HTTPError
|
||||
from webob import Request, Response
|
||||
|
||||
class StdLibClient(object):
|
||||
"""implement a REST client on top of urllib2"""
|
||||
""" implement a REST client on top of urllib2 """
|
||||
|
||||
def GET(self, url, headers={}):
|
||||
"""GET a resource"""
|
||||
""" GET a resource """
|
||||
|
||||
request = urllib2.Request(url, headers=headers)
|
||||
try:
|
||||
result = urllib2.urlopen(request)
|
||||
@@ -42,7 +43,8 @@ class StdLibClient(object):
|
||||
return response
|
||||
|
||||
def POST(self, url, data, headers={}):
|
||||
"""POST data to a resource"""
|
||||
""" POST data to a resource """
|
||||
|
||||
request = urllib2.Request(url, data, headers=headers)
|
||||
try:
|
||||
result = urllib2.urlopen(request)
|
||||
|
||||
@@ -24,6 +24,9 @@ import re
|
||||
from urllib import quote
|
||||
from urlparse import urlparse, urljoin
|
||||
|
||||
# related
|
||||
from indra.base import llsd
|
||||
|
||||
# pyogp
|
||||
from pyogp.lib.base.caps import Capability
|
||||
from network.stdlib_client import StdLibClient, HTTPError
|
||||
@@ -79,18 +82,20 @@ class Region(object):
|
||||
def get_region_public_seed(self,custom_headers={'Accept' : 'application/llsd+xml'}):
|
||||
"""call this capability, return the parsed result"""
|
||||
|
||||
log(DEBUG, 'Getting region public_seed %s' %(self.uri))
|
||||
log(DEBUG, 'Getting region public_seed %s' %(self.region_uri))
|
||||
|
||||
try:
|
||||
restclient = StdLibClient()
|
||||
response = restclient.GET(self.uri, custom_headers)
|
||||
response = restclient.GET(self.region_uri, custom_headers)
|
||||
except HTTPError, e:
|
||||
if e.code==404:
|
||||
raise exc.ResourceNotFound(self.uri)
|
||||
raise exc.ResourceNotFound(self.region_uri)
|
||||
else:
|
||||
raise exc.ResourceError(self.uri, e.code, e.msg, e.fp.read(), method="GET")
|
||||
raise exc.ResourceError(self.region_uri, e.code, e.msg, e.fp.read(), method="GET")
|
||||
|
||||
log(DEBUG, 'Get of cap %s response is: %s' % (self.uri, response))
|
||||
data = llsd.parse(response.body)
|
||||
|
||||
log(DEBUG, 'Get of cap %s response is: %s' % (self.region_uri, data))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user