From 8cd1b67a71fbfe8ff0d817257d4bbb352a0f8162 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 23 Jun 2019 15:50:39 +0200 Subject: [PATCH] migrate build.py to platformio 4 (issue #380) --- build.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index fd3b0f53..f7cf7e79 100644 --- a/build.py +++ b/build.py @@ -8,16 +8,22 @@ import requests from os.path import basename from platformio import util +try: + import configparser +except ImportError: + import ConfigParser as configparser + Import("env") # get platformio environment variables -project_config = util.load_project_config() +config = configparser.ConfigParser() +config.read("platformio.ini") # get platformio source path srcdir = env.get("PROJECTSRC_DIR") # check if lmic config file is present in source directory -lmicconfig = project_config.get("common", "lmicconfigfile") +lmicconfig = config.get("common", "lmicconfigfile") lmicconfigfile = os.path.join (srcdir, lmicconfig) if os.path.isfile(lmicconfigfile) and os.access(lmicconfigfile, os.R_OK): print "Parsing LMIC configuration from " + lmicconfigfile @@ -25,14 +31,14 @@ else: sys.exit("Missing file " + lmicconfigfile + ", please create it! Aborting.") # check if lora key file is present in source directory -lorakeyfile = os.path.join (srcdir, project_config.get("common", "lorakeyfile")) +lorakeyfile = os.path.join (srcdir, config.get("common", "lorakeyfile")) if os.path.isfile(lorakeyfile) and os.access(lorakeyfile, os.R_OK): print "Parsing LORAWAN keys from " + lorakeyfile else: sys.exit("Missing file " + lorakeyfile + ", please create it! Aborting.") # check if ota key file is present in source directory -otakeyfile = os.path.join (srcdir, project_config.get("common", "otakeyfile")) +otakeyfile = os.path.join (srcdir, config.get("common", "otakeyfile")) if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK): print "Parsing OTA keys from " + otakeyfile else: @@ -51,7 +57,7 @@ repository = mykeys["BINTRAY_REPO"] apitoken = mykeys["BINTRAY_API_TOKEN"] # get bintray upload parameters from platformio environment -version = project_config.get("common", "release_version") +version = config.get("common", "release_version") package = str(env.get("PIOENV")) # put bintray user credentials to platformio environment