Skip to content

Fix time functions would throw errors in python scripts#11414

Merged
pvizeli merged 4 commits into
home-assistant:devfrom
tomwaters:python-script-time-fix
Jan 7, 2018
Merged

Fix time functions would throw errors in python scripts#11414
pvizeli merged 4 commits into
home-assistant:devfrom
tomwaters:python-script-time-fix

Conversation

@tomwaters
Copy link
Copy Markdown
Contributor

Description:

Python scripts would fail when using time functions. For example a python script containing:
t = time.strptime('08:00', '%H:%M')

Will throw:
Error executing script: 'import'

Related issue (if applicable): fixes #N/A

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#N/A

Example entry for configuration.yaml (if applicable): N/A

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @tomwaters,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

Ok to merge when test added.

attribute = getattr(time, attr)
if callable(attribute):
def wrapper(*args, **kw):
"""Wrapper to return callable method if attribute is callable."""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

attribute = getattr(time, attr)
if callable(attribute):
def wrapper(*args, **kw):
"""Wrapper to return callable method if attribute is callable."""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

@pvizeli pvizeli merged commit 939d1b5 into home-assistant:dev Jan 7, 2018
@balloob balloob mentioned this pull request Jan 11, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants