Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Compatibility with flask_frozen v1.0.1 #182

Merged
merged 1 commit into from
Jan 26, 2024
Merged

Conversation

greymd
Copy link
Contributor

@greymd greymd commented Jan 14, 2024

This commit addresses an AttributeError encountered when using flask_frozen v1.0.1 with CustomFreezer class. Previously, the CustomFreezer's root property was returning a string representation of the cf_output_dir, which caused compatibility issues with the latest version of flask_frozen.

This update resolves the AttributeError ('str' object has no attribute 'mkdir') and ensures our CustomFreezer class works seamlessly with flask_frozen v1.0.1.

The error resolved by this change:

$ python3 app.py --channels test_channel -z test_dir --html-only -o output
Traceback (most recent call last):
  File "/Users/greymd/repos/hfaran/slack-export-viewer/app.py", line 6, in <module>
    main()
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/slackviewer/main.py", line 95, in main
    freezer.freeze()
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/flask_frozen/__init__.py", line 179, in freeze
    return set(page.url for page in self.freeze_yield())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/site-packages/flask_frozen/__init__.py", line 179, in <genexpr>
    return set(page.url for page in self.freeze_yield())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greymd/repos/hfaran/slack-export-viewer/venv/lib/python3.11/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'

This commit addresses an AttributeError encountered when using flask_frozen v1.0.1 with our CustomFreezer class. Previously, the CustomFreezer's root property was returning a string representation of
the cf_output_dir, which caused compatibility issues with the latest version of flask_frozen.

This update resolves the AttributeError ('str' object has no attribute 'mkdir') and ensures our CustomFreezer class works seamlessly with flask_frozen v1.0.1.
@nathang21
Copy link

Thanks for putting this together, i'm experiencing this in #181, however from a quick test i'm still running into the exact same error. Happy to help debug this PR if you need more information, or I can keep the discussion on the issue.

➜  slack-export-viewer git:(greymd/master) gh pr checkout 182 && git reset --hard
➜  slack-export-viewer git:(greymd/master) slack-export-viewer -z export.zip -p 5001 --debug --html-only
WARNING: DEBUG MODE IS ENABLED!
/var/folders/2h/rxc9f0qd5tg0qy595fzcc9zm0000gp/T/_slackviewer/9de4c73f97cfab33209489aa3663ad2fe558f973 already exists
Traceback (most recent call last):
  File "/usr/local/bin/slack-export-viewer", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slackviewer/main.py", line 95, in main
    freezer.freeze()
  File "/usr/local/lib/python3.11/site-packages/flask_frozen/__init__.py", line 179, in freeze
    return set(page.url for page in self.freeze_yield())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask_frozen/__init__.py", line 179, in <genexpr>
    return set(page.url for page in self.freeze_yield())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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'

@greymd
Copy link
Contributor Author

greymd commented Jan 18, 2024

@nathang21
I apologize if I'm mistaken, but it seems like you may not be using the slack-export-viewer with the changes I've made.
How about trying the following steps?

$ gh pr checkout 182 && git reset --hard
$ pip3 install -r requirements.txt
$ pip3 install -e .
$ slack-export-viewer -z export.zip -p 5001 --debug --html-only

@nathang21
Copy link

@greymd Oops, pip3 install -e . was the piece I was missing, not as familiar with pip as I should be. Thanks for the reply!

@thejoecarroll
Copy link

How soon before this PR is likely to make it into a release? It seems that it would fix an issue I reported, #181 , about being unable to output static HTML, which is important for me.

requirements.txt Show resolved Hide resolved
@hfaran hfaran merged commit 29ee289 into hfaran:master Jan 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants