Browse Source

remove stupid typo in search and replace

master
Nils 5 years ago
parent
commit
b53857c520
  1. 4
      qtgui/mainwindow.py
  2. 2
      template/calfbox/py/_cbox2.py
  3. 2
      template/engine/api.py
  4. 2
      template/engine/duration.py
  5. 10
      template/engine/sampler_sf2.py
  6. 27
      template/engine/sequencer.py
  7. 26
      template/engine/session.py
  8. 2
      template/qtgui/chooseSessionDirectory.py
  9. 2
      template/qtgui/debugScript.py
  10. 14
      template/qtgui/mainwindow.py
  11. 6
      template/qtgui/nsmclient.py
  12. 2
      template/qtgui/nsmsingleserver.py
  13. 16
      template/start.py

4
qtgui/mainwindow.py

@ -167,6 +167,10 @@ class MainWindow(TemplateMainWindow):
self.ui.gridView.horizontalScrollBar().setSliderPosition(0)
self.ui.gridView.verticalScrollBar().setSliderPosition(0)
#There is so much going on in the engine, we never reach a save status on load.
#Here is the crowbar-method.
self.nsmClient.announceSaveStatus(isClean = True)
def callback_numberOfTracksChanged(self, exportDictList):
"""We need to find out of the current track was the deleted one or if a new track got added

2
template/calfbox/py/_cbox2.py

@ -100,7 +100,7 @@ def find_calfbox():
cblib = os.environ["CALFBOXLIBABSPATH"]
else:
cblib = find_library('calfbox')
logger.info:("Loading calfbox shared library: %s" % (cblib))
logging.info("Loading calfbox shared library: %s" % (cblib))
cb = cdll.LoadLibrary(cblib)
return cb

2
template/engine/api.py

@ -85,7 +85,7 @@ class Callbacks(object):
Insert, delete edit are real data changes. Cursor movement or playback ticks are not."""
session.nsmClient.announceSaveStatus(False)
self._historyChanged()
self._historyChanged()
def _historyChanged(self):

2
template/engine/duration.py

@ -49,7 +49,7 @@ D512 = int(D256 / 2)
D1024 = int(D512 / 2) # set this to a number with many factors, like 210. According to http://homes.sice.indiana.edu/donbyrd/CMNExtremes.htm this is the real world limit.
if not int(D1024) == D1024:
logger.error:(f"Warning: Lowest duration D0124 has decimal places: {D0124} but should be a plain integer. Your D4 value: {D4} has not enough 2^n factors. ")
logger.error(f"Warning: Lowest duration D0124 has decimal places: {D0124} but should be a plain integer. Your D4 value: {D4} has not enough 2^n factors. ")
D2 = D4 *2
D1 = D2 *2

10
template/engine/sampler_sf2.py

@ -91,7 +91,7 @@ class Sampler_sf2(Data):
try:
cbox.JackIO.Metadata.set_port_order(portname, channelNumber)
except Exception as e: #No Jack Meta Data
logger.error:(e)
logger.error(e)
#Also sort the mixing channels
try:
@ -100,7 +100,7 @@ class Sampler_sf2(Data):
portname = f"{cbox.JackIO.status().client_name}:right_mix"
cbox.JackIO.Metadata.set_port_order(portname, 34)
except Exception as e: #No Jack Meta Data
logger.error:(e)
logger.error(e)
@ -141,7 +141,7 @@ class Sampler_sf2(Data):
def loadSoundfont(self, filePath, defaultSoundfont=None):
"""defaultSoundfont is a special case. The path is not saved"""
logger.info:(f"loading path: \"{filePath}\" defaultSoundfont parameter: {defaultSoundfont}")
logger.info(f"loading path: \"{filePath}\" defaultSoundfont parameter: {defaultSoundfont}")
#Remove the old link, if present. We cannot unlink directly in loadSoundfont because it is quite possible that a user will try out another soundfont but decide not to save but close and reopen to get his old soundfont back.
if self.filePath and os.path.islink(self.filePath):
@ -190,7 +190,7 @@ class Sampler_sf2(Data):
for youchoose_bank in self.patchlist.keys():
for youchoose_program, youchoose_name in self.patchlist[youchoose_bank].items():
youchoose_bank, youchoose_program, youchoose_name
logger.info:(METADATA["name"] + f": Channel {channel} Old bank/program not possible in new soundfont. Switching to first available program.")
logger.info(METADATA["name"] + f": Channel {channel} Old bank/program not possible in new soundfont. Switching to first available program.")
self.setPatch(channel, youchoose_bank, youchoose_program)
break #inner loop. one instrument is enough.
@ -251,7 +251,7 @@ class Sampler_sf2(Data):
cbox.JackIO.Metadata.set_pretty_name(portnameL, f"{str(channel).zfill(2)}-L : {name}")
cbox.JackIO.Metadata.set_pretty_name(portnameR, f"{str(channel).zfill(2)}-R : {name}")
except Exception as e: #No Jack Meta Data
logger.error:(e)
logger.error(e)
def updateAllChannelJackMetadaPrettyname(self):

