List Info

Thread: Error in my code




Error in my code
user name
2007-04-17 10:28:35
Hi,
 
I am executing following lines of code:
 
def WEP40_KEY(n):
  params = urllib.urlencode({})
  ;headers = {"Connection": "Keep-Alive";,"Authorization": ""}
  conn = httplib.HTTPConnection(HOST)
  conn.request ("GET", "/w_sec.htm HTTP/1.1", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
 ;params = urllib.urlencode({9;wsecurity':";WEP",'wep_auth':"Shared+Key",'wepenc':"128+bit";,'wep_key_no':"key1",';ascii_key1':";12345678901234567890123456",'ascii_key2':"";,'ascii_key3':"",'ascii_key4';:"",'passphrase9;:"",'wpa_psk':"12345678",'key_lifetime':"65535",9;wpa_enc':"TKIP",'save9;:"Save",'message': "",'todo':""})
    headers = {"Connection": "Keep-Alive";,"Authorization": ""}
    conn = httplib.HTTPConnection(HOST)
    conn.request("POST", "w_sec.htm", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
 ;   conn.close()
   
WEP40_KEY(sys.argv)
 
 
 
I am getting following error:
 

C:Documents and SettingsGovindadyaDesktopMarvell>Marvell_WEP40.py 192.168.1.
16
  File "C:Documents and SettingsGovindadyaDesktopMarvellMarvell_WEP40.py",
line 41
    response = conn.getresponse()
  ;           ;           ;        ^
IndentationError: unindent does not match any outer indentation level

 

Can anybody help me out on this?

Best Regards,

Govind

 

Re: Error in my code
user name
2007-04-17 11:43:06
If what you posted is exactly what your code looks like,
then you've got
an indentation problem. Since Python doesn't use {}'s for
code blocks,
it uses indentation instead, and it's somewhat picky about
indentation.

I think all the code after the first conn.request should
line up with
the conn.request.

def WEP40_KEY(n):
  params = urllib.urlencode({})
  headers = {"Connection":
"Keep-Alive","Authorization":
""}
  conn = httplib.HTTPConnection(HOST)
  conn.request ("GET", "/w_sec.htm
HTTP/1.1", params, headers)
  response = conn.getresponse()
  print response.status, response.reason
  params =
urllib.urlencode({'wsecurity':"WEP",'wep_auth':&qu
ot;Shared+Key",'wepenc':"12
8+bit",'wep_key_no':"key1",'ascii_key1':"
;12345678901234567890123456",'as
cii_key2':"",'ascii_key3':"",'ascii_key4
':"",'passphrase':"",'wpa_psk':"
12345678",'key_lifetime':"65535",'wpa_enc':&q
uot;TKIP",'save':"Save",'message
': "",'todo':""}) 
  headers = {"Connection":
"Keep-Alive","Authorization":
""}
  conn = httplib.HTTPConnection(HOST)
  conn.request("POST", "w_sec.htm",
params, headers) 
  response = conn.getresponse()
  print response.status, response.reason
  conn.close() 

It looks like your indenting 2 spaces. I believe the
recommendation is 4
spaces. You might read the style guide.

http
://www.python.org/doc/essays/styleguide.html

Out of curiosity, what editor are you using to write your
code? You can
configure many editors to automatically indent for you,
change tabs to
spaces, and set tabs to 4 spaces.

Mike

> -----Original Message-----
> From: tutor-bouncespython.org 
> [mailto:tutor-bouncespython.org] On Behalf Of
govind goyal
> Sent: Tuesday, April 17, 2007 9:29 AM
> To: tutorpython.org
> Subject: [Tutor] Error in my code
> 
> Hi,
>  
> I am executing following lines of code:
>  
> def WEP40_KEY(n):
>   params = urllib.urlencode({})
>   headers = {"Connection":
"Keep-Alive","Authorization":
""}
>   conn = httplib.HTTPConnection(HOST)
>   conn.request ("GET", "/w_sec.htm
HTTP/1.1", params, headers)
>     response = conn.getresponse()
>     print response.status, response.reason
>  params = 
>
urllib.urlencode({'wsecurity':"WEP",'wep_auth':&qu
ot;Shared+Key",'w
>
epenc':"128+bit",'wep_key_no':"key1",'as
cii_key1':"12345678901
234567890123456",'ascii_key2':"",'ascii_key3'
:"",'ascii_key4':"",'passph
rase':"",'wpa_psk':"1234567>
8",'key_lifetime':"65535",'wpa_enc':"TKI
P",'save':"Save",'mess
> age': "",'todo':""}) 
>     headers = {"Connection":
"Keep-Alive","Authorization":
""}
>     conn = httplib.HTTPConnection(HOST)
>     conn.request("POST",
"w_sec.htm", params, headers) 
>     response = conn.getresponse()
>     print response.status, response.reason
>     conn.close()
>     
> WEP40_KEY(sys.argv)
>  
>  
>  
> I am getting following error:
>  
> 
> C:Documents and 
> SettingsGovindadyaDesktopMarvell>Marvell_WEP40.py
192.168.1.
> 16
>   File "C:Documents and 
>
SettingsGovindadyaDesktopMarvellMarvell_WEP40.py",
> line 41
>     response = conn.getresponse()
>                                 ^
> IndentationError: unindent does not match any outer
indentation level
> 
>  
> 
> Can anybody help me out on this?
> 
> Best Regards,
> 
> Govind
> 
>  
> 
> 
_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )