Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

how to resolve "" #2

Open
githubuser00 opened this issue Feb 28, 2018 · 2 comments
Open

how to resolve "" #2

githubuser00 opened this issue Feb 28, 2018 · 2 comments

Comments

@githubuser00
Copy link

jd001@uservm001:/home/jd001# backup_slack --token='here_is_token'
Saving username list to ./users.json
Saving public channels to ./channels
Saving private channels to ./private_channels
Saving direct messages to ./direct_messages
Traceback (most recent call last):
File "/usr/local/bin/backup_slack", line 9, in
load_entry_point('backup-slack==1.0.0', 'console_scripts', 'backup_slack')()
File "/home/jd001/slack/py/src/backup-slack/backup_slack.py", line 252, in main
download_dm_threads(slack, outdir=direct_messages)
File "/home/jd001/slack/py/src/backup-slack/backup_slack.py", line 102, in download_dm_threads
for thread in slack.dm_threads():
File "/home/jd001/slack/py/src/backup-slack/backup_slack.py", line 197, in dm_threads
t['username'] = self.usernames[t['user']]
KeyError: u'F1J6QHSP4'
jd001@uservm001:/home/jd001#

@jforaci
Copy link

jforaci commented Feb 20, 2019

A quick hack to get around this is to change this to a get-with-default style of call in backup_slack.py:197:
t['username'] = self.usernames.get(t['user'],'???')
This fixes the problem where a username was not collected, for whatever reason. The "???" can be any value, and there will be a "???.json" user added under "direct_messages".

@fixbugsnow
Copy link

another soln of this issue has been implement in my fork:
https://github.com/fixbugsnow/backup-slack/blob/master/backup_slack.py#L197-L203

need the below check in "dm_threads(self)" method to make sure user exists in 'self.usernames', otherwise code aborts in the assigment stmt below with a "key error", e.g. when "t" has 'is_user_deleted' as "true" or when t['user'] has spaces in it, each of which results in "key error"s:

if t['user'] in self.usernames:
    t['username'] = self.usernames[t['user']]
    threads.append(t)

and believe it best if we implement the change in this original repo as well, for benefit of users of this repo and it's forks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants