audioguide icon indicating copy to clipboard operation
audioguide copied to clipboard

AG requires a terminal to run

Open totoetlititi opened this issue 3 years ago • 3 comments

AG requires terminal capabilities to display some infos and progress bars. When python scripts run in an other app (like Lua), without a terminal, the script displays this error: "Terminal isn't capable enough -- you should use a simpler progress dispaly."

 File "/home/we/dust/code/audioguide_test/lib/audioguide-1.75/agSegmentSf.py", line 56, in <module>
ag.initialize_analysis_interface()
File "/home/we/dust/code/audioguide_test/lib/audioguide-1.75/audioguide/__init__.py", line 76, in initialize_analysis_interface
self.p = userinterface.printer(self.ops.VERBOSITY, os.path.dirname(__file__), self.ops.get_outputfile('HTML_LOG_FILEPATH'))
File "/home/we/dust/code/audioguide_test/lib/audioguide-1.75/audioguide/userinterface.py", line 180, in __init__
raise ValueError("Terminal isn't capable enough -- you should use a simpler progress dispaly.")
ValueError: Terminal isn't capable enough -- you should use a simpler progress dispaly.

Even with VERBOSITY set to 0, AG shows this error. Is there a way to disable any verbosity, and not need a terminal anymore ?

All the best, _TG

totoetlititi avatar Jul 29 '22 20:07 totoetlititi

Hi Thomas! Could you trying commenting out these lines of the code and see if this fixes the issue?

benhackbarth avatar Jul 30 '22 19:07 benhackbarth

Thanks Ben ! But I had to go deeper in userinterface.py. The main problem seems to be the curses.setupterm() which can not be run successfully on Norns. But after some modification, it works ! Following the changes in the userinterface.py file (diff between the original and mine):

<         try: curses.setupterm()
<         except: return
---
>         # try: curses.setupterm() # _TG
>         # except: return # _TG 
116,117c116,117
<         self.COLS = curses.tigetnum('cols')
<         self.LINES = curses.tigetnum('lines')
---
>         # self.COLS = curses.tigetnum('cols') # _TG
>         # self.LINES = curses.tigetnum('lines') # _TG
147c147,148
<         cap = curses.tigetstr(cap_name) or ''
---
>         # cap = curses.tigetstr(cap_name) or '' # _TG
>         cap = ''
160,162c161,164
<         output = re.sub(b'\$\$|\${\w+}', self._render_sub, template)
<         output = output.decode(enc)
<         return output
---
>         # output = re.sub(b'\$\$|\${\w+}', self._render_sub, template) # _TG
>         # output = output.decode(enc) # _TG
>         # return output # _TG
>         return ''
179,180c181,182
< 		if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL):
< 			raise ValueError("Terminal isn't capable enough -- you should use a simpler progress dispaly.")
---
> 		# if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL): # _TG
> 		# 	raise ValueError("Terminal isn't capable enough -- you should use a simpler progress dispaly.") # _TG
307c309
< 			sys.stdout.write(self.header)
---
> 			# sys.stdout.write(self.header) # _TG
310,312c312,314
< 		sys.stdout.write(self.term.BOL.decode() + self.term.UP.decode() + self.term.CLEAR_EOL.decode() +
< 			(self.bar % (100*percent, '='*n, '-'*(self.width-10-n))) +
< 			self.term.CLEAR_EOL.decode() + '\t' + message)
---
> 		# sys.stdout.write(self.term.BOL.decode() + self.term.UP.decode() + self.term.CLEAR_EOL.decode() + # _TG
> 		# 	(self.bar % (100*percent, '='*n, '-'*(self.width-10-n))) + # _TG
> 		# 	self.term.CLEAR_EOL.decode() + '\t' + message) # _TG


totoetlititi avatar Jul 31 '22 19:07 totoetlititi

OK. I think that I may have figured out a simpler way to do this. Just pushed the fix to userinterface.py. I'd appreciate it if you could test it so I can close this ticket ! Cheers, Ben

benhackbarth avatar Aug 05 '22 10:08 benhackbarth