hfaran / slack-export-viewer

A Slack Export archive viewer that allows you to easily view and share your Slack team's export
https://pypi.python.org/pypi/slack-export-viewer
MIT License
901 stars 189 forks source link

Static HTML export fails with AttributeError: 'str' object has no attribute 'mkdir' #181

Open thejoecarroll opened 6 months ago

thejoecarroll commented 6 months ago

Whenever I run any variation of the following command

slack-export-viewer -z ./source.zip --no-browser --html-only -o ./slack-html-archive/

I get the following traceback and no output is created:

/var/folders/8k/jg3z1qgn4jd4dtqf6ycyjjf00000gn/T/_slackviewer/51d45081a3fab68a13f83d9ad6a79da7463aabb8 already exists
Traceback (most recent call last):
  File "/Users/joecarroll/.local/bin/slack-export-viewer", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 95, in main
    freezer.freeze()
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 179, in freeze
    return set(page.url for page in self.freeze_yield())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 179, in <genexpr>
    return set(page.url for page in self.freeze_yield())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joecarroll/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 150, in freeze_yield
    self.root.mkdir(parents=True, exist_ok=True)
    ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'mkdir'
nathang21 commented 6 months ago

I am also getting the same issue, I installed with pipx for a clean isolated env, so I don't think it's anything special about my env. I also tried running with sudo on Mac OS to see if it was a permissions issue.

I'm not able to generate any HTML exports, and because of this i'm not able to view it in the browser either, I get a weird HTTP 403 error when opening the localhost.

Happy to provide more debug information if requested.

System Information:

Mac OS Sonoma 14.2.1
Shell: Zsh
pipx: 1.4.1
slack-export-viewer: 1.3.0

Error:

Traceback (most recent call last):
  File "/Users/nathang21/.local/bin/slack-export-viewer", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 95, in main
    freezer.freeze()
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 179, in freeze
    return set(page.url for page in self.freeze_yield())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 179, in <genexpr>
    return set(page.url for page in self.freeze_yield())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nathang21/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/flask_frozen/__init__.py", line 150, in freeze_yield
    self.root.mkdir(parents=True, exist_ok=True)
    ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'mkdir'
nathang21 commented 6 months ago

I tried rolling back to slack-export-viewer: v1.2.1 and I no longer get the mkdir error (excepted since html-output was recently added), however i'm still getting a very generic HTTP 403 error, with no real details in the Browser.

UI:

Access to localhost was denied
You don't have authorization to view this page.
HTTP ERROR 403

Console: Failed to load resource: the server responded with a status of 403 ()

Network:

Request URL:
http://localhost:5000/
Request Method:
GET
Status Code:
403 Forbidden
Remote Address:
[::1]:5000
Referrer Policy:
strict-origin-when-cross-origin
HTTP/1.1 403 Forbidden
Content-Length: 0
Server: AirTunes/750.14.1
GET / HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Host: localhost:5000
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"

Update: Changing the default port to 5001 and adding the --debug flag seemed to fix the browser issue for me, perhaps that was in-use port was in use somehow. I even went back to v1.3.0 and the UI works, but still the same mkdir error for the html-output.

bhawk123 commented 5 months ago

Browser version works for me but i see the same AttributeError: 'str' object has no attribute 'mkdir' error. Python 3.11 running with sudo.

bhawk123 commented 5 months ago

This change fixed the static html issue for me: https://github.com/hfaran/slack-export-viewer/pull/182

182 opened 3 days ago by [greymd]

thejoecarroll commented 5 months ago

This change fixed the static html issue for me: #182 #182 opened 3 days ago by [greymd]

Looks promising. @bhawk123 , while waiting for v1.3.1 to be released, is there a way to install a version of slack-export-viewer with this fix in place via pip/pipx or would I need to clone the repo and merge the PR in myself and run it from there?