[...]
/usbdrive/Modes/A_Zach_Sine/main.py
Traceback (most recent call last):
File "C:\root\ETC_Mother\etc_system.py", line 239, in load_modes
imp.load_source(mode_name, mode_path)
File "/usbdrive/Modes/A_Zach_Sine/main.py", line 11, in <module>
w1 = screen.get_width()
NameError: name 'screen' is not defined
I don’t understand that, since screen is used in the def statements
thanks! That works. The only thing is, that I have to reload the mode one time to set the value from the setup section. Before the reload the variable has the value from the start (in this case 0).
How can I ensure, that the setup part is executed?
I still had no chance to test this on the ETC itself (its buried in the cases for the live shows), but I found out, that appearently the setup for the last Mode is not executed. If you have only one Mode, then this one is also the last one, and it will have its setup not executed.
# run setup functions if modes have them
print "running setup..."
for i in range(0, len(etc.mode_names)-1) :
print etc.mode_root
try :
etc.set_mode_by_index(i)
mode = sys.modules[etc.mode]
except AttributeError :
print "mode not found, probably has error"
continue
try :
osd.loading_banner(hwscreen,"Loading " + str(etc.mode) )
mode.setup(screen, etc)
etc.memory_used = psutil.virtual_memory()[2]
except :
print "error in setup, or setup not found"
continue
yup, it should be
for i in range(0, len(etc.mode_names)) :
seems like only issue with the bug is setup not called, and the memory_used will be wrong
(only a problem if the last mode uses a lot of resources)
fortunately easy fix.
and an easy ‘workaround’, would be to chuck a dummy mode at the end.
Ahhhhh!! sorry about that. I remember running across this a while ago. I think it was after we finalized everything, and the solution was just a dummy mode like @thetechnobear suggests. Most of the factory modes don’t actually have anything in the setup function, so it went unnoticed…