alexames / DeltaBot

GNU General Public License v3.0
65 stars 18 forks source link

CSS error #64

Closed PixelOrange closed 3 months ago

PixelOrange commented 10 years ago

https://github.com/alexames/DeltaBot/blob/master/deltabot/deltabot.py#L548

This line (and all other lines with this code) are currently throwing errors that cause the sidebar to not get updated. The rest of the bot appears to be working as intended.

amorde commented 10 years ago

That line is intended to remove the "top1" and "top10" special CSS classes from the previous month. How does that affect the sidebar? I'll look it to it, I think I might just not completely understand the codebase just yet and might be causing side effects.

PixelOrange commented 10 years ago

When the code is interrupted it stops and goes back to the beginning and starts a new comment. It's not error handled very well. Don't waste time trying to account error handling, though. Right now the biggest concern is figuring out why it keeps saying that the CSS is none type. It shouldn't be even if it's not a top 10.

amorde commented 10 years ago

So what can I do to resolve this?

PixelOrange commented 10 years ago

Due to multiple bugs that were not immediately apparent, I'm running this code as it is the most stable copy I could revert to:

https://github.com/alexames/DeltaBot/blob/b3c905b4353403e843ad762ff34b8673d8bb47ce/deltabot/deltabot.py

Somewhere between there and the most recent version of the code, there are parsing bugs that are causing the code to fail. I don't know what exactly is causing the problem nor do I know how to fix it.

amorde commented 10 years ago

What can I do to test it? To me, stuff like this is a major barrier to outside contributors to the product, because I can't really see what my code does until after I've already committed it. There are some tests in there but they are not very extensive.

Since I know the code I contributed doesn't work and has caused some problems, I'm very reluctant to contribute any more in fear of introducing more bugs..

PixelOrange commented 10 years ago

It's hard for me to test as well. I have a test environment I can run it in but I can't model it exactly like CMV so when I run it in there I get different results.

It's a conundrum.

Acebulf commented 10 years ago

In the early days of the project we had built a reddit clone in virtualbox on which we tested the bot in "real situations".

I don't know if you guys are still using it, but if you aren't, that is a distinct possibility for testing.

stahlous commented 10 years ago

The update_scoreboard method runs every time the script goes through an iteration, and it calls the update_top_ten_css method, which contains the line that's throwing the exception, which causes the update_scoreboard method to bomb out as well.

It looks like you're trying to remove old flair every iteration, which is a bit redundant. Regardless of that, you must be trying to change the flair of a user that either doesn't have any flair or maybe is deleted or something like that. You could probably fix this simply with an if statement:

            if current_css:
                new_css = current_css.replace(top_1_css, '').replace(top_10_css, '').strip()
                self.subreddit.set_flair(redditor,flair_text=flair_text,flair_css_class=new_css)
amorde commented 10 years ago

Hmm I see, I'm new to PRAW and I made the poor assumption that if a user did not have flair it would just be empty. I was trying to solve the issue of the previous month's leaderboard having the CSS when they shouldn't.

On May 12, 2014, at 3:19 PM, stahlous notifications@github.com wrote:

The update_scoreboard method runs every time the script goes through an iteration, and it calls the update_top_ten_css method, which contains the line that's throwing the exception, which causes the update_scoreboard method to bomb out as well.

It looks like you're trying to remove old flair every iteration, which is a bit redundant. Regardless of that, you must be trying to change the flair of a user that either doesn't have any flair or maybe is deleted or something like that. You could probably fix this simply with an if statement:

        if current_css:
            new_css = current_css.replace(top_1_css, '').replace(top_10_css, '').strip()
            self.subreddit.set_flair(redditor,flair_text=flair_text,flair_css_class=new_css)

— Reply to this email directly or view it on GitHub.