DeltaBot icon indicating copy to clipboard operation
DeltaBot copied to clipboard

CSS error

Open PixelOrange opened this issue 10 years ago • 9 comments

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.

PixelOrange avatar Apr 20 '14 10:04 PixelOrange

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.

amorde avatar Apr 20 '14 11:04 amorde

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.

PixelOrange avatar Apr 20 '14 11:04 PixelOrange

So what can I do to resolve this?

amorde avatar Apr 26 '14 22:04 amorde

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.

PixelOrange avatar Apr 27 '14 00:04 PixelOrange

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..

amorde avatar Apr 27 '14 00:04 amorde

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.

PixelOrange avatar Apr 27 '14 00:04 PixelOrange

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.

Acebulf avatar Apr 29 '14 18:04 Acebulf

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)

stahlous avatar May 12 '14 22:05 stahlous

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 [email protected] 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.

amorde avatar May 13 '14 06:05 amorde