Rename files and classes.

This commit is contained in:
Matthew Stratford 2020-10-24 14:44:26 +01:00
parent a3b56cb291
commit 490aef95c0
3 changed files with 10 additions and 13 deletions

View file

@ -4,9 +4,9 @@ import json
from mutagen.mp3 import MP3
import copy
from state_manager import stateManager
from state_manager import StateManager
class bapsicle():
class Player():
state = None
__default_state = {
@ -91,7 +91,7 @@ class bapsicle():
def __init__(self, channel, in_q, out_q):
self.state = stateManager("channel" + str(channel), self.__default_state)
self.state = StateManager("channel" + str(channel), self.__default_state)
self.state.update("channel", channel)

View file

@ -1,5 +1,5 @@
import multiprocessing
import bapsicle_standalone
import player
from flask import Flask, render_template, send_from_directory
import json
import sounddevice as sd
@ -129,7 +129,7 @@ if __name__ == "__main__":
# channel_to_q[-1].put_nowait("LOAD:test"+str(channel)+".mp3")
channel_p.append(
multiprocessing.Process(
target=bapsicle_standalone.bapsicle,
target=player.Player,
args=(channel, channel_to_q[-1], channel_from_q[-1])
)
)

View file

@ -1,11 +1,12 @@
import json
import os
class stateManager:
class StateManager:
filepath = None
__state = {}
def __init__(self, name, default_state = None):
def __init__(self, name, default_state=None):
self.filepath = "state/" + name + ".json"
if not os.path.isfile(self.filepath):
self.log("No file found for " + self.filepath)
@ -18,16 +19,15 @@ class stateManager:
self.log("Saving state to " + self.filepath)
file = open(self.filepath, 'r')
file_state = file.read()
file.close()
#TODO: also check for invalid JSON state
# TODO: also check for invalid JSON state
if file_state == "":
print("file empty")
self.state = default_state
else:
@ -54,6 +54,3 @@ class stateManager:
def log(self, msg):
print(msg)