27
template/engine/sequencer.py

@ -112,7 +112,7 @@ class Score(Data):
try:
cbox.JackIO.Metadata.set_all_port_order(order)
except Exception as e: #No Jack Meta Data
logger.error:(e)
logger.error(e)
def trackById(self, trackId:int):
for track in self.tracks:
@ -320,7 +320,7 @@ class SequencerInterface(_Interface): #Basically the midi part of a track.
def _processAfterInit(self):
#Create midi out and cbox track
logger.info:("Creating empty SequencerInterface instance")
logger.info("Creating empty SequencerInterface instance")
super()._processAfterInit()
self.cboxMidiOutUuid = cbox.JackIO.create_midi_output(self._name)
self.calfboxTrack.set_external_output(self.cboxMidiOutUuid)
@ -519,7 +519,7 @@ class TempoMap(object):
def __init__(self, parentData):
logger.info:("Creating empty TempoMap instance")
logger.info("Creating empty TempoMap instance")
self.parentData = parentData
self._tempoMap = {0:(120.0, 4, 4)} # 4/4, 120bpm. will not be used on startup, but is needed if transportMaster is switched on
self._isTransportMaster = False
@ -552,7 +552,7 @@ class TempoMap(object):
@isTransportMaster.setter
def isTransportMaster(self, value:bool):
logger.info:(f"Jack Transport Master status: {value}")
logger.info(f"Jack Transport Master status: {value}")
self._isTransportMaster = value
if value:
self._sendToCbox() #reactivate existing tempo map
@ -570,14 +570,13 @@ class TempoMap(object):
self._updatePlayback()
def _sanitize(self):
"""Inplace modification of self.tempoMap. Remove zeros and convert to float values.
"""
self._tempoMap = {int(key):(float(value), timesigNum, timesigDenom) for key, (value, timesigNum, timesigDenom) in self._tempoMap.items() if value > 0.0}
#Don't use the following. Empty tempo maps are allowed, especially in jack transport slave mode.
#Instead set a default tempo 120 on init explicitly
#if not self._tempoMap:
# logger.error:("Found invalid tempo map. Forcing to 120 bpm. Please correct manually")
# self._tempoMap = {0, 120.0}
"""Inplace modification of self.tempoMap. Remove zeros and convert to float values. """
self._tempoMap = {int(key):(float(value), timesigNum, timesigDenom) for key, (value,
timesigNum, timesigDenom) in self._tempoMap.items() if value > 0.0} #Don't use the
following. Empty tempo maps are allowed, especially in jack transport slave mode. #Instead
set a default tempo 120 on init explicitly #if not self._tempoMap: # logger.error("Found
invalid tempo map. Forcing to 120 bpm. Please correct manually") # self._tempoMap = {0,
120.0}
def _clearCboxTempoMap(self):
"""Remove all cbox tempo values by iterating over all of them and set them to None, which is
@ -638,7 +637,7 @@ class TempoMap(object):
assert 0 in self._tempoMap, self._tempoMap
return self._tempoMap[0][0] #second [0] is the tuple (tempo, timesig, timesig)
else:
logger.info:("Requested Quarter Notes per Minute, but we are not transport master")
logger.info("Requested Quarter Notes per Minute, but we are not transport master")
return None
#Save / Load / Export
@ -652,7 +651,7 @@ class TempoMap(object):
@classmethod
def instanceFromSerializedData(cls, parentData, serializedData):
logger.info:("Loading TempoMap from saved file")
logger.info("Loading TempoMap from saved file")
self = cls.__new__(cls)
self.parentData = parentData
self._tempoMap = serializedData["tempoMap"] #json saves dict-keys as strings. We revert back in sanitize()

26
template/engine/session.py

@ -83,7 +83,7 @@ class Session(object):
return jsonDataAsString.replace(self.sessionPrefix, "<sessionDirectory>")
def nsm_openOrNewCallback(self, ourPath, sessionName, ourClientNameUnderNSM):
logger.info:("New/Open session")
logger.info("New/Open session")
cbox.init_engine("")
#Most set config must be called before start audio. Set audio outputs seems to be an exception.
@ -111,13 +111,13 @@ class Session(object):
self.data = None #This makes debugging output nicer. If we init Data() here all errors will be presented as follow-up error "while handling exception FileNotFoundError".
except (NotADirectoryError, PermissionError) as e:
self.data = None
logger.error:("Will not load or save because: " + e.__repr__())
logger.error("Will not load or save because: " + e.__repr__())
if not self.data:
self.data = Data(parentSession = self)
logger.info:("New/Open session complete")
logger.info("New/Open session complete")
def openFromJson(self, absoluteJsonFilePath):
logger.info:("Loading file start")
logger.info("Loading file start")
with open(absoluteJsonFilePath, "r", encoding="utf-8") as f:
try:
text = self.addSessionPrefix(f.read())
@ -130,7 +130,7 @@ class Session(object):
self.guiWasSavedAsNSMVisible = result["guiWasSavedAsNSMVisible"]
self.guiSharedDataToSave = result["guiSharedDataToSave"]
assert type(self.guiSharedDataToSave) is dict, self.guiSharedDataToSave
logger.info:("Loading file complete")
logger.info("Loading file complete")
return Data.instanceFromSerializedData(parentSession=self, serializedData=result)
else:
warn(f"""{absoluteJsonFilePath} was saved with {result["version"]} but we need {METADATA["version"]}""")
@ -146,7 +146,7 @@ class Session(object):
if not os.path.exists(ourPath):
os.makedirs(ourPath)
except Exception as e:
logger.error:("Will not load or save because: " + e.__repr__())
logger.error("Will not load or save because: " + e.__repr__())
result = self.data.serialize()
result["origin"] = METADATA["url"]
@ -162,19 +162,21 @@ class Session(object):
with open(self.absoluteJsonFilePath, "w", encoding="utf-8") as f:
f.write(jsonData)
except Exception as e:
logger.error:("Will not load or save because: " + e.__repr__())
logger.error("Will not load or save because: " + e.__repr__())
logger.info("Saving file complete")
return self.absoluteJsonFilePath
def stopSession(self):
"""This got registered with atexit in the nsm new or open callback above.
will handle all python exceptions, but not segfaults of C modules. """
logger.info:("Starting Quit through @atexit, session.stopSession")
logger.info("Starting Quit through @atexit, session.stopSession")
self.eventLoop.stop()
logger.info:("@atexit: Event loop stopped")
logger.info("@atexit: Event loop stopped")
#Don't do that. We are just a client.
#cbox.Transport.stop()
#logger.info:("@atexit: Calfbox Transport stopped ")
#logger.info("@atexit: Calfbox Transport stopped ")
cbox.stop_audio()
logger.info:("@atexit: Calfbox Audio stopped ")
logger.info("@atexit: Calfbox Audio stopped ")
cbox.shutdown_engine()
logger.info:("@atexit: Calfbox Engine shutdown ")
logger.info("@atexit: Calfbox Engine shutdown ")

2
template/qtgui/chooseSessionDirectory.py

@ -45,7 +45,7 @@ class ChooseSessionDirectory(QtWidgets.QDialog):
def __init__(self, qtApp):
language = QtCore.QLocale().languageToString(QtCore.QLocale().language())
logger.info:("{}: Language set to {}".format(METADATA["name"], language))
logger.info("{}: Language set to {}".format(METADATA["name"], language))
if language in METADATA["supportedLanguages"]:
templateTranslator = QtCore.QTranslator()
templateTranslator.load(METADATA["supportedLanguages"][language], ":/template/translations/") #colon to make it a resource URL

2
template/qtgui/debugScript.py

@ -44,7 +44,7 @@ class DebugScriptRunner(object):
def _createEmptyDebugScript(self):
assert self.absoluteScriptFilePath
logger.info:(f"{self.nsmClient.ourClientNameUnderNSM}: Script file not found. Initializing: {self.absoluteScriptFilePath}")
logger.info(f"{self.nsmClient.ourClientNameUnderNSM}: Script file not found. Initializing: {self.absoluteScriptFilePath}")
text = ("""#! /usr/bin/env python3"""
"\n"
"""# -*- coding: utf-8 -*-"""

