From 7c0b187ca0de18457d6d2989b0aece829b7adb5e Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Tue, 24 Feb 2015 20:11:57 +0200 Subject: [PATCH 1/3] Extend validation of package for SHA1 // Resolve #69 --- tests/test_pkgmanifest.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index fd079ea9..a008ea5c 100644 --- a/tests/test_pkgmanifest.py +++ b/tests/test_pkgmanifest.py @@ -1,10 +1,31 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +import pytest import requests +from os.path import basename + from platformio.util import get_api_result +@pytest.fixture(scope="session") +def sfpkglist(): + result = None + r = None + + try: + r = requests.get("http://sourceforge.net/projects" + "/platformio-storage/files/packages/list") + result = r.json() + r.raise_for_status() + except: + pass + finally: + if r: + r.close() + return result + + def pytest_generate_tests(metafunc): if "package_data" not in metafunc.fixturenames: return @@ -22,13 +43,25 @@ def validate_response(req): assert int(req.headers['Content-Length']) > 0 -def validate_package(url): +def validate_package(url, sfpkglist): r = requests.head(url, allow_redirects=True) validate_response(r) assert r.headers['Content-Type'] in ("application/x-gzip", "application/octet-stream") -def test_package(package_data): +def test_package(package_data, sfpkglist): assert package_data['url'].endswith("%d.tar.gz" % package_data['version']) - validate_package(package_data['url']) + + # check content type and that file exists + r = requests.head(package_data['url'], allow_redirects=True) + validate_response(r) + assert r.headers['Content-Type'] in ("application/x-gzip", + "application/octet-stream") + + # check sha1 sum + if sfpkglist is None: + return + pkgname = basename(package_data['url']) + assert pkgname in sfpkglist + assert package_data['sha1'] == sfpkglist.get(pkgname, {}).get("sha1") From cd764d4b10af2e259e68672a3a3bf40472df49cd Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Wed, 25 Feb 2015 18:32:33 +0200 Subject: [PATCH 2/3] Skip testing of package if SF is offline --- tests/test_pkgmanifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index a008ea5c..25bddfd2 100644 --- a/tests/test_pkgmanifest.py +++ b/tests/test_pkgmanifest.py @@ -61,7 +61,7 @@ def test_package(package_data, sfpkglist): # check sha1 sum if sfpkglist is None: - return + return pytest.skip("SF is offline") pkgname = basename(package_data['url']) assert pkgname in sfpkglist assert package_data['sha1'] == sfpkglist.get(pkgname, {}).get("sha1") From fbd3d956f72f674d92be1090f5e63dec6f920f55 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Wed, 25 Feb 2015 18:33:34 +0200 Subject: [PATCH 3/3] Add "platformio-udev" rules --- docs/platforms/atmelavr.rst | 6 ++-- docs/platforms/atmelsam.rst | 6 ++-- docs/platforms/stm32.rst | 6 ++-- docs/platforms/teensy.rst | 6 ++-- docs/platforms/timsp430.rst | 6 ++-- docs/platforms/titiva.rst | 6 ++-- scripts/99-platformio-udev.rules | 57 ++++++++++++++++++++++++++++++++ 7 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 scripts/99-platformio-udev.rules diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 6ba7a7d3..090149c6 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -37,9 +37,9 @@ Packages - See below in :ref:`atmelavr_frameworks` -.. note:: - You can install ``atmelavr`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _atmelavr_frameworks: diff --git a/docs/platforms/atmelsam.rst b/docs/platforms/atmelsam.rst index 796d9188..9070424f 100644 --- a/docs/platforms/atmelsam.rst +++ b/docs/platforms/atmelsam.rst @@ -31,9 +31,9 @@ Packages - See below in :ref:`atmelsam_frameworks` -.. note:: - You can install ``atmelsam`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _atmelsam_frameworks: diff --git a/docs/platforms/stm32.rst b/docs/platforms/stm32.rst index ab4000c3..4748f6a9 100644 --- a/docs/platforms/stm32.rst +++ b/docs/platforms/stm32.rst @@ -35,9 +35,9 @@ Packages - - See below in :ref:`stm32_frameworks` -.. note:: - You can install ``stm32`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _stm32_frameworks: diff --git a/docs/platforms/teensy.rst b/docs/platforms/teensy.rst index a60b6d02..37f172c6 100644 --- a/docs/platforms/teensy.rst +++ b/docs/platforms/teensy.rst @@ -34,9 +34,9 @@ Packages - See below in :ref:`teensy_frameworks` -.. note:: - You can install ``teensy`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _teensy_frameworks: diff --git a/docs/platforms/timsp430.rst b/docs/platforms/timsp430.rst index f10d1578..256f9f36 100644 --- a/docs/platforms/timsp430.rst +++ b/docs/platforms/timsp430.rst @@ -31,9 +31,9 @@ Packages - See below in :ref:`timsp430_frameworks` -.. note:: - You can install ``atmelavr`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _timsp430_frameworks: diff --git a/docs/platforms/titiva.rst b/docs/platforms/titiva.rst index b9d822b9..208742d9 100644 --- a/docs/platforms/titiva.rst +++ b/docs/platforms/titiva.rst @@ -34,9 +34,9 @@ Packages - - See below in :ref:`titiva_frameworks` -.. note:: - You can install ``titiva`` platform with these packages - via :ref:`cmd_install` command. +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). .. _titiva_frameworks: diff --git a/scripts/99-platformio-udev.rules b/scripts/99-platformio-udev.rules new file mode 100644 index 00000000..34045ef3 --- /dev/null +++ b/scripts/99-platformio-udev.rules @@ -0,0 +1,57 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +# UDEV Rules for PlatformIO supproted boards, http://platformio.org/#!/boards +# +# The latest version of this file may be found at: +# https://github.com/ivankravets/platformio/blob/develop/scripts/99-platformio-udev.rules +# +# This file must be placed at: +# /etc/udev/rules.d/99-platformio-udev.rules (preferred location) +# or +# /lib/udev/rules.d/99-platformio-udev.rules (req'd on some broken systems) +# +# To install, type this command in a terminal: +# sudo cp 99-platformio-udev.rules /etc/udev/rules.d/99-platformio-udev.rules +# +# Restart "udev" management tool: +# sudo service udev restart +# or +# sudo udevadm control --reload-rules +# sudo udevadm trigger +# +# After this file is installed, physically unplug and reconnect your board. + +# CP210X USB UART +SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0666" + +# FT232R USB UART +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666" + +# Prolific Technology, Inc. PL2303 Serial Port +SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE:="0666" + +# ARDUINO UNO +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", MODE:="0666" + +# Digistump boards +SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666" +KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1" + +# STM32 discovery boards, with onboard st/linkv2 +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0666" + +# USBtiny +SUBSYSTEMS=="usb", ATTRS{idProduct}=="0c9f", ATTRS{idVendor}=="1781", MODE="0666" + +# Teensy boards +ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{ID_MM_DEVICE_IGNORE}="1" +ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{MTP_NO_PROBE}="1" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666" +KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666" + +#TI Stellaris Launchpad +SUBSYSTEMS=="usb", ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", MODE="0666" + +#TI MSP430 Launchpad +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0666"