slack-matrix-migration icon indicating copy to clipboard operation
slack-matrix-migration copied to clipboard

NameError: name 'config' is not defined on migrate

Open PeterSprague opened this issue 2 years ago • 6 comments

(venv) [root@matrix-gei /tmp/slack-matrix-migration/slack-matrix-migration]# python slack-matrix-migration/slack-matrix-migration/migrate.py INFO:SLACK.MIGRATE:Opening zipfile: /tmp/slack-matrix-migration/slack-matrix-migration/data/ve7ppe.slack.dump_aug-14-2022-1604.zip INFO:SLACK.MIGRATE:Found dms.json in archive. Adding. INFO:SLACK.MIGRATE:Warning: Couldn't find groups.json in archive. Skipping. INFO:SLACK.MIGRATE:Warning: Couldn't find mpims.json in archive. Skipping. INFO:SLACK.MIGRATE:Found channels.json in archive. Adding. INFO:SLACK.MIGRATE:Found users.json in archive. Adding. Admin user localpart [root]: gei-admin Password: Traceback (most recent call last): File "/tmp/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/migrate.py", line 969, in main() File "/tmp/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/migrate.py", line 874, in main admin_user, access_token = login(config["homeserver"]) File "/tmp/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/slack-matrix-migration/migrate.py", line 201, in login r = requests.post(url, json=data, verify=config["verify-ssl"]) NameError: name 'config' is not defined

Been all through the README to make sure I followed the instructions. Inserted random strings for AS & HS. Tried to follow the Traceback code, nothing jumped out.

Have a fresh synapse install with an admin user in a FreeBSD jail. Can access from Element app.

Completely stymied. Likely something simple I have missed. Have a few Slack exports I need to get imported for our non-profit volunteers groups before we lose all the history access

PeterSprague avatar Aug 15 '22 01:08 PeterSprague

I also had this issue and noticed it's a scoping issue with the config variable. See my PR #11 for a working version (at least for me).

mbharanya avatar Aug 20 '22 10:08 mbharanya

Hmm, I spent some tine yesterday and today looking through the code. Not seeing how you have changed the scope of config by moving it from the Main function to line #110. I also looked through the history and don't see the change you referred to.

I'm leaning towards passing config_yaml instead of yaml to test_config() on line #869

PeterSprague avatar Aug 22 '22 17:08 PeterSprague

@PeterSprague The scope of config was only inside the main function before my change. Therefore you get your error in admin_user, access_token = login(config["homeserver"]) where config is not defined. For that to work it would need to be passed as an argument (but will break in other places).

As a quick workaround I moved config to the top scope in my PR and it is therefore accessible by admin_user, access_token = login(config["homeserver"]) and the other function you listed. Fixing the NameErrors.

mbharanya avatar Aug 22 '22 20:08 mbharanya

Been refactoring this code over the last week to get it to properly import a "slackdump" export. Running Pylinter and PDB against this code points to all kinds of issues. It seems to be way more than just making a variable local --> global

PeterSprague avatar Aug 29 '22 22:08 PeterSprague

@PeterSprague would you be willing to share your changes? (:

hackmybeer avatar Sep 04 '22 09:09 hackmybeer

Sure, I'll share the fork url once it actually works fully. I've had to move to other work, but plan to get back to this fairly soon. I have ~15 Slack workgroups to move over to a hosted synapse server

PeterSprague avatar Sep 06 '22 18:09 PeterSprague