Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85280
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <Steve.Dower@microsoft.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; 'subject:: [': 0.04; 'subsequent': 0.05; 'subject:Python': 0.06; 'parser': 0.07; 'skip:\\ 20': 0.07; 'socket': 0.07; 'sys': 0.07; 'steve': 0.09; '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; 'python': 0.11; 'def': 0.12; 'posted': 0.15; 'windows': 0.15; '","': 0.16; '"python': 0.16; '404': 0.16; 'hostname': 0.16; 'httperror': 0.16; 'subject:Dev': 0.16; 'subject:access': 0.16; 'to:name:python-dev@python.org': 0.16; 'true:': 0.16; 'url:windows': 0.16; "skip:' 30": 0.19; 'subject:] ': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'cheers,': 0.24; 'cc: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; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'host': 0.29; 'skip:p 30': 0.29; 'errors': 0.30; 'skip:g 30': 0.30; 'code': 0.31; 'getting': 0.31; '"': 0.31; 'class': 0.32; 'skip:& 30': 0.33; 'except': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'false': 0.36; 'ubuntu': 0.36; 'email addr:python.org': 0.37; 'skip:& 10': 0.38; 'skip:_ 30': 0.39; 'skip:& 20': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:u 10': 0.60; 'skip:a 30': 0.61; 'first': 0.61; "you'll": 0.62; 'charset:windows-1256': 0.64; 'email name :python-list': 0.65; 'phone': 0.66; 'here': 0.66; 'skip:r 40': 0.68; 'skip:r 30': 0.69; '[python-dev]': 0.84; 'azure': 0.84; 'email name:python-dev': 0.84; 'httprequest,': 0.84; 'hub': 0.84; 'syed': 0.84; 'eliminates': 0.91 |
| From | Steve Dower <Steve.Dower@microsoft.com> |
| To | syed khalid <syedk@pacificloud.com>, "python-dev@python.org" <python-dev@python.org> |
| Subject | RE: [Python-Dev] Azure event hub network access |
| Thread-Topic | [Python-Dev] Azure event hub network access |
| Thread-Index | AQHQQc2SZXgSTFC6NUasF0d5Ov6HEZzjHKlf |
| Date | Fri, 6 Feb 2015 05:45:37 +0000 |
| References | <CAHc+NX3Qpum5sVbVepVecm_eSsv-eCW6gCKi+S+-fVUc8r2f8A@mail.gmail.com> |
| In-Reply-To | <CAHc+NX3Qpum5sVbVepVecm_eSsv-eCW6gCKi+S+-fVUc8r2f8A@mail.gmail.com> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [166.171.250.103] |
| authentication-results | pacificloud.com; dkim=none (message not signed) header.d=none; |
| x-microsoft-antispam | BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0735; |
| x-exchange-antispam-report-test | UriScan:; |
| x-exchange-antispam-report-cfa-test | BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB0735; |
| x-forefront-prvs | 047999FF16 |
| x-forefront-antispam-report | SFV:NSPM; SFS:(10019020)(2900100001)(122556002)(106116001)(86612001)(76576001)(46102003)(2950100001)(92566002)(66066001)(40100003)(16601075003)(16236675004)(33656002)(19580395003)(19580405001)(2656002)(86362001)(15975445007)(50986999)(102836002)(74316001)(87936001)(19617315012)(62966003)(76176999)(77156002)(54356999); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB0735; H:DM2PR0301MB0734.namprd03.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; |
| Content-Type | multipart/alternative; boundary="_000_DM2PR0301MB07342199859E34D9429CC070F5380DM2PR0301MB0734_" |
| MIME-Version | 1.0 |
| X-OriginatorOrg | microsoft.onmicrosoft.com |
| X-MS-Exchange-CrossTenant-originalarrivaltime | 06 Feb 2015 05:45:37.6833 (UTC) |
| X-MS-Exchange-CrossTenant-fromentityheader | Hosted |
| X-MS-Exchange-CrossTenant-id | 72f988bf-86f1-41af-91ab-2d7cd011db47 |
| X-MS-Exchange-Transport-CrossTenantHeadersStamped | DM2PR0301MB0735 |
| Cc | "python-list@python.org" <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.18501.1423201542.18130.python-list@python.org> (permalink) |
| Lines | 394 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423201542 news.xs4all.nl 2923 [2001:888:2000:d::a6]:35247 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85280 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
This would be much better posted on the github page for the project. I don't have the URL handy, but if you search github for "Python Azure SDK" you'll find it.
Cheers,
Steve
Sent from my Windows Phone
________________________________
From: syed khalid<mailto:syedk@pacificloud.com>
Sent: 2/5/2015 21:27
To: python-dev@python.org<mailto:python-dev@python.org>
Cc: python-list@python.org<mailto:python-list@python.org>
Subject: [Python-Dev] Azure event hub network access
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<http://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
RE: [Python-Dev] Azure event hub network access Steve Dower <Steve.Dower@microsoft.com> - 2015-02-06 05:45 +0000
csiph-web