Testing and slow move toward a standard architecture

updates on Attrerrors
Added FREEZEINPUT
This commit is contained in:
Maximilien Rigaut 2021-10-31 20:12:41 +01:00
parent ddfe2cff80
commit 5ab6b7752e
32 changed files with 49 additions and 63 deletions

6
.gitignore vendored
View File

@ -102,3 +102,9 @@ venv.bak/
# mypy
.mypy_cache/
/.idea/midiRebind.iml
/.idea/misc.xml
/.idea/modules.xml
/.idea/inspectionProfiles/profiles_settings.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/vcs.xml

14
.gitmodules vendored
View File

@ -1,12 +1,6 @@
[submodule "minitest"]
path = minitest
url = https://github.com/Malphaet/minitest.git
[submodule "panaremote"]
path = panaremote
[submodule "src/midiRebind/panaremote"]
path = src/midiRebind/panaremote
url = git@github.com:Malphaet/panaremote.git
[submodule "pythonAnalogWay"]
path = pythonAnalogWay
[submodule "src/midiRebind/pythonAnalogWay"]
path = src/midiRebind/pythonAnalogWay
url = git@github.com:Malphaet/pythonAnalogWay.git
[submodule "pyUsage"]
path = pyUsage
url = git@github.com:Malphaet/pyUsage.git

13
midiRebind.py → main.py Executable file → Normal file
View File

@ -1,16 +1,17 @@
import mido, argparse, sys,os
import configparser,importlib,mapping
import argparse, sys,os
import configparser,importlib
from src.midiRebind import mapping
import traceback
import platform
def launchWithArgs(args):
try:
local=os.path.dirname(__file__)
path=os.path.join(local,"patch","{}.ini".format(args.patch))
path=os.path.join(local, "src","midiRebind","patch", "{}.ini".format(args.patch))
conf=configparser.ConfigParser()
conf.read(path)
interpath="mapping.{}".format(conf["interface"]["mapping"])
interpath="src.midiRebind.mapping.{}".format(conf["interface"]["mapping"])
Module=importlib.import_module(interpath)
@ -40,7 +41,7 @@ def launchWithArgs(args):
except:
print("[Unexpected error@midibind.py] {}".format(sys.exc_info()))
except ImportError as e:
print("[Error] There was an error loading module {} ({})".format(interpath,e))
print("[Error] There was an error loading module {} ({}) ({})".format(interpath,path,e))
traceback.print_exc()
except KeyError as e:
print("[Error] There was an error while loading patch {} ({})".format(path,e))

@ -1 +0,0 @@
Subproject commit 3198c7fa6016752b29ff36e3e221c1238d8cbd6b

@ -1 +0,0 @@
Subproject commit 3e941466c721846696bc4b5b5b8d290874063a96

0
src/__init__.py Normal file
View File

View File

@ -0,0 +1 @@
__all__=["mapping","panaremote","pythonAnalogWay"]

View File

@ -1,6 +1,4 @@
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
import mido
import re,configparser
from src.midiRebind.mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
commandlist={1:"go",2:"stop",3:"resume",4:"timed_go",6:"set",7:"fire",10:"go_off"}
# Doc says 11 is go_off, test says otherwise

View File

@ -1,6 +1,4 @@
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
import mido
import re,configparser
from src.midiRebind.mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
commandlist={127:"DCA",55:"IN",84:"MIX",101:"MATRICE",115:"MASTER",336:"MASTER2",122:"PAGE",53:"MUTE",893:"CUE"}
# Doc says 11 is go_off, test says otherwise

View File

@ -1,13 +1,8 @@
#!/bin/python3
# import pyautogui
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
from src.midiRebind.mapping.base import BasicMidiInterface
import mido
import re,configparser
import pyautogui
from mapping.midi import MessageParse
from mapping.midi import Actions
PLUGGED=[0,0,1,0,0,0,1,0]

View File

@ -11,12 +11,9 @@ __TESTING=False
# IMPORTS
###
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
from src.midiRebind.mapping.base import BasicMidiInterface
import mido
import re,configparser
from panaremote import request as panarequest
from mapping.midi import MessageParse
from mapping.midi import Actions
from src.midiRebind.panaremote import request as panarequest
from threading import Timer
@ -243,7 +240,6 @@ vars=demvars()
def _onload(self):
"Send a reset colors"
import time,sys
vars.output=self.outputs[vars.interface_nb]
#Load the remote control on some VPs
loadVPs(_LIST_VPS)

View File

@ -1,6 +1,5 @@
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
import mido
import configparser,sys
from src.midiRebind.mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
import sys
#A MessageParse object MUST be included in the file, the rest is implementation Specific
class MessageParse(BasicMessageParse):

View File

@ -2,7 +2,7 @@
###########################
# IMPORTS
import mido
from mapping.utils import doublepress
from src.midiRebind.mapping.utils import doublepress
###########################
# FUNCTION DEFINES

