KiCost runtime error


#1

Hallo … I have a weird problem running kicost

Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\wx\core.py", line 2228, in Notify
    self.notify()
  File "c:\program files\python37\lib\site-packages\wx\core.py", line 3384, in Notify
    self.result = self.callable(*self.args, **self.kwargs)
  File "c:\program files\python37\lib\site-packages\kicost\kicost_gui.py", line 770, in run
    dist_list.append(v['module'])
KeyError: 'module'

Someone can help me?


#2

@Michele_Santucci
With @debisme, the author, I am the active programmer.
In your terminal/DOS/prompt type kicost --version and return it to me.


#3

here it is:

KiCost v.1.1.1 on Windows-10-10.0.17134-SP0(64bit) Python 3.7.2

… thnx for the reply


#5

Fix, replace your file by that available at https://github.com/xesscorp/KiCost/ . I will release it soon on PYPI.
The GUI (graphical user interface) still need some improvement but I am the only active programmer now. We still need some testers users and help with the GUI.

Tip: use kicost --setup (and the opposite kicost --unsetup) to add it to the Eeschema BOM list.


#6

Sorry I need some more infos:

  • Which file I have to replace?
  • What’s PYPI?
  • kicost --setup will add manf# field to EESchema default fields-set?

#7

Which file I have to replace?
This issue just committed the kicost_gui.py file.
But to be sure you can replace your installation for the full folder kicost that you can download here https://github.com/xesscorp/KiCost/
Search in your Windows for the kicost folder and replace it.

What’s PYPI ?
It is the official release in here https://pypi.org/project/kicost/
When I officially release a version user can simple install by pip install kicost in the terminal.

kicost --setup will add manf# field to EESchema default fields-set?
--setup adds KiCost to the BOM list on Eeschema, beeing now access directly in KiCad without terminal or external commands.

Interesting: add “manf#” as default field when I run --setup.
If you have more ideas that can help / make easy to use, please submit in https://github.com/xesscorp/KiCost/issues


#8

Is there a way to update trough pip ?
I tried but nothing seems to be changed:

pip install kicost
Requirement already satisfied: kicost in c:\program files\python37\lib\site-packages (1.1.1)
Requirement already satisfied: XlsxWriter>=0.7.3 in c:\program files\python37\lib\site-packages\xlsxwriter-1.1.5-py3.7.egg (from kicost) (1.1.5)
Requirement already satisfied: beautifulsoup4>=4.3.2 in c:\program files\python37\lib\site-packages\beautifulsoup4-4.7.1-py3.7.egg (from kicost) (4.7.1)
Requirement already satisfied: CurrencyConverter>=0.13 in c:\program files\python37\lib\site-packages\currencyconverter-0.13.8-py3.7.egg (from kicost) (0.13.8)
Requirement already satisfied: requests>=2.18.4 in c:\program files\python37\lib\site-packages\requests-2.21.0-py3.7.egg (from kicost) (2.21.0)
Requirement already satisfied: babel>=2.6 in c:\program files\python37\lib\site-packages\babel-2.6.0-py3.7.egg (from kicost) (2.6.0)
Requirement already satisfied: future in c:\program files\python37\lib\site-packages\future-0.17.1-py3.7.egg (from kicost) (0.17.1)
Requirement already satisfied: tqdm>=4.30.0 in c:\program files\python37\lib\site-packages\tqdm-4.31.1-py3.7.egg (from kicost) (4.31.1)
Requirement already satisfied: soupsieve>=1.2 in c:\program files\python37\lib\site-packages\soupsieve-1.8-py3.7.egg (from beautifulsoup4>=4.3.2->kicost) (1.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\program files\python37\lib\site-packages\certifi-2018.11.29-py3.7.egg (from requests>=2.18.4->kicost) (2018.11.29)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\program files\python37\lib\site-packages\chardet-3.0.4-py3.7.egg (from requests>=2.18.4->kicost) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in c:\program files\python37\lib\site-packages\idna-2.8-py3.7.egg (from requests>=2.18.4->kicost) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\program files\python37\lib\site-packages\urllib3-1.24.1-py3.7.egg (from requests>=2.18.4->kicost) (1.24.1)
Requirement already satisfied: pytz>=0a in c:\program files\python37\lib\site-packages\pytz-2018.9-py3.7.egg (from babel>=2.6->kicost) (2018.9)

I will share any idea I’ll have don’t worry.
And if I can be of any help please ask I’m always available. Please take into account that I’m just starting to learn Python (I wish to create some simple plugins for Kicad) but I’m pretty good in C, C++, Java. and in english->italian localization.


#9

Yes pip install -U kicost but just after I officially release 1.1.2 version (I will do just after some tests and add the “manf#” as default).

If you are familiar with git (and have it installed), you can run
pip install -U git+https://github.com/xesscorp/KiCost/
to get the last coded version. If you haven’t git installed, the replace file make the same procedure.


#10

luckly I already have git installed and I’m familiar with it.
BTW In the past I requested an OCTOPART key (free one) and I obtained it … how can I setup KiCost to use it?


#11

After the successful update I tried to run it again but, using the --gui option it hangs without any error/warning.
If I run it trough console without the --gui switch I got this:

kicost -i V2-10A122_ki.xml -o V2-10A122.xlsx
Traceback (most recent call last):
  File "C:\Program Files\Python37\Scripts\kicost-script.py", line 11, in <module>
    load_entry_point('kicost==1.1.1', 'console_scripts', 'kicost')()
  File "c:\program files\python37\lib\site-packages\kicost\__main__.py", line 319, in main
    dist_list=dist_list, currency=args.currency)
  File "c:\program files\python37\lib\site-packages\kicost\kicost.py", line 164, in kicost
    p, info = eda_module.get_part_groups(in_file[i_prj], ignore_fields, variant[i_prj])
  File "c:\program files\python37\lib\site-packages\kicost\edas\eda_kicad.py", line 154, in get_part_groups
    for c in root.find('components').find_all('comp'):
AttributeError: 'NoneType' object has no attribute 'find_all'

I have to wait for 1.1.2?


#12

I kept the distributors/api_octopart.py updated on the installation. But you will have to made some manual changes:

  1. Add your KEY manually inside the api_octopart.py file through the definition def query(query, apiKey=None). Change the None to "YOUR_TOKEN";
  2. At kicost.py file change api_partinfo_kitspace.query_part_info(parts, distributor_dict, currency) to api_ocotpart.query_part_info(parts, distributor_dict, currency).

Those change should be enough. I have plan to made this easy for users to change though configuration in the Windows/GUI. But I need some programmer to help me (with the GUI), for now I am just using the time to keep KiCost running and updating the motor (internal functions).


#13

Could you send my your XML file (in private). Appear to be related with the read routine.


#14

Following you suggestion to share ideas: why don’t you put an command line option like --octopartkey KEY to insert it inline or --keyfile FILENAME to specify a file where the key string is stored? I think it should be pretty easy to implement and avoid people like me to go editing Python files (in my opinion this could lead to some unpredictable behaviours)…
In GUI you should just put a textbox where to insert the key string.


#15

I sent you a private message with a goole drive share link.


#16

The problem if that is: every time that I change or add a new module I will have to create --octopartkey/ --digikeykey… creating more work for me to maintenance.
The GUI already have the function to save the filled fields. I just need (help) create a table that using the modules at distributors folder show columns with the configurations.
The low level work is almost done, missing all the GUI part integration.

Also the file already used for this could be used in the CLI access.


#17

I really haven’t got what you mean there, besides the key features that’s not so important (I’m using kicost as is without inserting my octopart key at this moment and it looks to works fine).

The GUI already have the function to save the filled fields. I just need (help) create a table that using the modules at distributors folder show columns with the configurations.

If you explain a little more maybe I can help you with this but up to now I really haven’t got what you was meaning.

The low level work is almost done, missing all the GUI part integration.
Also the file already used for this could be used in the CLI access.

For what? They are referred to the previous statement?

Best regards,
Mike


#18

There is a lot in a roadmap for the GUI

The most important is that the GUI freeze when the “KiCost motor” is working. This is due the logger library used to print at terminal (when running KiCost just by terminal).
I redirect the messages output to the text box (using the GUI_LoggerHandler class at the kicost_gui.py file) by appear that this specific issue is related to the wx.CallLater(10, self.run) directive in wxPython (the graphical library used).
The expected behavior is: not freeze the GUI, print message-by-message in the text box and load the process bar.

What I want to mean with the save GUI fields routine is: doing that (in the actual code) will be allow add many distributors modules / API as we want (not just kitspace and octopart by direct access to digikey, mouser …). The GUI (or the direct modification of the file that saves the GUI information) will allow the user to define the KEYS and what module to use.

Important to remember is that Octopart have price information about more distributors than Kitspace. And Kitspace is a OpenCollective initiative https://opencollective.com/kitspace


#19

Hi. I did a new try with my home setup (Windows 10 Home, KiCAD 5.1.4), kicost updated to the last release trough:

pip install -U git+https://github.com/xesscorp/KiCost/

Launched kicost trough kicad -> EESchema -> Generate Bill Of Materials -> KiCost it!

Nothing happens… I’ll do another try trough console tonight.

Best regards,
Mike


#20

@Michele_Santucci:

  1. Click in “KiCost it!”
  2. See the the button get pressed;
  3. Check that the dialog window is frozen (you can try click again in “KiCost it!” but it will not get pressed)
  4. Wait one or two minutes;
  5. The spreadsheet will automatically open in your default software.

The GUI (Graphical User Interface) have a bug: after click in “KiCost it!” the process bar should start to fill, showing the progress. Now the progress bar just get full at the end, not showing the intermediary process.
I still need some help (by Python programmers) to fix this issue.

Did you reproduce it?


#21

I’m not at home right now but I’m sure the dialog wasn’t frozen at all.