Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85279
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <syedk@pacificloud.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subsequent': 0.05; 'parser': 0.07; 'skip:\\ 20': 0.07; 'socket': 0.07; 'sys': 0.07; 'caller': 0.09; 'ex:': 0.09; 'http': 0.09; 'msg': 0.09; 'resp': 0.09; 'skip:\\ 10': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'sfxlen:2': 0.11; 'python': 0.11; 'def': 0.12; '","': 0.16; '404': 0.16; 'hostname': 0.16; 'httperror': 0.16; 'subject:access': 0.16; 'true:': 0.16; 'url:windows': 0.16; "skip:' 30": 0.19; 'skip:p 40': 0.19; '8bit%:5': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 30': 0.26; 'skip:" 40': 0.26; 'skip:" 20': 0.27; 'skip:_ 20': 0.27; 'to:addr:python-dev': 0.27; 'host': 0.29; 'skip:p 30': 0.29; 'received:209.85.217': 0.29; 'errors': 0.30; 'skip:g 30': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'getting': 0.31; '"': 0.31; "skip:' 40": 0.31; 'class': 0.32; 'skip:m 30': 0.32; 'skip:& 30': 0.33; 'received:209.85': 0.35; 'except': 0.35; 'skip:s 30': 0.35; 'skip:u 20': 0.35; 'received:google.com': 0.35; '8bit%:9': 0.36; 'false': 0.36; 'ubuntu': 0.36; 'skip:4 10': 0.37; 'received:209': 0.37; 'skip:& 10': 0.38; 'skip:_ 30': 0.39; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'skip:u 10': 0.60; 'skip:\xc2 10': 0.60; 'skip:a 30': 0.61; 'first': 0.61; '8bit%:10': 0.64; 'here': 0.66; 'skip:r 40': 0.68; 'skip:r 30': 0.69; 'azure': 0.84; 'httprequest,': 0.84; 'syed': 0.84; 'eliminates': 0.91 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=w14yeysSiLg6T9B+lo+JF0ghA2+zVdaXqibcchsXMwM=; b=Ir4u2y29ffdJwOlqJxNcdNEk8WcxxuirfJa6W914nFs7oMO79bljXPWfN5acdjrONR i5jqd11OCsD3dJ532AZIOqgPQLEbVvuMaj9JbD2yitRLIWtL1fcaNB4+kC8WAU/wx6MS oLYgHSVKXe47pLckX3M8qWLd/5qqdRHzUKoiUeMftEQOFnfu0CoTOfSs2exYOYX5yD7q 2p+3lTalmh/ODjSPGCMjbDoylYy7aZOXZzYwW62asbxYBVNkhavmGtvo5/ZNN2dRzotY 3NVIOzFcBYFd5oVc4Kh9IajKkv8FOZMgCpm26IjocGbDehmJ7uUUz8uURFhGYZLdNq4B xzLg== |
| X-Gm-Message-State | ALoCoQkepzZDmQICZHWhimbHj+bO6jpg8pBegCfz6NS18hgokmih24m2jBzEY1WfBIjuwV9dA/qp |
| MIME-Version | 1.0 |
| X-Received | by 10.152.5.167 with SMTP id t7mr1190999lat.32.1423200380354; Thu, 05 Feb 2015 21:26:20 -0800 (PST) |
| X-Originating-IP | [98.155.101.136] |
| Date | Thu, 5 Feb 2015 21:26:20 -0800 |
| Subject | Azure event hub network access |
| From | syed khalid <syedk@pacificloud.com> |
| To | python-dev@python.org |
| Content-Type | multipart/alternative; boundary=089e01419d861d9d30050e64a9cd |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18500.1423200697.18130.python-list@python.org> (permalink) |
| Lines | 297 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423200697 news.xs4all.nl 2935 [2001:888:2000:d::a6]:60682 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85279 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
I am getting http error 404. I am able to access the site via telnet which
eliminates network issues. Here is the code and subsequent errors
user/bin/python
import sys
import azure
import socket
from azure.servicebus import (
_service_bus_error_handler
)
from azure.servicebus.servicebusservice import (
ServiceBusService,
ServiceBusSASAuthentication
)
from azure.http import (
HTTPRequest,
HTTPError
)
from azure.http.httpclient import _HTTPClient
class EventHubClient(object):
def sendMessage(self,body,partition):
eventHubHost = "pac-ns.servicebus.windows.net"
httpclient = _HTTPClient(service_instance=self)
sasKeyName = "pac-pl"
sasKeyValue = "IhkEepQPLfSy9jo6H2Yxxxxxxxxxxxxxxxxxxxx="
authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)
request = HTTPRequest()
request.method = "POST"
request.host = eventHubHost
request.protocol_override = "https"
# request.path = "/myhub/publishers/" + partition +
"/messages?api-version=20
14-05"
request.body = body
request.headers.append(('Content-Type',
'application/atom+xml;type=entry;cha
rset=utf-8'))
authentication.sign_request(request, httpclient)
request.headers.append(('Content-Length', str(len(request.body))))
status = 0
try:
resp = httpclient.perform_request(request)
status = resp.status
except HTTPError as ex:
status = ex.status
return status
class EventDataParser(object):
def getMessage(self,payload,sensorId):
host = socket.gethostname()
body = "{ \"DeviceId\" : \"" + host + "\",\"SensorData\": [ "
msgs = payload.split(",")
first = True
for msg in msgs:
# print msg
sensorType = msg.split(":")[0]
sensorValue = msg.split(":")[1]
if first == True:
first = False
else:
body += ","
body += "{ \"SensorId\" : \"" + sensorId + "\", \"SensorType\" : \""
+ sen
sorType + "\", \"SensorValue\" : " + sensorValue + " }"
body += "]}"
return body
hubClient = EventHubClient()
parser = EventDataParser()
hostname = socket.gethostname()
sensor = sys.argv[2]
body = parser.getMessage(sys.argv[1],sensor)
hubStatus = hubClient.sendMessage(body,hostname)
# return the HTTP status to the caller
print hubStatus
print hostname
print sensor
~/IOT/AZURE$ python send.py temperature:22,humidity:20 deviceid
404
ubuntu
deviceid
{ "DeviceId" : "ubuntu","SensorData": [ { "SensorId" : "deviceid",
"SensorType" : "temperature", "SensorValue" : 22 },{ "SensorId" :
"deviceid", "SensorType" : "humidity", "SensorValue" : 20 }]}
--
*Syed Khalid*
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Azure event hub network access syed khalid <syedk@pacificloud.com> - 2015-02-05 21:26 -0800
csiph-web