Freeseer / freeseer

Designed for capturing presentations at conferences. Pre-fill a list of talks to record, record them, and upload them to YouTube with our YouTube Uploader.
http://freeseer.readthedocs.org
GNU General Public License v3.0
216 stars 110 forks source link

Refactor recording api methods and fix logic #613

Closed dbrenden closed 9 years ago

dbrenden commented 9 years ago

Refactored code of recording api setup, teardown, and endpoint functions.

Added a get_current_state_str() method to Multimedia to make some code in recording api cleaner.

Fix to recording api logic determining next_id. Fix to test_server.py teardown to undo patching to media_dict

closes #629

mtomwing commented 9 years ago

Regarding your question on IRC about my try/except suggestion.

Consider this

try:
    with open(your_file) as fd:
        old_stuff = json.load(fd)
except IOError:
    old_stuff = {}

next_id = 1

for key, value in old_stuff.iteritems():
    do_more_things()

If there is nothing from a previous run to load, then the loop will simply do nothing. This is more Pythonic than having branches and repeated logic for each case. We want to be as DRY as possible.

mtomwing commented 9 years ago

Thanks for your contribution!