14
template/qtgui/mainwindow.py

@ -95,15 +95,15 @@ class EventLoop(object):
def start(self):
"""The event loop MUST be started after the Qt Application instance creation"""
logger.info:("Starting fast qt event loop")
logger.info("Starting fast qt event loop")
self.fastLoop.start(20)
logger.info:("Starting slow qt event loop")
logger.info("Starting slow qt event loop")
self.slowLoop.start(100)
def stop(self):
logger.info:("Stopping fast qt event loop")
logger.info("Stopping fast qt event loop")
self.fastLoop.stop()
logger.info:("Stopping slow qt event loop")
logger.info("Stopping slow qt event loop")
self.slowLoop.stop()
api.session.eventLoop = EventLoop()
@ -113,7 +113,7 @@ api.session.eventLoop = EventLoop()
#Setup the translator before classes are set up. Otherwise we can't use non-template translation.
#to test use LANGUAGE=de_DE.UTF-8 . not LANG=
language = QtCore.QLocale().languageToString(QtCore.QLocale().language())
logger.info:("{}: Language set to {}".format(METADATA["name"], language))
logger.info("{}: Language set to {}".format(METADATA["name"], language))
if language in METADATA["supportedLanguages"]:
templateTranslator = QtCore.QTranslator()
templateTranslator.load(METADATA["supportedLanguages"][language], ":/template/translations/") #colon to make it a resource URL
@ -355,13 +355,13 @@ class MainWindow(QtWidgets.QMainWindow):
#Close and exit
def _nsmQuit(self, ourPath, sessionName, ourClientNameUnderNSM):
logger.info:("Qt main window received NSM exit callback. Calling pythons system exit. ")
logger.info("Qt main window received NSM exit callback. Calling pythons system exit. ")
self.storeWindowSettings()
#api.stopEngine() #will be called trough sessions atexit
#self.qtApp.quit() #does not work. This will fail and pynsmclient2 will send SIGKILL
sysexit() #works, NSM cleanly detects a quit. Triggers the session atexit condition
logger.error:("Code executed after sysexit. This message should not have been visible.")
logger.error("Code executed after sysexit. This message should not have been visible.")
#Code here never gets executed.
def closeEvent(self, event):

6
template/qtgui/nsmclient.py

@ -333,6 +333,9 @@ class NSMClient(object):
self.sock.setblocking(False) #We have waited for tha handshake. Now switch blocking off because we expect sock.recvfrom to be empty in 99.99...% of the time so we shouldn't wait for the answer.
#After this point the host must include self.reactToMessage in its event loop
#We assume we are save at startup.
self.announceSaveStatus(isClean = True)
def reactToMessage(self):
"""This is the main loop message. It is added to the clients event loop."""
@ -466,6 +469,9 @@ class NSMClient(object):
def announceSaveStatus(self, isClean):
"""Only send to the NSM Server if there was really a change"""
if not self.supportsSaveStatus:
return
if not isClean == self.cachedSaveStatus:
message = "/nsm/client/is_clean" if isClean else "/nsm/client/is_dirty"
self.cachedSaveStatus = isClean

2
template/qtgui/nsmsingleserver.py

@ -106,7 +106,7 @@ def startSingleNSMServer(directory):
#loop.run_forever()
#asyncio.run(asyncio.start_server(handle_client, 'localhost', SERVER_PORT))
logger.info:(f"Starting fake NSM server on port {SERVER_PORT}")
logger.info(f"Starting fake NSM server on port {SERVER_PORT}")
#For Carla:
signal(SIGUSR1, NSMProtocol.staticSave)

