Curses addstr() variable instead of integer causes error? - python

I've started working on a curses program in python and I have come across this issue. The code "logo.addstr(count, 1, line)" gives this error:
Traceback (most recent call last):
File "intro.py", line 90, in <module>
curses.wrapper(main)
File "/usr/lib/python3.7/curses/__init__.py", line 102, in wrapper
return func(stdscr, *args, **kwds)
File "intro.py", line 22, in main
show_rank_logo()
File "intro.py", line 87, in show_rank_logo
logo.addstr(count, 1, line)
_curses.error: addwstr() returned ERR
If you replace "count" with 1, the lines will show up but on one line (as it should). This file is ASCII art so I want it to display in the window (named logo) all at once. This is why I added a count to the loop. But the variable which equals 1 somehow gives an error.
def show_rank_logo():
logo = curses.newwin(35, 105, 1, 51)
logo.box()
count = 1
with open('platinum_logo.txt') as file:
for line in file.readlines():
logo.addstr(count, 1, line)
count += 1
logo.refresh()
Looking for any help!

Related

Problems when I run ML-GCN

'''
PS D:\ML-GCN\ML-GCN-master> python demo_voc2007_gcn.py data/voc --image-size 448 --batch-size 1 -e --resume checkpoint/voc/voc_checkpoint.pth.tar
[dataset] read data/voc\data\data\data\voc\data\voc\files\VOC2007\classification_trainval.csv
Traceback (most recent call last):
File "D:\ML-GCN\ML-GCN-master\demo_voc2007_gcn.py", line 75, in <module>
main_voc2007()
File "D:\ML-GCN\ML-GCN-master\demo_voc2007_gcn.py", line 44, in main_voc2007
train_dataset = Voc2007Classification(args.data, 'trainval', inp_name='data/voc/voc_glove_word2vec.pkl')
train_dataset = Voc2007Classification(args.data, 'trainval', inp_name='data/voc/voc_glove_word2vec.pkl')
File "D:\ML-GCN\ML-GCN-master\voc.py", line 242, in __init__
self.images = read_object_labels_csv(file_csv)
File "D:\ML-GCN\ML-GCN-master\voc.py", line 95, in read_object_labels_csv
name = row[0]
IndexError: list index out of range
'''
The problem encountered when running ML-GCN, why does the problem of list index out of range appear, and how can I solve it

KeyError with custom derived quantity

I have defined a new derived dimension with
[molar_energy] = [energy] / [substance]
However, if I do the following it complains:
>>> UR.get_compatible_units('[molar_energy]')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cedric/.local/share/virtualenvs/MatDB--uGOYMXa/lib/python3.9/site-packages/pint/registry.py", line 881, in get_compatible_units
equiv = self._get_compatible_units(input_units, group_or_system)
File "/Users/cedric/.local/share/virtualenvs/MatDB--uGOYMXa/lib/python3.9/site-packages/pint/registry.py", line 2082, in _get_compatible_units
ret = super()._get_compatible_units(input_units, group_or_system)
File "/Users/cedric/.local/share/virtualenvs/MatDB--uGOYMXa/lib/python3.9/site-packages/pint/registry.py", line 1835, in _get_compatible_units
ret = super()._get_compatible_units(input_units, group_or_system)
File "/Users/cedric/.local/share/virtualenvs/MatDB--uGOYMXa/lib/python3.9/site-packages/pint/registry.py", line 891, in _get_compatible_units
return self._cache.dimensional_equivalents[src_dim]
KeyError: <UnitsContainer({'[length]': 2, '[mass]': 1, '[substance]': -1, '[time]': -2})
I saw that there is a conversion included in a context but I don't use it. What I am doing wrong?
Thanks for your help
PS: logged issue https://github.com/hgrecco/pint/issues/1418
Just leaving the solution here for anyone who faces this issue as well.
I just added a made-up unit and it worked
# Molar Energy
[molar_energy] = [energy] / [substance]
mol_en = J / mol

IndexError: list index out of range right after printing len(list) > 0

I literally have these two lines of code in sequence:
print(len(counter.ondas))
onda = counter.ondas[-1]
I got 13 printed for the first line and it crashed giving me tracebook to the onda = counter.ondas[-1] line saying IndexError: list index out of range right after printing len(list).
It works thousands of times before crashing. I have no clue on how to approach this problem.
Output for print(counter.ondas):
[Onda([<workers.mov.Mov object at 0x244EA050>], [Candle(4, 'GBP_JPY', Timestamp('2017-06-12 16:59:00'), 138.884, 138.897, 138.674, 138.76, 10957.0, True)]), Onda([<workers.mov.Mov object at 0x245073D0>], [Candle(4, 'GBP_JPY', Timestamp('2017-06-12 16:59:00'), 138.884, 138.897, 138.674, 138.76, 10957.0, True)...]
Output for print(type(counter.ondas)):
<class 'list'>
Output for print(isinstance(counter.ondas, list)):
True
Full Error Traceback
Traceback (most recent call last):
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "C:\Users\joaoa\PycharmProjects\aquitania\general_manager.py", line 88, in load_observer_manager
observer_manager.update_load_run_data()
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_manager.py", line 78, in update_load_run_data
self.load_run_data()
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_manager.py", line 91, in load_run_data
self.feeder.exec_df(df[self.start_date:])
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 429, in exec_df
self.feed(candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 98, in feed
self.make_candle(ts, candle, criteria_table)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 126, in make_candle
self.set_values(ts, candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 310, in set_values
ts_obs.feed_complete(self._candles[ts])
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_loader.py", line 100, in feed_complete
observer.update_last_candle(candle, store_candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\abstract\observer_abc.py", line 93, in update_last_candle
self.set_observe(self.update_method(candle))
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\ondas\ondas_inside.py", line 393, in update_method
self.update_routine(counter_id=2, candle=candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\ondas\ondas_inside.py", line 412, in update_routine
onda = list(counter.ondas)[-1]
IndexError: list index out of range
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 145, in <module>
gm.run()
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 113, in run
list_of_observer_managers = self.load_all_observer_managers()
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 60, in load_all_observer_managers
observer = currency_pool.map(self.load_observer_manager, list_of_currencies)
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 644, in get
raise self._value
IndexError: list index out of range
I was able to idenfity the issue. The error was being thrown in a separate process than the one that was being printed and for some reason the error ocurred only after the process that was printing the results was interrupted by another unrelated error.
Weird behavior, but now I am able to tackle the problem.
Debugging in a single process mode helped a lot.
Thank you for your help.

Scapy won't start

My Scapy v2.3.3 won't start. Fresh reinstalled Python 2.7, WinPcap10 and pyreadline. Sometimes it starts after at second try in the same console.
c:\Python27\Scripts>scapy
c:\Python27\Scripts>python c:\Python27\Scripts\scapy
INFO: Can't import matplotlib. Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
Traceback (most recent call last):
File "c:\Python27\Scripts\scapy", line 26, in <module>
interact()
File "C:\Python27\lib\site-packages\scapy\main.py", line 300, in interact
scapy_builtins = __import__("all",globals(),locals(),".").__dict__
File "C:\Python27\lib\site-packages\scapy\all.py", line 16, in <module>
from scapy.arch import *
File "C:\Python27\lib\site-packages\scapy\arch\__init__.py", line 83, in <module>
from scapy.arch.windows import *
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 318, in <module>
IFACES.load_from_powershell()
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 270, in load_from_powershell
for i in get_windows_if_list():
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 206, in get_windows_if_list
for line in query)
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 205, in <genexpr>
(dict(zip(['name', 'win_index', 'description', 'guid', 'mac'], line))
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 53, in _exec_query_ps
l.append(line.split(':', 1)[1].strip())
IndexError: list index out of range
This bug was implemented in 6840d30 (v2.3.3) and fixed in a454ef4, it could be fixed by changing
l.append(line.split(':', 1)[1].strip())
to
sl = line.split(':', 1)
if len(sl) == 1:
l[-1] += sl[0].strip()
continue
else:
l.append(sl[1].strip())

Error while using mloginfo m-tools

I want to analyze log file of mongodb. I am referred to use m-tools. But I'm getting following error.
I've typed in terminal
mlonginfo /..logfilelocation../ --queries
Error:
QUERIES [============================== ] 74.1 % Traceback (most recent call last):
File "/usr/local/bin/mloginfo", line 9, in <module>
load_entry_point('mtools==1.1.8', 'console_scripts', 'mloginfo')()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/mloginfo.py", line 82, in main
tool.run()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/mloginfo.py", line 77, in run
section.run()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/sections/query_section.py", line 51, in run
for i, le in enumerate(logfile):
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logfile.py", line 208, in __iter__
le = self.next()
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logfile.py", line 190, in next
ret = le.set_datetime_hint(self._datetime_format, self._datetime_nextpos, self.year_rollover)
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logevent.py", line 246, in set_datetime_hint
if not self.split_tokens[self._datetime_nextpos-1][0].isdigit():
IndexError: list index out of range
Thanks in advance.

Categories

Resources