Code Monkey home page Code Monkey logo

Comments (10)

clabnet avatar clabnet commented on August 23, 2024

from esp8266-iot-framework.

maakbaas avatar maakbaas commented on August 23, 2024

Thanks for reporting, however I agree with clabnet, this is related to your local toolchain or PlatformIO, and not to this repository :).

from esp8266-iot-framework.

maxgerhardt avatar maxgerhardt commented on August 23, 2024

For completeness sake since this was also discussed in https://community.platformio.org/t/cannot-build-the-project-keyerror-value/17834/

KeyError: 'value':
File "C:\Users\shalk\Documents\PlatformIO\Projects\Test_Project_Framework.pio\libdeps\esp12e\ESP8266 IoT Framework\scripts\preBuildConfig.py", line 43:
cpp.write("\t" + str(item['value']).lower())

with open(dir_path + '/../gui/js/configuration.json') as f:
data = json.load(f)
# binascii.crc32(mes.encode('utf8'))
#headers
h.write("#ifndef CONFIG_H\n")
h.write("#define CONFIG_H\n\n")
h.write("struct configData\n{\n")
cpp.write("#include <Arduino.h>\n")
cpp.write("#include \"config.h\"\n\n")
cpp.write("uint32_t configVersion = " + str(binascii.crc32(json.dumps(data).encode())) + "; //generated identifier to compare config with EEPROM\n\n")
cpp.write("const configData defaults PROGMEM =\n{\n")
#loop through variables
first = True
for item in data:
if first==True:
first=False
else:
cpp.write(',\n')
if item['type'] == 'char':
cpp.write("\t\"" + item['value'] + "\"")
h.write("\tchar " + item['name'] + "[" + str(item['length']) + "];\n")
elif item['type'] == 'bool':
cpp.write("\t" + str(item['value']).lower())
h.write("\t" + item['type'] + " " + item['name'] +";\n")
else:
cpp.write("\t" + str(item['value']))
h.write("\t" + item['type'] + " " + item['name'] +";\n")

The extra script of the library in this repository is throwing that error (see stacktrace), but it seems to do so because a malformed .json file of the user, if it can't read the value attribute of the object in the JSON file.

from esp8266-iot-framework.

FernandoGarcia avatar FernandoGarcia commented on August 23, 2024

Hi @maakbaas !

I'm getting this error for every single example that have tested.

File "/home/fernandogarcia/Downloads/ESP8266-Iot-framework-test-main/remote-esp-web/.pio/libdeps/esp12e/ESP8266 IoT Framework/scripts/preBuildConfig.py", line 61: cpp.write('\t"' + item["value"] + '"')

I think it doesn't look like an user error since the content of "/../gui/js/configuration.json" is created automatically for your script.

Also I think there's no error in path since the file is opened correctly.

I have checked it using this piece of code before preBuildConfigFun() function.

import sys
filename = inspect.getframeinfo(inspect.currentframe()).filename
dir_path = os.path.dirname(os.path.abspath(filename))
filename = "config"
h = open(dir_path + "/../src/generated/" + filename + ".h", "w", encoding="utf8")
cpp = open(dir_path + "/../src/generated/" + filename + ".cpp", "w", encoding="utf8")
configFile = open(dir_path + "/../gui/js/configuration.json")

if configFile:
    print("Opened!")

    for line in configFile:
        print(line)
sys.exit()

Here you can see the output of this code.

iot framework

Could you give some suggestion to fix this problem please?

Best regards.

from esp8266-iot-framework.

maakbaas avatar maakbaas commented on August 23, 2024

Are you sure you did not modify the code?

This line does not exist in the standard script:
cpp.write('\t"' + item["value"] + '"')

from esp8266-iot-framework.

FernandoGarcia avatar FernandoGarcia commented on August 23, 2024

Max has quoted the code above. Line 40.

from esp8266-iot-framework.

FernandoGarcia avatar FernandoGarcia commented on August 23, 2024

Full compiling output:

Click to expand > [email protected] build > webpack --mode=production

