awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.19k stars 773 forks source link

Documentation generation fails on Python 2.6.9 #131

Open joguSD opened 8 years ago

joguSD commented 8 years ago

The HTML parser blows up when trying to generate documentation for the first time on v2.6.9.

First run, creating autocomplete index...
Traceback (most recent call last):
  File "/Users/guymonj/.pyenv/versions/2.6.9/bin/aws-shell", line 9, in <module>
    load_entry_point('aws-shell', 'console_scripts', 'aws-shell')()
  File "/Users/guymonj/Code/aws-shell/awsshell/__init__.py", line 47, in main
    write_index(index_file)
  File "/Users/guymonj/Code/aws-shell/awsshell/makeindex.py", line 67, in write_index
    index_command(current, help_command)
  File "/Users/guymonj/Code/aws-shell/awsshell/makeindex.py", line 59, in index_command
    index_command(child, sub_help_command)
  File "/Users/guymonj/Code/aws-shell/awsshell/makeindex.py", line 59, in index_command
    index_command(child, sub_help_command)
  File "/Users/guymonj/Code/aws-shell/awsshell/makeindex.py", line 40, in index_command
    arg_obj.documentation.split('\n')[0])
  File "/Users/guymonj/Code/aws-shell/awsshell/utils.py", line 22, in remove_html
    s.feed(html)
  File "/Users/guymonj/.pyenv/versions/2.6.9/lib/python2.6/HTMLParser.py", line 108, in feed
    self.goahead(0)
  File "/Users/guymonj/.pyenv/versions/2.6.9/lib/python2.6/HTMLParser.py", line 148, in goahead
    k = self.parse_starttag(i)
  File "/Users/guymonj/.pyenv/versions/2.6.9/lib/python2.6/HTMLParser.py", line 229, in parse_starttag
    endpos = self.check_for_whole_start_tag(i)
  File "/Users/guymonj/.pyenv/versions/2.6.9/lib/python2.6/HTMLParser.py", line 304, in check_for_whole_start_tag
    self.error("malformed start tag")
  File "/Users/guymonj/.pyenv/versions/2.6.9/lib/python2.6/HTMLParser.py", line 115, in error
    raise HTMLParseError(message, self.getpos())
HTMLParser.HTMLParseError: malformed start tag, at line 1, column 275

The documentation causing the issue is deploy push:

Required. Information about the location of the application revision to be uploaded to Amazon S3. You must specify both a bucket and a key that represent the Amazon S3 bucket name and the object key name. Content will be zipped before uploading. Use the format s3:///

Specifically: Use the format s3://\<bucket\>/\<key\> is being incorrectly interpreted as HTML This can be seen on the online docs here: http://docs.aws.amazon.com/cli/latest/reference/deploy/push.html Which seems to strip the 'tags' to Use the format s3:///

This also affects the CLI docs as the parameter descriptions are missing after this option:

OPTIONS
       --application-name  (string)  Required.  The name of the AWS CodeDeploy
       application to be associated with the application revision.

       --s3-location (string)

       --ignore-hidden-files | --no-ignore-hidden-files (boolean)

       --source (string)

       --description (string)

This appears to work properly on all other versions of Python (2.7, 3.3, 3.4, 3.5). The documentation on the CLI for these versions strips the documentation to Use the format s3:/// much like the online docs, which is still not optimal.

Potentially related to #107, but this is a different error.

jolexa commented 7 years ago

I can reproduce this issue with python 2.7.12. Here are the steps to reproduce:

$ cat Dockerfile
FROM amazonlinux:2016.09

RUN yum install -y python-pip \
    && pip-2.6 install aws-shell

CMD aws-shell
$ docker build -t my-aws-shell .
Sending build context to Docker daemon 63.49 kB
Step 1/3 : FROM amazonlinux:2016.09
2016.09: Pulling from library/amazonlinux
Digest: sha256:f1d4ae3f7261a72e98c6ebefe9985cf10a0ea5bd762585a43e0700ed99863807
Status: Downloaded newer image for amazonlinux:2016.09
 ---> 5b52b314511a
Step 2/3 : RUN yum install -y python-pip     && pip-2.6 install aws-shell
 ---> Using cache
 ---> 25d134eee127
Step 3/3 : CMD aws-shell
 ---> Using cache
 ---> 7086127e6c1b
Successfully built 7086127e6c1b
$ docker run -it my-aws-shell
First run, creating autocomplete index...
Traceback (most recent call last):
  File "/usr/local/bin/aws-shell", line 9, in <module>
    load_entry_point('aws-shell==0.1.1', 'console_scripts', 'aws-shell')()
  File "/usr/local/lib/python2.6/site-packages/awsshell/__init__.py", line 47, in main
    write_index(index_file)
  File "/usr/local/lib/python2.6/site-packages/awsshell/makeindex.py", line 67, in write_index
    index_command(current, help_command)
  File "/usr/local/lib/python2.6/site-packages/awsshell/makeindex.py", line 59, in index_command
    index_command(child, sub_help_command)
  File "/usr/local/lib/python2.6/site-packages/awsshell/makeindex.py", line 59, in index_command
    index_command(child, sub_help_command)
  File "/usr/local/lib/python2.6/site-packages/awsshell/makeindex.py", line 40, in index_command
    arg_obj.documentation.split('\n')[0])
  File "/usr/local/lib/python2.6/site-packages/awsshell/utils.py", line 22, in remove_html
    s.feed(html)
  File "/usr/lib64/python2.6/HTMLParser.py", line 108, in feed
    self.goahead(0)
  File "/usr/lib64/python2.6/HTMLParser.py", line 148, in goahead
    k = self.parse_starttag(i)
  File "/usr/lib64/python2.6/HTMLParser.py", line 229, in parse_starttag
    endpos = self.check_for_whole_start_tag(i)
  File "/usr/lib64/python2.6/HTMLParser.py", line 304, in check_for_whole_start_tag
    self.error("malformed start tag")
  File "/usr/lib64/python2.6/HTMLParser.py", line 115, in error
    raise HTMLParseError(message, self.getpos())
HTMLParser.HTMLParseError: malformed start tag, at line 1, column 275
$ docker run -it my-aws-shell python --version
Python 2.7.12
joguSD commented 7 years ago

@jolexa You're actually installing / running the shell using Python 2.6, as can be seen in your stack trace. pip-2.6 install aws-shell seems suspect.

aaronlelevier commented 6 years ago

Was there ever a fix for this error?

I'm running into the same error with Python2.6 and upgrading the Python version isn't an option at this point.