From 9ead140b6e2c57e971e77fffa81f0c1c18eef9ad Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 5 Oct 2014 23:34:40 +0300 Subject: [PATCH] Fix lib update crashing when no libs are installed (resolve issue #19) --- HISTORY.rst | 1 + platformio/commands/lib.py | 7 +++++-- platformio/libmanager.py | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 28e6f71e..b20c9b45 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,7 @@ Release History * Fixed bug with order for includes in conversation from INO/PDE to CPP * Automatic detection of port on upload (`issue #15 `_) +* Fixed lib update crashing when no libs are installed (`issue #19 `_) 0.7.0 (2014-09-24) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 9de31be2..07aef25a 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -140,9 +140,12 @@ def lib_show(name): @cli.command("update", short_help="Update installed libraries") def lib_update(): lm = LibraryManager(get_lib_dir()) - lib_names = lm.get_installed() - versions = get_api_result("/lib/version/" + ",".join(lib_names)) + lib_names = lm.get_installed() + if not lib_names: + return + + versions = get_api_result("/lib/version/" + ",".join(lib_names)) for name in lib_names: info = lm.get_info(name) diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 2fb4a185..4a522d78 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -33,6 +33,8 @@ class LibraryManager(object): def get_installed(self): items = [] + if not isdir(self.lib_dir): + return items for item in listdir(self.lib_dir): conf_path = join(self.lib_dir, item, self.CONFIG_NAME) if isfile(conf_path):