Hash: 30c32e37ec7c4bc7986f
Version: webpack 4.42.1
Time: 9014ms
Built at: 14/07/2021 17:04:50
Asset Size Chunks Chunk Names
./index.html 453 KiB [emitted] [big]
./index.html.gz 122 KiB [emitted]
bundle.js 450 KiB 0 [emitted] [big] main
bundle.js.gz 120 KiB [emitted]
main.css 3.52 KiB 0, 0 [emitted] main, main
main.css.gz 1.01 KiB [emitted]
Entrypoint main [big] = main.css main.css bundle.js
[0] ./node_modules/preact/compat/dist/compat.module.js + 2 modules 19.2 KiB {0} [built]
| 3 modules
[2] ./gui/js/configuration.json 1.63 KiB {0} [built]
[4] ./gui/js/lang/en.json 2.25 KiB {0} [built]
[7] ./gui/js/lang sync ^./.*.json$ 216 bytes {0} [built]
[10] ./gui/js/dashboard.json 10 bytes {0} [built]
[12] (webpack)/buildin/global.js 472 bytes {0} [built]
[29] ./node_modules/@emotion/is-prop-valid/dist/is-prop-valid.browser.esm.js + 1 modules 4.41 KiB {0} [built]
| 2 modules
[46] ./gui/js/lang/de.json 2.38 KiB {0} [optional] [built]
[47] ./gui/js/lang/nl.json 2.34 KiB {0} [optional] [built]
[48] ./gui/js/lang/zh.json 2.12 KiB {0} [optional] [built]
[74] ./gui/js/index.js + 335 modules 1000 KiB {0} [built]
| ./gui/js/index.js 7.28 KiB [built]
| ./gui/js/comp/UiComponents.js 10.7 KiB [built]
| ./gui/js/comp/WifiPage.js 8.22 KiB [built]
| ./gui/js/functions/configHelpers.js 5.25 KiB [built]
| ./gui/js/comp/ConfigPage.js 2.22 KiB [built]
| ./gui/js/comp/DashboardPage.js 4.45 KiB [built]
| ./gui/js/comp/FilePage.js 785 bytes [built]
| ./gui/js/comp/FirmwarePage.js 7.83 KiB [built]
| ./gui/js/comp/DashboardItems.js 9.06 KiB [built]
| ./gui/js/comp/FileListing.js 8.68 KiB [built]
| ./gui/js/comp/ControlItem.js 7.27 KiB [built]
| ./gui/js/comp/DisplayItem.js 2.41 KiB [built]
| + 324 hidden modules
+ 129 hidden modules

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
bundle.js (450 KiB)
./index.html (453 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
main (453 KiB)
main.css
bundle.js

WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = ./index.html
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./gui/index.html 277 bytes {0} [built]
Child mini-css-extract-plugin ../ESP8266 IoT Framework/node_modules/css-loader/dist/cjs.js!../ESP8266 IoT Framework/node_modules/react-vis/dist/style.css:
Entrypoint mini-css-extract-plugin = *
2 modules
KeyError: 'value':
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/main.py", line 177:
env.SConscript("$BUILD_SCRIPT")
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 591:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 280:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/fernandogarcia/.platformio/platforms/espressif8266/builder/main.py", line 238:
target_elf = env.BuildProgram()
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
return self.method(*nargs, **kwargs)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/platformio.py", line 62:
env.ProcessProjectDeps()
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
return self.method(*nargs, **kwargs)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/platformio.py", line 140:
project_lib_builder = env.ConfigureProjectLibBuilder()
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
return self.method(*nargs, **kwargs)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 1062:
project.install_dependencies()
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 880:
if _is_builtin(spec):
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 872:
for lb in self.env.GetLibBuilders():
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
return self.method(*nargs, **kwargs)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 993:
lb = LibBuilderFactory.new(env, lib_dir)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 61:
obj = getattr(sys.modules[name], clsname)(env, path, verbose=verbose)
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 137:
self.process_extra_options()
File "/home/fernandogarcia/.platformio/penv/lib/python3.7/site-packages/platformio/builder/tools/piolib.py", line 282:
exports={"env": self.env, "pio_lib_builder": self},
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 591:
return _SConscript(self.fs, *files, **subst_kw)
File "/home/fernandogarcia/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 280:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/home/fernandogarcia/Downloads/ESP8266-Iot-framework-test-main/remote-esp-web/.pio/libdeps/esp12e/ESP8266 IoT Framework/scripts/preBuild.py", line 58:
preBuildConfigFun()
File "/home/fernandogarcia/Downloads/ESP8266-Iot-framework-test-main/remote-esp-web/.pio/libdeps/esp12e/ESP8266 IoT Framework/scripts/preBuildConfig.py", line 47:
cpp.write('\t"' + item["value"] + '"')

from esp8266-iot-framework.

FernandoGarcia avatar FernandoGarcia commented on August 23, 2024

If do you want try reproduce this error you can use this files.

IOT_framework.zip

from esp8266-iot-framework.

maakbaas avatar maakbaas commented on August 23, 2024

You used the example JSON file from the dashboard for the configuration manager. For the configuration manager, the field value in the JSON file is mandatory, that is what you see in the error message. Fix this by changing your platformio.ini to:

build_flags = -DDASHBOARD_PATH=webconfig.json -DREBUILD_HTML

from esp8266-iot-framework.

FernandoGarcia avatar FernandoGarcia commented on August 23, 2024

Hi!

Thanks for your help.

I think there's a gap in the documentation in this point.

I did a PR to try leave it more clear.

Best regards.

from esp8266-iot-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.