16
template/start.py

@ -71,11 +71,11 @@ import os.path
try:
from compiledprefix import prefix
compiledVersion = True
logger.info:("Compiled prefix found: {}".format(prefix))
logger.info("Compiled prefix found: {}".format(prefix))
except ModuleNotFoundError as e:
compiledVersion = False
logger.info:("Compiled version: {}".format(compiledVersion))
logger.info("Compiled version: {}".format(compiledVersion))
cboxSharedObjectVersionedName = "lib"+METADATA["shortName"]+".so." + METADATA["version"]
@ -126,12 +126,12 @@ else:
if os.path.exists (os.path.join(_root, "site-packages", "calfbox", "cbox.py")):
#add to the front to have higher priority than system site-packages
logger.info:("Will attempt to start with local calfbox python module: {}".format(os.path.join(_root, "site-packages", "calfbox", "cbox.py")))
logger.info("Will attempt to start with local calfbox python module: {}".format(os.path.join(_root, "site-packages", "calfbox", "cbox.py")))
sys.path.insert(0, os.path.join(os.path.join(_root, "site-packages")))
#else try to use system-wide calfbox. Check for this and if the .so exists at the end of this file.
logger.info:("PATHS: {}".format(PATHS))
logger.info("PATHS: {}".format(PATHS))
def exitWithMessage(message:str):
@ -235,7 +235,7 @@ def profiler(*pargs, **kwds):
from tempfile import NamedTemporaryFile
cprofPath = NamedTemporaryFile().name + ".cprof"
pr.dump_stats(cprofPath)
logger.info:("{}: write profiling data to {}".format(METADATA["name"], cprofPath))
logger.info("{}: write profiling data to {}".format(METADATA["name"], cprofPath))
print (f"pyprof2calltree -k -i {cprofPath}")
pr = cProfile.Profile()
@ -304,13 +304,13 @@ if args.mute:
#Make sure calfbox is available.
if "CALFBOXLIBABSPATH" in os.environ:
logger.info:("Looking for calfbox shared library in absolute path: {}".format(os.environ["CALFBOXLIBABSPATH"]))
logger.info("Looking for calfbox shared library in absolute path: {}".format(os.environ["CALFBOXLIBABSPATH"]))
else:
logger.info:("Looking for calfbox shared library systemwide through ctypes.util.find_library")
logger.info("Looking for calfbox shared library systemwide through ctypes.util.find_library")
try:
from calfbox import cbox
logger.info:("{}: using cbox python module from {} . Local version has higher priority than system wide.".format(METADATA["name"], os.path.abspath(cbox.__file__)))
logger.info("{}: using cbox python module from {} . Local version has higher priority than system wide.".format(METADATA["name"], os.path.abspath(cbox.__file__)))
except Exception as e:
print (e)

Loading…
Cancel
Save