Fix recording through ecasound

This is part 2 of fixing ecasound recordings from line-in. Part 1 restored the User-Interface, part 2 takes care of getting to the point where ecasound gets started, records something and uploads it through rest when done. Part 3 will take care of making sure that the recorded file is mapped to the show and not just stored as a new track.

I refactored api_clients to not use urllib2 for posting multipart data since I was loosing my sanity over it and requests seems to have a modern approach to doing this compared to what api_clients was previously doing.
This commit is contained in:
Lucas Bickel 2017-03-24 15:12:06 +01:00
parent 674f17213f
commit b267036483
5 changed files with 55 additions and 36 deletions

View file

@ -95,7 +95,7 @@ class ShowRecorder(Thread):
self.logger.info("starting record")
self.logger.info("command " + command)
self.p = Popen(args,stdout=PIPE)
self.p = Popen(args,stdout=PIPE,stderr=PIPE)
#blocks at the following line until the child process
#quits
@ -129,11 +129,10 @@ class ShowRecorder(Thread):
# Register the streaming http handlers with urllib2
register_openers()
# headers contains the necessary Content-Type and Content-Length
# datagen is a generator object that yields the encoded parameters
datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance})
# files is what requests actually expects
files = {'file': open(filepath, "rb"), 'name': filename, 'show_instance': str(self.show_instance)}
self.api_client.upload_recorded_show(datagen, headers)
self.api_client.upload_recorded_show(files, self.show_instance)
def set_metadata_and_save(self, filepath):
"""