Commit Graph

17 Commits (81d3161a5e2ced733e4b3febc6baf58f9936f41c)

Author SHA1 Message Date
Fabian Affolter 8deb462471
Upgrade restrictedpython to 4.0b4 (#14537) 2018-05-19 10:05:02 +02:00
Fabian Affolter ea5c336ab4
Upgrade restrictedpython to 4.0b3 (#14140) 2018-04-28 19:21:37 +02:00
Otto Winter 678f284015 Upgrade pylint to 1.8.2 (#12274)
* Upgrade pylint to 1.8.1

* Fix no-else-return

* Fix bad-whitespace

* Fix too-many-nested-blocks

* Fix raising-format-tuple

See https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/1.8.rst

* Fix len-as-condition

* Fix logging-not-lazy

Not sure about that TEMP_CELSIUS though, but internally it's probably just like if you concatenated any other (variable) string

* Fix stop-iteration-return

* Fix useless-super-delegation

* Fix trailing-comma-tuple

Both of these seem to simply be bugs:
 * Nest: The value of self._humidity never seems to be used anywhere
 * Dovado: The called API method seems to expect a "normal" number

* Fix redefined-argument-from-local

* Fix consider-using-enumerate

* Fix wrong-import-order

* Fix arguments-differ

* Fix missed no-else-return

* Fix no-member and related

* Fix signatures-differ

* Revert "Upgrade pylint to 1.8.1"

This reverts commit af78aa00f125a7d34add97b9d50c14db48412211.

* Fix arguments-differ

* except for device_tracker

* Cleanup

* Fix test using positional argument

* Fix line too long

I forgot to run flake8 - shame on me... 🙃

* Fix bad-option-value for 1.6.5

* Fix arguments-differ for device_tracker

* Upgrade pylint to 1.8.2

* 👕 Fix missed no-member
2018-02-11 09:20:28 -08:00
Fabian Affolter 47e31dc9ee Fixes for PEP257 (#11810)
* Fixes for PEP257

* More updates
2018-01-20 22:35:38 -08:00
Tom Waters 939d1b5ff6 Fix time functions would throw errors in python scripts (#11414)
* Fix time functions would throw errors in python scripts

* Added unit test for time.strptime, change variable name to satisfy lint

* Added docstring for time attribute wrapper method to satisfy lint

* Fixed line too long lint problem
2018-01-07 01:50:55 +01:00
Egor Tsinko f052a0926b Added sorted() to python_script (#10621)
* added sorted() to python_script

* fixed lint errors
2017-11-16 22:06:02 -08:00
Fabian Affolter 2891b0cb2e Upgrade restrictedpython to 4.0b2 (#10179)
* Upgrade restrictedpython to 4.0b2

* Update test
2017-10-30 00:02:15 -07:00
Paulus Schoutsen 414900fefb Expose time module in Python Scripts (#9736)
* Expose time module in Python Scripts

* Make dt_util available in Python Scripts

* Limit methods in time module

* Add time.mktime

* Limit access to datetime

* Add warning to time.sleep

* Lint
2017-10-09 08:51:32 +02:00
Sébastien RAMAGE c26fb9906f Add reload service to python_script (#9512)
* Add reload service

* add reload test

* Use global variable

* remove white space ....

* adjust as suggested

* remove annoying white space....

* fix travis

* fix travis, again

* rename Load_scripts to Discover_scripts

Travis complains that "Load_scripts" is an invalid name (I don't know why)

* Update python_script.py
2017-09-21 17:00:45 +02:00
Sébastien RAMAGE 20f3e3dcf9 Improve Python script (#9417)
* add datetime and support for unpacksequence

add datetime to builtin and support for unpacksequence
a,b = (1,2)
for a,b in [(1,2),(3,4)]

* add test for python_script

* fix test

* restore previous test

restore previous tests, removed by mistake sorry...

* fix test

* Update test_python_script.py

* fix travis

* fix test

* Update test_python_script.py

* Add files via upload

* fix travis...
2017-09-14 07:52:47 -07:00
Sean Dague 8d1999dc12 Enhance python_script to support "_getitem_" (#8541)
* Enhance python_script to support "_getitem_"

In order to use dict / list structures in python scripts we need
_getitem_ allowed in the RestrictedPython environment. There is a
default_guarded_getitem included with RestrictedPython, which is a
pass through used in the Eval code paths.

* Add tests for dict/list support in python_scripts

* Lint
2017-07-19 22:56:24 -07:00
Paulus Schoutsen d29bdddaa7 Add bind_hass to components (#8502)
* Add bind_hass to components

* Add bind_hass to group
2017-07-16 10:14:46 -07:00
Open Home Automation fe4abc8454 Integrate utility functions into restricted Python environment (#8427) 2017-07-10 18:42:42 -07:00
Paulus Schoutsen 6398e92836 Allow iteration in python_script (#8134)
* Allow iteration in python_script

* Add tests
2017-06-21 13:32:50 +02:00
Paulus Schoutsen 87274879a8 Upgrade RestrictedPython dependency (#8132) 2017-06-20 19:30:01 -07:00
Paulus Schoutsen 74cc675a38 Restrict Python Script (#8053) 2017-06-15 22:13:10 -07:00
Paulus Schoutsen db0efc647d New component: Python Script (#7950)
* Add initial version

* Fix requirements

* Prefer logging over printing

* Set executor thread name on >Py36 only

* Add tests

* Lint

* Add restrictedpython to test dependencies

* Create python_script.py

From doc:
```
However, an empty dict ({}) is treated as is. If you want to specify a list that can contain anything, specify it as dict:
>>> schema = Schema({}, extra=ALLOW_EXTRA)  # don't do this
>>> try:
...   schema({'extra': 1})
...   raise AssertionError('MultipleInvalid not raised')
... except MultipleInvalid as e:
...   exc = e
>>> str(exc) == "not a valid value"
True
>>> schema({})
{}
>>> schema = Schema(dict)  # do this instead
>>> schema({})
{}
>>> schema({'extra': 1})
{'extra': 1}

```
2017-06-09 12:38:40 +02:00