MitjaNemec / Kicad_action_plugins

Kicad action plugins
413 stars 62 forks source link

make save_restore_layout to work with wx 4.0 and python3 on linux #68

Closed lumostor closed 4 years ago

lumostor commented 4 years ago

Hi, Thanks for for this awesome work.

I had to do some modifications to make it to work on linux(debian-testing).

wx.version()-> '4.0.6 gtk3 (phoenix) wxWidgets 3.0.4' python.version()->'3.7.4+ (default, Sep 4 2019, 08:03:05) \n[GCC 9.2.1 20190827]' kicad '5.1.4+dfsg1-1, release build'

got the following complains:

1:

Traceback (most recent call last):
  File "~/.kicad_plugins/save_restore_layout/action_save_restore_layout.py", line 251, in Run
    save_layout.save_layout(pivot_mod, pivot_mod.sheetname[0:index + 1], layout_file)
  File "~/.kicad_plugins/save_restore_layout/save_restore_layout.py", line 895, in save_layout
    md5hash = self.schematics.get_sch_hash(sch_file, md5hash)
  File "~/.kicad_plugins/save_restore_layout/save_restore_layout.py", line 175, in get_sch_hash
    md5hash.update(line)
TypeError: Unicode-objects must be encoded before hashing

CORRECTED with md5hash.update(line.encode('utf-8'))

2

AttributeError: module 'wx' has no attribute 'SAVE'

CORRECTED with wx.FD_SAVE instead os wx.SAVE

3 AttributeError: module 'wx' has no attribute 'OPEN'

CORRECTED with wx.FD_OPEN instead os wx.OPEN

This will break code running with wx 3.x.

lumostor commented 4 years ago

This afternoon I was able to save and restore on another machine (ubuntu 19.10/kicad-5.1.4) with these modifications. Now on another machine (debian-testing) I'm able to save but on restore kicad crash and I got:

kicad: /build/kicad-2BBSqv/kicad-5.1.4+dfsg1/pcbnew/./board_connected_item.h:95: void BOARD_CONNECTED_ITEM::SetNet(NETINFO_ITEM *): AssertionaNetInfo->GetBoard() == GetBoard()' failed. `

save_restore_layout.log:

10-04 22:57:30 save_restore_layout.action_save_restore_layout 154:Plugin executed with python version: '3.7.4+ (default, Sep 4 2019, 08:03:05) \n[GCC 9.2.1 20190827]' 10-04 22:57:30 save_restore_layout.action_save_restore_layout 155:Save/Restore Layout plugin version: 22 started 10-04 22:57:31 save_restore_layout.action_save_restore_layout 266:Restore layout chosen 10-04 22:57:35 save_restore_layout.save_restore_layout 362:Getting board info 10-04 22:57:35 save_restore_layout.save_restore_layout 364:Getting schematics info 10-04 22:57:35 save_restore_layout.save_restore_layout 150:getting project hierarchy from schematics 10-04 22:57:35 save_restore_layout.save_restore_layout 152:Project hierarchy looks like: {'5D9F8B30': ['Motor Driver', '~/prj/motor_driver.sch'], '5DC7ACAB': ['sheet5DC7AC9C', '~/prj/motor_driver.sch']} 10-04 22:57:35 save_restore_layout.save_restore_layout 366:Getting layout info 10-04 22:57:35 save_restore_layout.save_restore_layout 225:getting a list of all footprints on board 10-04 22:57:35 save_restore_layout.save_restore_layout 368:Updating layout info with schematics info 10-04 22:57:35 save_restore_layout.save_restore_layout 706:Loading saved design 10-04 22:57:35 save_restore_layout.save_restore_layout 713:Source levels is:['motor_driver.sch'] 10-04 22:57:35 save_restore_layout.save_restore_layout 724:Destination levels is:['motor_driver.sch'] 10-04 22:57:35 save_restore_layout.save_restore_layout 729:All sch files required are: ['motor_driver.sch'] 10-04 22:57:35 save_restore_layout.save_restore_layout 731:Getting current schematics hash 10-04 22:57:35 save_restore_layout.save_restore_layout 741:Source hash is:'dab2363e945cf41da9373b77b805fe08' 10-04 22:57:35 save_restore_layout.save_restore_layout 742:Destination hash is: 'dab2363e945cf41da9373b77b805fe08' 10-04 22:57:35 save_restore_layout.save_restore_layout 759:Get layout data from saved board 10-04 22:57:35 save_restore_layout.save_restore_layout 225:getting a list of all footprints on board 10-04 22:57:35 save_restore_layout.save_restore_layout 473:Replicating footprints 10-04 22:57:35 save_restore_layout.save_restore_layout 575:Replicating tracks

MitjaNemec commented 4 years ago

Hi, thanks for contribution.

The encoding is a python3 compatibility issue, but the fix works also on python2 I don't have a clue what SAVE vs FD_SAVE differences are, but on my setup MSW 5.1.4 python2 it works either way, so I'll merge the pull request and I'll merge it to master

As for the assertion you get, it is probably different issue. It looks like a bug in KiCad and not in the plugin, but I'll add logging where I think it is important and we should be able to narrow it down

MitjaNemec commented 4 years ago

As for the timeline, I'll merge it to master only when I merge the GUI changes in #66, otherwise I'll have a complete mess in git log.

MitjaNemec commented 4 years ago

Here you go, you've got a new branch available Added_logging_for_track_setnet. If you run the plugin again we should have a bit more data when (with which net) it fails