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

Tried to run with pycharm, got 'NoneType' object has no attribute 'read' #51

Closed
vizakenjaro opened this issue Mar 2, 2016 · 7 comments
Assignees
Labels

Comments

@vizakenjaro
Copy link

I placed shreddit.cfg and shreddit.py on the desktop folder (OS X).
Then run it under IDE environment called PyCharm.
Installed modules yaml and praw.

Got error:
(line 50 in shreddit.py)
config.read(args.config)
AttributeError: 'NoneType' object has no attribute 'read'

@x89
Copy link
Owner

x89 commented Mar 2, 2016 via email

@vizakenjaro
Copy link
Author

What?

@kevinhikaruevans
Copy link

It looks like config is just set to None right before read is called. Previously config was being set to simpleconfigparser(), but that's no longer being imported.

I ran it without the -c shreddit.yml args and it worked for me (python ./shreddit.py instead of python ./shreddit.py -c shreddit.yml)...

@x89
Copy link
Owner

x89 commented Mar 3, 2016 via email

@Tjololo12
Copy link

Looks like a simple fix. I edited the code and changed around line 50:

config = None
if args.config:
    config.read(args.config)
else:
    with open('shreddit.yml', 'r') as fh:
        config = yaml.safe_load(fh)
if config is None:
    raise Exception("No config options passed!")

to:

config = None
if args.config:
    with open(args.config, 'r') as fh:
      config = yaml.safe_load(fh)
    #config.read(args.config)
else:
    with open('shreddit.yml', 'r') as fh:
        config = yaml.safe_load(fh)
if config is None:
    raise Exception("No config options passed!")

Note that adding the "with open(args.config, 'r' as fh:" line will open the config file you pass.

@x89 x89 self-assigned this Mar 12, 2016
@x89 x89 added the bug label Mar 12, 2016
@cereal-killer
Copy link

Hey there, this should be fixed by #54

@x89
Copy link
Owner

x89 commented Apr 4, 2016

Merged (can't test at the moment but looks like it should work).

Pull again @vizakenjaro and see if that works for you.

Thanks as well @Tjololo12.

@x89 x89 closed this as completed Apr 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants