Results 1 to 3 of 3

Thread: Indentation issues with python

  1. #1
    Join Date
    Feb 2015
    Beans
    1

    Indentation issues with python

    I downlooaded this code and am attempting to run it. I keep getting indentation error. I realize this is an Ubuntu forum but perhaops there is a way to handle it with a editor which can nrecognize the tab or space issue.

    I have encased the error mesage with line 23 between "****************"
    Code:
    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)
     ********************************************************************def sendMessage(self,body,partition):
          ^
    IndentationError: expected an indented block
    
    ***********************************************************************
    sasKeyName = "SendPolicy"
    sasKeyValue = "erENqf/5wdWCNEbCA9NsDIRqd5MRKdkii07+wezl/NU="
     
    authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)
     
    request = HTTPRequest()
    request.method = "POST"
    request.host = eventHubHost
    request.protocol_override = "https"
    request.path = "/myhub/publishers/" + partition + "/messages?api-version=2014-05
    "
    request.body = body
    request.headers.append(('Content-Type', 'application/atom+xml;type=entry;charset
    =utf-8'))
     
    authentication.sign_request(request, httpclient)
     
    request.headers.append(('Content-Length', str(len(request.body)))
    Last edited by papibe; February 5th, 2015 at 04:38 AM. Reason: please use code tags

  2. #2
    Join Date
    May 2012
    Beans
    39

    Re: Indentation issues with python

    Hi,

    I generally use VIM as an editor. You can try to copy-paste the same code into a file with .py extension and try to open it with VIM. I tried now, though it is still not working, it seems that these errors are manageable.

    So, in short, my advice is to use VIM. You can also try to take a look at https://github.com/mbrochh/vim-as-a-python-ide Maybe this will help you for a long term solution.

    Hope this helps.

  3. #3
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Indentation issues with python

    Just a wild guess:
    Code:
    class EventHubClient(object):
        def sendMessage(self,body,partition):
            eventHubHost = "pac-ns.servicebus.windows.net"
            httpclient = _HTTPClient(service_instance=self)
            sasKeyName = "SendPolicy"
            sasKeyValue = "erENqf/5wdWCNEbCA9NsDIRqd5MRKdkii07+wezl/NU="
    
    
            authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)
    
    
            request = HTTPRequest()
            request.method = "POST"
            request.host = eventHubHost
            request.protocol_override = "https"
            request.path = "/myhub/publishers/" + partition + "/messages?api-version=2014-05"
            request.body = body
            request.headers.append(('Content-Type', 'application/atom+xml;type=entry;charset=utf-8'))
    
    
            authentication.sign_request(request, httpclient)
    
    
            request.headers.append(('Content-Length', str(len(request.body)))
    But actually, you should follow the advice you've got on the python list, and download the code in such a way that will preserve its identation.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •