L0laapk3 / FactorioMaps

L0laapk3's FactorioMaps mod
https://mods.factorio.com/mod/L0laapk3_FactorioMaps
Other
119 stars 22 forks source link

Error when copying icons to webroot #45

Closed badboybeyer closed 4 years ago

badboybeyer commented 5 years ago

When executing auto.py i get an error after the cleanup step:

cleaning up
Traceback (most recent call last):
  File "./auto.py", line 702, in <module>
    auto(*sys.argv[1:])
  File "./auto.py", line 628, in auto
    copy(src, dest)
  File "/home/myusername/.local/share/virtualenvs/L0laapk3_FactorioMaps_3.4.0-niQMlvrd/lib/python3.7/shutil.py", line 245, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/myusername/.local/share/virtualenvs/L0laapk3_FactorioMaps_3.4.0-niQMlvrd/lib/python3.7/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
NotADirectoryError: [Errno 20] Not a directory: '/home/myusername/Downloads/factorio/bin/x64/factorio/../../../data/base/graphics/icons/electronic-circuit.png'

This is because bin/x64/factorio is not a directory, it is an executable. I made the following change:

diff --git a/auto.py b/auto.py
index 9a22f87..763162b 100644
--- a/auto.py
+++ b/auto.py
@@ -607,7 +607,7 @@ def auto(*args):
                                iconColor = m.group(2).split("?")
                                icon = iconColor[0]
                                if m.group(1) in ("base", "core"):
-                                       src = os.path.join(factorioPath, "../../../data", m.group(1), icon + ".png")
+                                       src = os.path.join(os.path.split(factorioPath)[0], "../../data", m.group(1), icon + ".png")
                                else:
                                        mod = next(mod for mod in modVersions if mod[0] == m.group(1).lower())
                                        if not mod[1][3]: #true if mod is zip