Giter Site home page Giter Site logo

djotaku / eldonationtracker Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 2.0 62.54 MB

A Python-based donation tracker for Extra Life streams

Home Page: http://djotaku.github.io/ELDonationTracker/

License: GNU General Public License v3.0

Python 100.00%
extralife streaming obs-studio xsplit hacktoberfest twitch

eldonationtracker's Introduction

Hi there ๐Ÿ‘‹

I'm a Pythonista (๐Ÿ) and sometimes Gopher (๐Ÿน) who creates programs and scripts to solve problems in my life. I'm also dabbling in video game development. My ultimate achievement is the ELDonationTracker below, which is a utility for folks raising money via the Extra Life charity. I also participate in Advent of Code.

โœ Latest Blog Posts

๐Ÿ’ป Check out these Repos

๐Ÿ Python

Extra Life Donation Tracker Donor Drive Python these words don't matter these words don't matter these words don't matter these words don't matter these words don't matter these words don't matter lastfm-mastodon taskwarrior_web

๐Ÿน Go

these words don't matter these words don't matter these words don't matter these words don't matter

๐ŸŽฎ Unity

these words don't matter these words don't matter these words don't matter these words don't matter these words don't matter

๐Ÿ”Œ Electronics

these words don't matter these words don't matter these words don't matter these words don't matter

๐Ÿš€ Misc

these words don't matter these words don't matter

๐ŸŽฒ Github Stats

djotaku's github stats Most Used Programming Languages

eldonationtracker's People

Contributors

dependabot[bot] avatar djotaku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eldonationtracker's Issues

GUI for info and config

Create a GUI similar to bfinley's old GUI that provides info to check that it's working as well as config options

Final 5.0 refactors and cleanups

  • go through each python file (except the ones created by pyuic) and, if you haven't done it already as part of #104 or #105 , make sure all method, function, and variables are Pythonically named.

  • If IPC still exists after #103 consider: Service-oriented architecture (SOA) (Serious Python ch11) - while the structure I notated above might be the right one for ELDT and the GUI, IPC via text files is NOT the way to do IPC. See ZeroMQ (import zmq) as a way to use TCP or Unix sockets to communicate between processes. (Unix sockets are a nope unless it also has a Windows sockets implementation)

  • Should the classes own the attributes rather than so many dictionaries? Is one better than the other? For understanding purposes? For code efficiency? (especially in Participant and Team)

  • Should the donor/donation classes (and their descendants) do the formatting on the fly? Should they store it? Is it better the way I have it now?

  • Consider attr on classes where it makes sense (definitely should be last step of this 5.0 refactor) - see Serious Python Ch 13

General Refactor ticket

Refactor code to eliminate duplications. For example the way that the top Participant Donor and top Team Donor are calculated.

Change Windows Pyinstaller output to be one file

