def load_manifest(self, pkg_dir): cache_key = "load_manifest-%s" % pkg_dir result = self.cache_get(cache_key) if result: return result manifest = {} src_manifest = None manifest_path = self.get_manifest_path(pkg_dir) src_manifest_path = self.get_src_manifest_path(pkg_dir) if src_manifest_path: src_manifest = util.load_json(src_manifest_path) if not manifest_path and not src_manifest_path: return None if manifest_path and manifest_path.endswith(".json"): manifest = util.load_json(manifest_path) elif manifest_path and manifest_path.endswith(".properties"): with codecs.open(manifest_path, encoding="utf-8") as fp: for line in fp.readlines(): if "=" not in line: continue key, value = line.split("=", 1) manifest[key.strip()] = value.strip() if src_manifest: if "version" in src_manifest: manifest['version'] = src_manifest['version'] manifest['__src_url'] = src_manifest['url'] # handle a custom package name autogen_name = self.parse_pkg_uri(manifest['__src_url'])[0] if "name" not in manifest or autogen_name != src_manifest['name']: manifest['name'] = src_manifest['name'] if "name" not in manifest: manifest['name'] = basename(pkg_dir) if "version" not in manifest: manifest['version'] = "0.0.0" manifest['__pkg_dir'] = util.path_to_unicode(pkg_dir) self.cache_set(cache_key, manifest) return manifest
def load_manifest(self, pkg_dir): cache_key = "load_manifest-%s" % pkg_dir result = self.cache_get(cache_key) if result: return result manifest = {} src_manifest = None manifest_path = self.get_manifest_path(pkg_dir) src_manifest_path = self.get_src_manifest_path(pkg_dir) if src_manifest_path: src_manifest = util.load_json(src_manifest_path) if not manifest_path and not src_manifest_path: return None if manifest_path and manifest_path.endswith(".json"): manifest = util.load_json(manifest_path) elif manifest_path and manifest_path.endswith(".properties"): with codecs.open(manifest_path, encoding="utf-8") as fp: for line in fp.readlines(): if "=" not in line: continue key, value = line.split("=", 1) manifest[key.strip()] = value.strip() if src_manifest: if "version" in src_manifest: manifest['version'] = src_manifest['version'] manifest['__src_url'] = src_manifest['url'] # handle a custom package name autogen_name = self.parse_pkg_uri(manifest['__src_url'])[0] if "name" not in manifest or autogen_name != src_manifest['name']: manifest['name'] = src_manifest['name'] if "name" not in manifest: manifest['name'] = basename(pkg_dir) if "version" not in manifest: manifest['version'] = "0.0.0" manifest['__pkg_dir'] = util.path_to_unicode(pkg_dir) self.cache_set(cache_key, manifest) return manifest
def get_package_by_dir(self, pkg_dir): for manifest in self.get_installed(): if manifest['__pkg_dir'] == util.path_to_unicode(abspath(pkg_dir)): return manifest return None
def get_package_by_dir(self, pkg_dir): for manifest in self.get_installed(): if manifest['__pkg_dir'] == util.path_to_unicode(abspath(pkg_dir)): return manifest return None
Default("checkprogsize") # Print configured protocols env.AddPreAction(["upload", "program"], env.VerboseAction( lambda source, target, env: env.PrintUploadInfo(), "Configuring upload protocol...")) AlwaysBuild(env.Alias("debug", DEFAULT_TARGETS)) AlwaysBuild(env.Alias("__debug", DEFAULT_TARGETS)) AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS)) ############################################################################## if "envdump" in COMMAND_LINE_TARGETS: print(env.Dump()) env.Exit(0) if "idedata" in COMMAND_LINE_TARGETS: try: print("\n%s\n" % util.path_to_unicode( json.dumps(env.DumpIDEData(), ensure_ascii=False))) env.Exit(0) except UnicodeDecodeError: sys.stderr.write( "\nUnicodeDecodeError: Non-ASCII characters found in build " "environment\n" "See explanation in FAQ > Troubleshooting > Building\n" "https://docs.platformio.org/page/faq.html\n\n") env.Exit(1)
AlwaysBuild(env.Alias("__debug", DEFAULT_TARGETS + ["size"])) AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS + ["size"])) if "UPLOAD_FLAGS" in env: env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"]) for item in env.GetPostExtraScripts(): env.SConscript(item, exports="env") if "envdump" in COMMAND_LINE_TARGETS: print env.Dump() env.Exit(0) if "idedata" in COMMAND_LINE_TARGETS: try: print "\n%s\n" % util.path_to_unicode( json.dumps(env.DumpIDEData(), ensure_ascii=False)) env.Exit(0) except UnicodeDecodeError: sys.stderr.write( "\nUnicodeDecodeError: Non-ASCII characters found in build " "environment\n" "See explanation in FAQ > Troubleshooting > Building\n" "http://docs.platformio.org/page/faq.html\n\n") env.Exit(1) env.AddPreAction(["upload", "program"], Action(lambda source, target, env: env.PrintUploadInfo(), "Configuring upload protocol..."))