mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Report about outdated 99-platformio-udev.rules // Resolve #1823
This commit is contained in:
@ -15,6 +15,8 @@ PlatformIO 3.0
|
||||
* Support in-line comments for multi-line value (``lib_deps``, ``build_flags``, etc) in `“platformio.ini” (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
|
||||
* Do not re-create ".gitignore" and ".travis.yml" files if they were removed
|
||||
from a project
|
||||
* Report about outdated `99-platformio-udev.rules <http://docs.platformio.org/page/faq.html#platformio-udev-rules>`__
|
||||
(`issue #1823 <https://github.com/platformio/platformio-core/issues/1823>`_)
|
||||
* Fixed an issue when dynamic build flags were not handled correctly
|
||||
(`issue #1799 <https://github.com/platformio/platformio-core/issues/1799>`_)
|
||||
|
||||
|
2
docs
2
docs
Submodule docs updated: 97cde4edd9...4d4a51260b
@ -25,7 +25,7 @@ from time import sleep
|
||||
from SCons.Script import ARGUMENTS
|
||||
from serial import Serial, SerialException
|
||||
|
||||
from platformio import util
|
||||
from platformio import exception, util
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
@ -154,15 +154,10 @@ def AutodetectUploadPort(*args, **kwargs):
|
||||
and not env.subst("$UPLOAD_PROTOCOL"))):
|
||||
env.Replace(UPLOAD_PORT=_look_for_mbed_disk())
|
||||
else:
|
||||
if ("linux" in util.get_systype() and not any([
|
||||
isfile("/etc/udev/rules.d/99-platformio-udev.rules"),
|
||||
isfile("/lib/udev/rules.d/99-platformio-udev.rules")
|
||||
])):
|
||||
sys.stderr.write(
|
||||
"\nWarning! Please install `99-platformio-udev.rules` and "
|
||||
"check that your board's PID and VID are listed in the rules."
|
||||
"\n https://docs.platformio.org/en/latest/faq.html"
|
||||
"#platformio-udev-rules\n")
|
||||
try:
|
||||
util.ensure_udev_rules()
|
||||
except exception.InvalidUdevRules as e:
|
||||
sys.stderr.write("\n%s\n\n" % e)
|
||||
env.Replace(UPLOAD_PORT=_look_for_serial_port())
|
||||
|
||||
if env.subst("$UPLOAD_PORT"):
|
||||
|
@ -141,7 +141,7 @@ def BuildProgram(env):
|
||||
return program
|
||||
|
||||
|
||||
def ParseFlagsExtended(env, flags):
|
||||
def ParseFlagsExtended(env, flags): # pylint: disable=too-many-branches
|
||||
if not isinstance(flags, list):
|
||||
flags = [flags]
|
||||
result = {}
|
||||
|
@ -235,6 +235,25 @@ class CIBuildEnvsEmpty(PlatformioException):
|
||||
"predefined environments using `--project-conf` option")
|
||||
|
||||
|
||||
class InvalidUdevRules(PlatformioException):
|
||||
pass
|
||||
|
||||
|
||||
class MissedUdevRules(InvalidUdevRules):
|
||||
|
||||
MESSAGE = (
|
||||
"Warning! Please install `99-platformio-udev.rules`. \nMode details: "
|
||||
"https://docs.platformio.org/en/latest/faq.html#platformio-udev-rules")
|
||||
|
||||
|
||||
class OutdatedUdevRules(InvalidUdevRules):
|
||||
|
||||
MESSAGE = (
|
||||
"Warning! Your `{0}` are outdated. Please update or reinstall them."
|
||||
"\n Mode details: https://docs.platformio.org"
|
||||
"/en/latest/faq.html#platformio-udev-rules")
|
||||
|
||||
|
||||
class UpgradeError(PlatformioException):
|
||||
|
||||
MESSAGE = """{0}
|
||||
|
@ -786,6 +786,43 @@ def merge_dicts(d1, d2, path=None):
|
||||
return d1
|
||||
|
||||
|
||||
def ensure_udev_rules():
|
||||
|
||||
def _rules_to_set(rules_path):
|
||||
result = set([])
|
||||
with open(rules_path, "rb") as fp:
|
||||
for line in fp.readlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
result.add(line)
|
||||
return result
|
||||
|
||||
if "linux" not in get_systype():
|
||||
return None
|
||||
installed_rules = [
|
||||
"/etc/udev/rules.d/99-platformio-udev.rules",
|
||||
"/lib/udev/rules.d/99-platformio-udev.rules"
|
||||
]
|
||||
if not any(isfile(p) for p in installed_rules):
|
||||
raise exception.MissedUdevRules
|
||||
|
||||
origin_path = abspath(
|
||||
join(get_source_dir(), "..", "scripts", "99-platformio-udev.rules"))
|
||||
if not isfile(origin_path):
|
||||
return None
|
||||
|
||||
origin_rules = _rules_to_set(origin_path)
|
||||
for rules_path in installed_rules:
|
||||
if not isfile(rules_path):
|
||||
continue
|
||||
current_rules = _rules_to_set(rules_path)
|
||||
if not origin_rules <= current_rules:
|
||||
raise exception.OutdatedUdevRules(rules_path)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def rmtree_(path):
|
||||
|
||||
def _onerror(_, name, __):
|
||||
|
5
setup.py
5
setup.py
@ -37,7 +37,7 @@ setup(
|
||||
license=__license__,
|
||||
python_requires='>=2.7, <3',
|
||||
install_requires=install_requires,
|
||||
packages=find_packages(),
|
||||
packages=find_packages() + ["scripts"],
|
||||
package_data={
|
||||
"platformio": [
|
||||
"projectconftpl.ini",
|
||||
@ -45,6 +45,9 @@ setup(
|
||||
"ide/tpls/*/*.tpl",
|
||||
"ide/tpls/*/*/*.tpl",
|
||||
"ide/tpls/*/.*/*.tpl"
|
||||
],
|
||||
"scripts": [
|
||||
"99-platformio-udev.rules"
|
||||
]
|
||||
},
|
||||
entry_points={
|
||||
|
Reference in New Issue
Block a user