Because of the way it runs (by copying out to the system's /tmp), may need to first have the enhancement to create the participant.conf if the program can't find it. Or make sure to package it via Pyinstaller options and then strongly encourage users to use persistent settings.

KeyError: 'amount'

Hi! Thank you for making this, it's been really great! However, of late, I haven't been able to get recent donations or last donation fields to work at all and it's been giving me an error that says "KeyError: 'amount'", and I can't figure it out. You can see in the screenshots below...

Extra Life Participant ID and/or Team ID
385304

GUI and/or Console
Both!

Describe the bug
When I run the program, it will get most of the data except the data about "recent donations" and "last donations". And it returns this error that says: KeyError: 'amount' and it won't populate the text files.

Error Output
What, if anything, was output to the console when the error happened?

"Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.py", line 926, in _bootstrap_inner
File "gui.py", line 163, in run
File "extralifedonations.py", line 136, in run
File "extralifedonations.py", line 102, in get_donors
File "extralifedonations.py", line 102, in
KeyError: 'amount'"

To Reproduce
I just run the program with my user ID and that's what happens.

Expected behavior
I expected this error to not occur and to see my last donations and recent donations.

Screenshots
If applicable, add screenshots to help explain your problem.

My settings (forgive the blue mark!):
image

What the GUI looks like after I hit "run" (see nothing in the last and recent donations):
image

Console output:
image

Desktop (please complete the following information):

  • OS: Windows 10
  • OS Version 1903
  • Extra Life Donation Tracker Version: 3.0
  • Python Version: ?

Additional context
I tried to delete the persistent settings to see if it would help, but it didn't. Definitely at a loss. Thanks so much!

Documentation in RTD for GUI

What do you believe is missing from the documentaton?

GUI documentation

What page (within the documentation) do you believe it should go on?
Usage and Installation

Text File Missing Error

Getting an error when running the gui that a text file I think it was called something with IRC in it is missing. Just says over and over "did you update the settings" which I have

create unit tests

Create robust unit tests to facilitate refactoring as well as to make it a requirement for pull requests

Team support?

Any chance you can get team support put in by this year's gameday?

Change from using threading in gui.py to using a timer to launch participant actions

depends on issue #102

from my notes:
For the gui.py instead of using threading, you can use a timer to launch Participant.main. This works for this code (compared to, say, the way you'd do flickr project) in that the code runs only every 30 seconds. ALSO it runs relatively quickly. So if the GUI goes unresponsive for a second or two, it shouldn't be a big deal. Probably update the GUI at the end of it - make it part of the same timer. (Currently timer is under the comment: # timer to update the main text) ALSO, this might allow for some simplification that would allow for getting rid of ipc.py/ipc.txt

Handle high volume of donations

This mostly concerns the following areas:

  • A user has a scrolling list so donations can be seen/thanked - right now if they get more than 5 / 30 seconds, some donations will go unacknowledged
  • The new GUI tracker will not show a succession of names if lots of people donate, only the most recent one.

Use __str__ on classes

add str to classes in ELDonation Tracker for better messages on the screen - unit test can be to compare str(class) to what I wrote in the str function

grab team donations

This is in the case that during a livestream a team may be more interested in donations to the team as a whole instead of for the current participant. This issue may involve a refactor to move the Donor out of the extralifedonations.py and into its own file to be used by both extralifedonations.py and team.py. Will probably not be done before this year's Extra Life day.

Add File, Help menu to top of GUI

under help help will load RTD in browser, about is the usual, check for updates -> a way to do this with either pip or GitHub API?

Place the settings file in the recommended location for the OS it's on

Put it in the right lcoation for Windows and Linux

For example $HOME/.config or $HOME/.eldonationtracker and wherever it's expected to be on windows

Then look there first before using the one in the same directory.

Might involve some kind of setup script or a button to persist it?

Refactor Donors/Donations

Currently conflating donors and donations because in my experience they've been on-in-the-same. But somehow (maybe if the donor has an extra-life.org account and is logged in when they donate) some users have donors with multiple donations recorded to the same donor. After game day 2019, I will work to fix this and get it working better.

Current thought is to have separate Donor and Donation classes. Not sure if they need to be explicitly tied together for the data that's being extracted for this program. As of right now, I think not. Donor can be used to find the top donor while Donation can be used for the last N donations, last Donation, etc.

Couldn't get to participant URL

Extra Life Participant ID and/or Team ID
This will help me figure out if I've fixed your issue.
349598

GUI and/or Console
Does the bug only happen on the GUI? Console? both?
Only GUI tested

Describe the bug
When clicking run, Nothing happens, and console shows "Couldn't get to participant URL."

Error Output
What, if anything, was output to the console when the error happened?
"
run button
Starting Thread-1
Couldn't get to participant URL
Check ExtraLifeID.
Or server may be unavailable.
Exception in thread Thread-1:
File "Threading.py", line 926, in _bootstrap_inner
File "gui.py", line 111, in run
File "extralifedonations.py", line 168, in run
File "extralifedonations.py", line 82, in get_participant_JSON
AttributeError: 'Participant' object has no attribute 'participantJSON'

To Reproduce
Steps to reproduce the behavior:

  1. Extract Extra.Life.Donation.Tracker.for.Windows.v2.2.1.zip
  2. Run gui.exe
  3. Click settings, enter EL ID, clear team id
  4. Click save
  5. Click run
  6. Observe error in console

Expected behavior
Gui to populate with EL information and data

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • OS Version [e.g. 22]
  • Extra Life Donation Tracker Version
  • Python Version 3.8

Additional context
Add any other context about the problem here.

Move base API URL to __init__.py

In the package init.py store the base API URL so that it doesn't have to be repeated in more than one place. Import this into extralifedonations.py and team.py

Add a check in the while loop for changed data

So the new API contains a field called numDonations. Can use that to see if there's a new donation and, therefore, not stress the API. They allow 1 call per 15 seconds, but then ask for people on their git page to check this before checking their donors. So there's probably some compute expenses that come from checking the donors.

redo participant class loop

Depends on issue #101 being done first

This has a few purposes:

  • Make sure the loop is as efficient as possible to reduce API hits
  • Moving the looping to the if name=="main" so that others importing participant.py can do a loop run and then do other things before another loop run
  • Allows gui.py to remove the complications of threading and just set off the loop via a timer - eliminating a class of bugs (like hitting run more than once will start another thread) and making maintenance simpler

Will potentially want to split the loop off into a few sub-methods to make things cleaner - maybe/maybe not. Will depend on what what looks like.

A few notes I've made over the past few months:

Note Set 1:

For team, if the number of donations has not changed, donโ€™t check the other API points

For a refactor of the running code (frankly itโ€™s not elegant and itโ€™s too long) and participant part of it, would add
the following methods:

Update self
Grabs participant info
If changes in numDonations:
Call update donations list
Call update donor List
Write dictionary files to disk
Update donations list
Get donations
Get top donations (is there a way to tell via logic if this is necessary?)
Update donors list
Get donors
Get top donors (again, is there a way to tell via logic if this is necessary?)

Have a class variable that knows if first run or not

Note Set 2

from google docs - compare to above:

Run Order
Get participant data
If > 0 donations, get donation and donor data
Write text files
Get team data
If > 0 participants, get participant data
Write text files
Start loop (every 10s)
Get participant data (every 3rd time through the loop)
If donations have gone up ->
Append new donations to front of list (so theyโ€™re 0, 1, 2โ€ฆ.)
Append new donations to last donation list (so theyโ€™re 2, 1, 0)
Grab top donor
Make text files (except last donation)
Each time through loop, if last donations list isnโ€™t empty, pop a donor and write the last donation text file, also IPC file so that tracker will know to push a new name to GUI

For reducing API hits:
In team.py have a new function that is called from Participant class. This function determines whether to run both team_run and participant_run. Participant run should only run on the first time and if something in team JSON indicates thereโ€™s been a change. Best bet is to check if donation numbers have changed.


The note sets were written weeks or months apart and may or may not be compatible. Will need to see which has better ideas.

KeyError: 'displayName'

I'm not sure if it's me or not, but I'm getting the following error when trying to run the extralifedonations.py, both via the gui.py or directly.

Traceback (most recent call last):
File "extralifedonations.py", line 179, in
p.run()
File "extralifedonations.py", line 154, in run
self.get_donors()
File "extralifedonations.py", line 101, in get_donors
self.donorlist = [Donor(self.donorJSON[donor]['displayName'], self.donorJSON[donor].get('message'), self.donorJSON[donor]['amount']) for donor in range(0, len(self.donorJSON))]
File "extralifedonations.py", line 101, in
self.donorlist = [Donor(self.donorJSON[donor]['displayName'], self.donorJSON[donor].get('message'), self.donorJSON[donor]['amount']) for donor in range(0, len(self.donorJSON))]
KeyError: 'displayName'

It worked fine a couple of weeks ago, but it's throwing this tonight after I updated to your newest release. I updated Python to 3.7.5(I had 3.7.4 before)as well just to be sure, but I get the same error.

I did try to chase down the issue, but unfortunately my python skills aren't up to this yet.

Change participant.conf finder code to create one if can't find it

On Linux (for some reason) things have changed recently where the pyinstaller GUI cannot find participant.conf even if it's in the same folder. (I think same goes for pypi install). So, have it just create the file in the xdg location if this happens. (Will just make it work this way for both Windows and Linux)

Windows build throwing error about Teams

Extra Life Participant ID and/or Team ID
This will help me figure out if I've fixed your issue.

GUI and/or Console
Does the bug only happen on the GUI? Console? both?
Both, though running the GUI allows everything to continue working, running on the console causes it to crash out on the error.

Describe the bug
Throws an error regardless of team status.

Error Output
Starting Thread-1
Couldn't get to team URL.
Check team ID.
Or server may be unavailable.
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.py", line 926, in _bootstrap_inner
File "gui.py", line 111, in run
File "extralifedonations.py", line 176, in run
File "team.py", line 113, in team_run
File "team.py", line 25, in get_team_json
AttributeError: 'Team' object has no attribute 'team_json'

To Reproduce
Steps to reproduce the behavior:
Running the GUI.exe or the extralifedonations.py generates the error. Has been tested by wiping total local contents of folder, replacing from downloaded archive and configuring from GUI.

Desktop (please complete the following information):

  • OS: Win10
  • Extra Life Donation Tracker Version: 2.2
  • Python Version: 3.7

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.