Skip to content

Support of the unified command line interface for all devices#289

Merged
syssi merged 18 commits intorytilahti:masterfrom
syssi:feature/unified-cli-support
Apr 8, 2018
Merged

Support of the unified command line interface for all devices#289
syssi merged 18 commits intorytilahti:masterfrom
syssi:feature/unified-cli-support

Conversation

@syssi
Copy link
Copy Markdown
Collaborator

@syssi syssi commented Mar 31, 2018

No description provided.

return self.send("set_power", ["on"])

@command(
default_output = format_output("Powering off"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

defaultdict(lambda: None, zip(properties, values)))

@command(
default_output = format_output("Powering on"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

@command(
click.argument("brightness", type=int),
click.argument("cct", type=int),
default_output=format_output("Setting brightness to {brightness} and color temperature to {cct}")
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 (105 > 100 characters)

return self.send("set_angle_enable", ["off"])

@command(
click.argument("brightness", type=EnumType(LedBrightness, False)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

undefined name 'EnumType'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Import added.

return self.send("set_speed_level", [level]) # 0...100

@command(
click.argument("direction", type=EnumType(MoveDirection, False)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

undefined name 'EnumType'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Import added.

miio/ceil.py Outdated
@command(
click.argument("brightness", type=int),
click.argument("cct", type=int),
default_output=format_output("Setting brightness to {brightness} and color temperature to {cct}")
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 (105 > 100 characters)

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 31, 2018

Coverage Status

Coverage increased (+0.4%) to 70.095% when pulling bb9302e on syssi:feature/unified-cli-support into 91b05a1 on rytilahti:master.

@syssi syssi assigned syssi and unassigned syssi Mar 31, 2018
@syssi syssi requested a review from rytilahti March 31, 2018 21:18
@syssi syssi force-pushed the feature/unified-cli-support branch from 17ac625 to f5547d7 Compare April 1, 2018 07:14
from miio import Vacuum, VacuumStatus
from .dummies import DummyDevice
import datetime
from miio import Vacuum, VacuumStatus, VacuumException
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'miio.VacuumException' imported but unused

from miio import Vacuum, VacuumStatus
from .dummies import DummyDevice
import datetime
from miio import Vacuum, VacuumStatus, VacuumException
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'miio.VacuumException' imported but unused


import click

from .click_common import command, format_output, EnumType
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'.click_common.EnumType' imported but unused

@syssi syssi changed the title Support of the unified commad line interface added to many devices Support of the unified command line interface for all devices Apr 3, 2018
@syssi syssi force-pushed the feature/unified-cli-support branch from fc92fde to c7939cd Compare April 4, 2018 06:24
@syssi
Copy link
Copy Markdown
Collaborator Author

syssi commented Apr 4, 2018

I would be happy to merge this soon. Rebasing the PR takes a lot of time.

Copy link
Copy Markdown
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

There is quite a bit to review, but I think we can simply merge this and do clean-ups later on. I just added a couple of comments for now.

from miio.wifirepeater import WifiRepeater
from miio.wifispeaker import WifiSpeaker
from miio.yeelight import Yeelight

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove the newline.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I made this newline because miio.discovery cannot be moved to line 10. The position of this import is important. The newline shall help here. ;-)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hmm, I'm not following? Why it cannot be moved/why it is important?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If I move the discovery import to the top the tests are failing:

_______________________________________________________________________________________ ERROR collecting miio/tests/test_airconditioningcompanion.py _________________________________________________________________________________________
ImportError while importing test module '/home/sebastian/src/python-miio/miio/tests/test_airconditioningcompanion.py'.                                                                                                                         
Hint: make sure your test modules/packages have valid Python names.                                                                                                                                                                            
Traceback:                                                                                                                                                                                                                                     
miio/__init__.py:2: in <module>                                                                                                                                                                                                                
    from miio.discovery import Discovery                                                                                                                                                                                                       
miio/discovery.py:10: in <module>                                                                                                                                                                                                              
    from . import (Device, Vacuum, ChuangmiPlug, PowerStrip, AirPurifier, Ceil,                                                                                                                                                                
E   ImportError: cannot import name 'Device'                                                                                                                                                                                                   
______________________________________________________________________________________________ ERROR collecting miio/tests/test_airhumidifier.py ______________________________________________________________________________________________
ImportError while importing test module '/home/sebastian/src/python-miio/miio/tests/test_airhumidifier.py'.                                                                                                                                    
Hint: make sure your test modules/packages have valid Python names.                                                                                                                                                                            
Traceback:                                                                                                                                                                                                                                     
miio/__init__.py:2: in <module>                                                                                                                                                                                                                
    from miio.discovery import Discovery                                                                                                                                                                                                       
miio/discovery.py:10: in <module>                                                                                                                                                                                                              
    from . import (Device, Vacuum, ChuangmiPlug, PowerStrip, AirPurifier, Ceil,                                                                                                                                                                
E   ImportError: cannot import name 'Device'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ohh, I see. I just didn't understand why the new line was necessary (as it should be just about the order, right?), but this is fine for me.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct! :-)


@command(
default_output=format_output("Powering the air condition on"),
)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

When it all fits into one line (and there are no arguments), I think it'd be nice to have it all on a single line.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are you sure? It feels hard to read because of the braces and the little spaces.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Well, I think it would be nicer for grepping the code, but it's not so important and can be changed later if needed.

Copy link
Copy Markdown
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Looks good to me, I think we can merge and adjust as needed. What also needs to be added is an updated documentation for the new style cli before releasing a new version.


@command(
default_output=format_output(
"",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe it would make sense to use a keyword argument here, otherwise it remains unclear what does "" do.

@syssi syssi merged commit 71195ce into rytilahti:master Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants