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

IndexError: list index out of range #63

Closed
accuratefeed opened this issue May 2, 2018 · 10 comments
Closed

IndexError: list index out of range #63

accuratefeed opened this issue May 2, 2018 · 10 comments

Comments

@accuratefeed
Copy link

accuratefeed commented May 2, 2018

I saw #24 and I thought this issue was fixed. I'm getting the following error:

`PS C:\Users\AccurateFeed\downloads> slack-export-viewer --archive ldrs.zip
ldrs.zip extracting to C:\Users\AccurateFeed\AppData\Local\Temp\2_slackviewer\5e226d974f1b15de666dab44c8ea52f329d39587...
ldrs.zip extracted to C:\Users\AccurateFeed\AppData\Local\Temp\2_slackviewer\5e226d974f1b15de666dab44c8ea52f329d39587.

  • Serving Flask app "slackviewer.app" (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://localhost:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [02/May/2018 09:10:57] "GET / HTTP/1.1" 500 -
    Error on request:
    Traceback (most recent call last):
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\werkzeug\serving.py", line 270, in run_wsgi
    execute(self.server.app)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\werkzeug\serving.py", line 258, in execute
    application_iter = app(environ, start_response)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2309, in call return self.wsgi_app(environ, start_response)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2295, in wsgi_app response = self.handle_exception(e)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask_compat.py", line 35, in reraise
    raise value
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request()
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask_compat.py", line 35, in reraise
    raise value
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functionsrule.endpoint
    File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\app.py", line 81, in index
    return channel_name(channels[0])
    IndexError: list index out of range`
@tscritch
Copy link
Contributor

tscritch commented May 2, 2018

Hey @accuratefeed can you add your channels.json file or a snippet of it. The only reason I can see this happening is because there are no channels at all. But if that's not the case I can test with your data.
Thanks!

@accuratefeed
Copy link
Author

Hi @tscritch thanks for replying so quickly. The channels.json file is indeed empty. I contacted slack about this and they're not sure why it's empty either. I do have the folder of the channel I'm trying to view though and the other json files such as users.json has data in it. I'm really just trying to put this 1 channel in a viewable format, so if you have any other suggestions, please let me know!

@tscritch
Copy link
Contributor

tscritch commented May 2, 2018

Wow. Interesting! haha
Well the list of channels is created from that channels.json so we need it... I would suggest for now just manually creating the file. Go to the tests folder in this project and open the zip to find the channels.json and just copy one from there. I'm not sure what else you could do if you don't have data in that file.

@accuratefeed
Copy link
Author

accuratefeed commented May 3, 2018

@tscritch I was able to find a channels.json with data in it. Now I'm getting the following error:

PS C:\Users\AccurateFeed\downloads> slack-export-viewer --archive ldrs.zip ldrs.zip extracting to C:\Users\AccurateFeed\AppData\Local\Temp\2\_slackviewer\25cc1dfe34b348f9bc8e83888e92fcff8f708853... ldrs.zip extracted to C:\Users\AccurateFeed\AppData\Local\Temp\2\_slackviewer\25cc1dfe34b348f9bc8e83888e92fcff8f708853. Traceback (most recent call last): File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\AccurateFeed\AppData\Local\Programs\Python\Python36-32\Scripts\slack-export-viewer.exe\__main__.py", line 9, in <module> File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 722, in __call__ return self.main(*args, **kwargs) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 535, in invoke return callback(*args, **kwargs) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\main.py", line 76, in main configure_app(app, archive, debug) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\main.py", line 41, in configure_app groups = compile_groups(path, user_data, group_data) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\site-packages\slackviewer\archive.py", line 67, in compile_groups day_messages = json.load(f) File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\json\__init__.py", line 296, in load return loads(fp.read(), File "c:\users\AccurateFeed\appdata\local\programs\python\python36-32\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 428: character maps to <undefined>

@tscritch
Copy link
Contributor

tscritch commented May 3, 2018

Ah jeez haha it looks like that would be a character it can't read for some reason... I'm not too experienced with that stuff. @hfaran any insight?

@accuratefeed
Copy link
Author

accuratefeed commented May 4, 2018

I was able to get what I needed using levelsio's script, which I believe this script was based off of. Any idea if hfaran's script is using utf8 or latin1 to decode? Just curious.

@tscritch
Copy link
Contributor

tscritch commented May 4, 2018

Ok great.
It is using utf8 👍

@hfaran
Copy link
Owner

hfaran commented May 5, 2018

@tscritch Looking at the stack trace that @accuratefeed posted, the bug is here:

with io.open(os.path.join(self._PATH, day)) as f:
# loads all messages
day_messages = json.load(f)

You're missing the encoding="utf8" argument on io.open

@hfaran hfaran closed this as completed in 54c60ed May 5, 2018
@hfaran
Copy link
Owner

hfaran commented May 5, 2018

Committed the fix, but I'm gonna wait until your next PR goes to make a new release

@hfaran
Copy link
Owner

hfaran commented May 5, 2018

Actually, I went ahead and released 0.6.0. @accuratefeed please try it

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

No branches or pull requests

3 participants