View File

@ -1,12 +1,12 @@
#!/bin/python3
from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
from src.midiRebind.mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface
import mido
from mapping.midi import MessageParse
from mapping.midi import Actions
from src.midiRebind.mapping.midi import MessageParse
from src.midiRebind.mapping.midi import Actions
import sys
from mapping.utils import doublepress
from pythonAnalogWay import bindings
from src.midiRebind.mapping.utils import doublepress
from src.midiRebind.pythonAnalogWay import bindings
###########################
# FUNCTION DEFINES
@ -20,7 +20,7 @@ def printl(label=""):
eprint=printl("[mPH:ERROR]")
dprint,ddprint,iprint,wprint=nopeF,nopeF,nopeF,nopeF
bindings.dprint,bindings.ddprint,bindings.iprint=nopeF,nopeF,nopeF
bindings.dprint, bindings.ddprint, bindings.iprint= nopeF, nopeF, nopeF
if _VERBOSE>=1:
wprint=printl("[mPH:WARNING]")
@ -39,10 +39,10 @@ _COLORS={"black":0,"green":1,"blinking_green":2,"red":3,"blinking_red":4,"yellow
###
# try:
from mapping import midiPageHandler
from src.midiRebind.mapping import midiPageHandler
# except:
# from
handler=midiPageHandler.AkaiAPCMini()
handler= midiPageHandler.AkaiAPCMini()
class pulseLink(object):
"""Link between lights, messages and states
Receives messages from the pulse and adjust states"""
@ -54,22 +54,22 @@ class pulseLink(object):
def _onload(self):
"Send a reset colors"
import time,sys
import time
try:
#HOSTS=[["127.0.0.1",3000]] # Test server
HOSTS=[["192.168.0.140",10500]] # Test server
HOSTS=[["127.0.0.1",3000]] # Test server
# HOSTS=[["192.168.0.140",10500]] # Test server
# The socket remote controller
controllerPulse1=bindings.analogController(*HOSTS[0])
controllerPulse1= bindings.analogController(*HOSTS[0])
# Adding the midi interface to the controller
handler.addInterfaceOut(self.interfaceOut(1))
time.sleep(0.2)
# The pulse module, bound to 3 lines
modulePulse1=handler.addModule(midiPageHandler.pulseRackController,[0,1,2,4])
modulePulse1=handler.addModule(midiPageHandler.pulseRackController, [0, 1, 2, 4])
# The IO interface between the pulse and the controller, one IO is necessary per auxilliary application
IOInterface=midiPageHandler.IOInterfacePulse(handler,modulePulse1,controllerPulse1)
IOInterface= midiPageHandler.IOInterfacePulse(handler, modulePulse1, controllerPulse1)
# Finishing initialising the controller (Should be done in a thread to avoid locking)
controllerPulse1.addFeedbackInterface(IOInterface)

18
test.py
View File

@ -21,12 +21,12 @@ class mappingTest(minitest.simpleTestUnit):
self.verbose=True
def _testParsing(self):
self.currentTest("Loading default mappings")
from mapping import GrandMA2
self.gm=GrandMA2
from src.midiRebind.mapping import GrandMA2
self.gm= GrandMA2
self.addSuccess()
self.currentTest("Creating Parser")
self.parser=GrandMA2.MessageParse()
self.parser= GrandMA2.MessageParse()
self.addSuccess()
self.currentTest("Testing hex2dec")
@ -93,7 +93,7 @@ class mappingTest(minitest.simpleTestUnit):
pass
return EmptySender()
self.e_config=Emptyconfig("patch/test.ini")
self.act=GrandMA2.Actions(self.e_config)
self.act= GrandMA2.Actions(self.e_config)
self.addSuccess()
except IOError:
self.addFailure("Can't load config file")
@ -211,7 +211,7 @@ class ConfigTest(minitest.simpleTestUnit):
def _testAll(self):
self.currentTest("Loading config")
from mapping import GrandMA2
from src.midiRebind.mapping import GrandMA2
GrandMA2.MidiInterface("patch/test.ini")
self.addSuccess()
@ -221,19 +221,19 @@ class LiveTest(minitest.simpleTestUnit):
def _testAll(self):
self.currentTest("Loading config")
from mapping import GrandMA2
Inter=GrandMA2.MidiInterface("patch/test.ini")
from src.midiRebind.mapping import GrandMA2
Inter= GrandMA2.MidiInterface("patch/test.ini")
self.addSuccess()
self.currentTest("Loading message parser")
Par=GrandMA2.MessageParse()
Par= GrandMA2.MessageParse()
self.addSuccess()
self.currentTest("Loading Patch")
# print(GrandMA2.Actions)
Acts=GrandMA2.Actions(Inter)
Acts= GrandMA2.Actions(Inter)
self.addSuccess()
#Act.prettyprint()