Merge branch 'develop' of https://github.com/valeros/platformio into develop

This commit is contained in:
Valeriy Koval
2015-02-12 14:46:53 +02:00
4 changed files with 26 additions and 38 deletions

View File

@ -27,7 +27,7 @@ Get/List existing settings
Examples Examples
~~~~~~~~ ~~~~~~~~
1. List all settings and theirs current values 1. List all settings and current their values
.. code-block:: bash .. code-block:: bash
@ -38,9 +38,7 @@ Examples
auto_update_platforms Yes Automatically update platforms (Yes/No) auto_update_platforms Yes Automatically update platforms (Yes/No)
check_libraries_interval 7 Check for the library updates interval (days) check_libraries_interval 7 Check for the library updates interval (days)
check_platformio_interval 3 Check for the new PlatformIO interval (days) check_platformio_interval 3 Check for the new PlatformIO interval (days)
check_platforms_interval 7 Check for the platform updates interval (days) check_platforms_interval 7 Check for the platforms updates interval (days)
enable_prompts Yes Can PlatformIO communicate with you via prompts: propose to install platforms which aren't installed yet, paginate over library search results and etc.)? ATTENTION!!! If you call PlatformIO like subprocess, please disable prompts to avoid blocking (Yes/No)
enable_telemetry Yes Shares commands, platforms and libraries usage to help us make PlatformIO better (Yes/No)
2. Show specified setting 2. Show specified setting

View File

@ -560,5 +560,5 @@
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": false "wait_for_upload_port": false
} }
} }
} }

View File

@ -81,11 +81,9 @@ if "BOARD" in env:
if "BOARD_F_CPU" not in env: if "BOARD_F_CPU" not in env:
env.Replace(BOARD_F_CPU="${BOARD_OPTIONS['build']['f_cpu']}") env.Replace(BOARD_F_CPU="${BOARD_OPTIONS['build']['f_cpu']}")
if "UPLOAD_PROTOCOL" not in env: if "UPLOAD_PROTOCOL" not in env:
env.Replace( env.Replace(UPLOAD_PROTOCOL="${BOARD_OPTIONS['upload']['protocol']}")
UPLOAD_PROTOCOL="${BOARD_OPTIONS['upload'].get('protocol', None)}")
if "UPLOAD_SPEED" not in env: if "UPLOAD_SPEED" not in env:
env.Replace( env.Replace(UPLOAD_SPEED="${BOARD_OPTIONS['upload']['speed']}")
UPLOAD_SPEED="${BOARD_OPTIONS['upload'].get('speed', None)}")
if "IGNORE_LIBS" in env: if "IGNORE_LIBS" in env:
env['IGNORE_LIBS'] = [l.strip() for l in env['IGNORE_LIBS'].split(",")] env['IGNORE_LIBS'] = [l.strip() for l in env['IGNORE_LIBS'].split(",")]

View File

@ -10,7 +10,9 @@ from subprocess import PIPE, Popen
import requests import requests
from platformio import __apiurl__, __version__, exception from platformio import __apiurl__, __version__
from platformio.exception import (APIRequestError, GetSerialPortsError,
NotPlatformProject)
try: try:
from configparser import ConfigParser from configparser import ConfigParser
@ -31,7 +33,7 @@ def get_home_dir():
if (config.has_section("platformio") and if (config.has_section("platformio") and
config.has_option("platformio", "home_dir")): config.has_option("platformio", "home_dir")):
home_dir = config.get("platformio", "home_dir") home_dir = config.get("platformio", "home_dir")
except exception.NotPlatformProject: except NotPlatformProject:
pass pass
if not home_dir: if not home_dir:
@ -53,7 +55,7 @@ def get_lib_dir():
if lib_dir.startswith("~"): if lib_dir.startswith("~"):
lib_dir = expanduser(lib_dir) lib_dir = expanduser(lib_dir)
return abspath(lib_dir) return abspath(lib_dir)
except exception.NotPlatformProject: except NotPlatformProject:
pass pass
return join(get_home_dir(), "lib") return join(get_home_dir(), "lib")
@ -73,7 +75,7 @@ def get_pioenvs_dir():
def get_project_config(): def get_project_config():
path = join(get_project_dir(), "platformio.ini") path = join(get_project_dir(), "platformio.ini")
if not isfile(path): if not isfile(path):
raise exception.NotPlatformProject(get_project_dir()) raise NotPlatformProject(get_project_dir())
cp = ConfigParser() cp = ConfigParser()
cp.read(path) cp.read(path)
return cp return cp
@ -99,7 +101,7 @@ def get_serialports():
elif os_name == "posix": elif os_name == "posix":
from serial.tools.list_ports_posix import comports from serial.tools.list_ports_posix import comports
else: else:
raise exception.GetSerialPortsError(os_name) raise GetSerialPortsError(os_name)
return[{"port": p, "description": d, "hwid": h} for p, d, h in comports()] return[{"port": p, "description": d, "hwid": h} for p, d, h in comports()]
@ -125,15 +127,14 @@ def get_api_result(path, params=None, data=None):
r.raise_for_status() r.raise_for_status()
except requests.exceptions.HTTPError as e: except requests.exceptions.HTTPError as e:
if result and "errors" in result: if result and "errors" in result:
raise exception.APIRequestError(result['errors'][0]['title']) raise APIRequestError(result['errors'][0]['title'])
else: else:
raise exception.APIRequestError(e) raise APIRequestError(e)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
raise exception.APIRequestError( raise APIRequestError(
"Could not connect to PlatformIO Registry Service") "Could not connect to PlatformIO Registry Service")
except ValueError: except ValueError:
raise exception.APIRequestError( raise APIRequestError("Invalid response: %s" % r.text.encode("utf-8"))
"Invalid response: %s" % r.text.encode("utf-8"))
finally: finally:
if r: if r:
r.close() r.close()
@ -142,24 +143,15 @@ def get_api_result(path, params=None, data=None):
def get_boards(type_=None): def get_boards(type_=None):
boards = {} boards = {}
try: bdirs = [join(get_source_dir(), "boards")]
boards = get_boards._cache # pylint: disable=W0212 if isdir(join(get_home_dir(), "boards")):
except AttributeError: bdirs.append(join(get_home_dir(), "boards"))
bdirs = [join(get_source_dir(), "boards")]
if isdir(join(get_home_dir(), "boards")):
bdirs.append(join(get_home_dir(), "boards"))
for bdir in bdirs: for bdir in bdirs:
for json_file in listdir(bdir): for json_file in listdir(bdir):
if not json_file.endswith(".json"): if not json_file.endswith(".json"):
continue continue
with open(join(bdir, json_file)) as f: with open(join(bdir, json_file)) as f:
boards.update(json.load(f)) boards.update(json.load(f))
get_boards._cache = boards # pylint: disable=W0212
if type_ is None: return boards[type_] if type_ is not None else boards
return boards
else:
if type_ not in boards:
raise exception.UnknownBoard(type_)
return boards[type_]