Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ice-dev] Python ICore update code

Alex,

Yeah, that is not the way to fix that problem. I'll look into this at some point. As of, I think, Christmas, the HTTP service worked fine, but I notice now that ICE isn't registering with it correctly. Hopefully I'll fix this later today or tomorrow.

Jay

On Wed, Apr 22, 2015 at 10:30 AM, McCaskey, Alex <mccaskeyaj@xxxxxxxx> wrote:
I forgot to add that the Core as it is could not establish this connection.

Basically, the Core.setHttpService method was being called through the OSGi DS before the Core.start method was being called. The start method initializes the ComponentContext object which is used by the setHttpService method, so the method was throwing a NullPointerException when it went to use the ComponentContext because it hadn’t been set yet.

To fix this, I just added a call to setHttpService at the end of the start method and added a null check for the componentContext in setHttpService. I’m sure there’s a better way to fix this, so I’ll hold of on committing any changes. I didn’t take any time to dig into a better fix.

Alex


On Apr 22, 2015, at 9:53 AM, McCaskey, Alex <mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>> wrote:

Everyone,

Here’s the code I was able to put together to let python post updates to a running Core instance.


import json
import requests
import base64

if __name__ == '__main__':

   # Set the ICore url for updates
   url = "" href="http://localhost:8080/ice/update" target="_blank">http://localhost:8080/ice/update'



   # It requires the username:password be encoded
   s = base64.b64encode('ice:veryice')



   # Set up your json map
   payload = {'some': 'data'}



   # Set up the headers, These have to be here
   headers = {'Authorization' : 'Basic ' + s, 'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}

   # Start a requests session
   session = requests.session()



   # Get the ICE update url
   session.get(url)



   # Post the json message with the given headers
   r = session.post(url, json=payload, headers=headers)
   print r

   # Close the session
   session.close()

Jordan, I imagine you should be able to start experimenting with the Peacock IO stuff using this code now.

Best,

Alex

_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx<mailto:ice-dev@xxxxxxxxxxx>
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev

Alex McCaskey
ORNL Computer Science Research
mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>
(865) 574-8715



_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev



--
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings

Back to the top