Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group support #120

Merged
merged 12 commits into from
Jul 20, 2018
Merged

Group support #120

merged 12 commits into from
Jul 20, 2018

Conversation

theychx
Copy link
Collaborator

@theychx theychx commented Jul 16, 2018

We are now assuming that 1st/2nd gen. chromecasts are the only kinds of devices that report different names via DIAL/zeroconf.

fixes #119

Please test, as I do not have access to multiple audio devices myself.

theychx added 4 commits July 16, 2018 16:05
..so that it returns zeroconf data instead.
..as we can now not be shure whether device data was obtained via DIAL or zeroconf.
@skorokithakis
Copy link
Owner

Thanks, @theychx! @saulrh, can you give this a spin?

@theychx
Copy link
Collaborator Author

theychx commented Jul 16, 2018

@skorokithakis
We would have to store the group port in the cache, for this to work properly (there is no default group port). I don't know how you want to handle this, with regards to upgrades.

@skorokithakis
Copy link
Owner

Hmm, why would upgrades be an issue? We'd just need to make a note somewhere near the cache to know what kind of information we store, so we can migrate it (or just delete it) between versions.

It might not be such a bad idea to key the cache off the app version, if we ever introduce a backwards-incompatible schema change.

@theychx
Copy link
Collaborator Author

theychx commented Jul 16, 2018

OK, so we implement a check of the cache format and delete if it's wrong?

It might not be such a bad idea to key the cache off the app version

Please explain.

@skorokithakis
Copy link
Owner

Add the app's version to the keys of the cache (or the cache dir), so if the user upgrades the app to 0.9.3 or whatever, the cache dir catt-0.9.3 won't be there.

@theychx
Copy link
Collaborator Author

theychx commented Jul 16, 2018

Ah ok, thanks.

@saulrh
Copy link

saulrh commented Jul 17, 2018

It works! Thanks!

@theychx
Copy link
Collaborator Author

theychx commented Jul 19, 2018

@skorokithakis Did you forget about this?

@skorokithakis
Copy link
Owner

No, it's still WIP so I thought you wanted to add something.

@theychx
Copy link
Collaborator Author

theychx commented Jul 19, 2018

Ah, didn't think about that. It's ready for review.

@theychx theychx changed the title [WIP] Group support Group support Jul 19, 2018
@@ -184,25 +189,39 @@ def clear(self):

class Cache(CattStore):
def __init__(self):
cache_path = Path(tempfile.gettempdir(), "catt_cache", "chromecast_hosts")
cache_path = Path(tempfile.gettempdir(), "catt_%s_cache" % CATT_VERSION, "chromecast_hosts")
Copy link
Owner

Choose a reason for hiding this comment

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

Can you sha1 the version here and get the first 8 chars or so? It's not very likely, but I'd like to guard against a version containing slashes like 0.4.3-pre1/amd or whatever.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

fetched = data[min(data, key=str)]
return (fetched["ip"], fetched.get("group_port")) if fetched else (None, None)

def set_data(self, name, ip, port):
Copy link
Owner

Choose a reason for hiding this comment

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

Since we're 3-only now, can you add some types here? It helps with mypy. I'll add pre-commit so this is checked on CI as well.

Copy link
Owner

Choose a reason for hiding this comment

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

Oh we already added pre-commit, I'll see about adding mypy to it. The problem with having tens of projects is that you forget what you did where :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've had to comment out the baseclass set_data method in order to avoid getting this mypy error:

catt/controllers.py:221: error: Signature of "set_data" incompatible with supertype "CattStore"

(adding -> None does not help)
I realize that this might be bad OOP design anyway, so I'd appreciate any suggestions.

Copy link
Owner

Choose a reason for hiding this comment

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

I think this is a mypy bug. I added a type ignore on those lines for now.

theychx added 2 commits July 19, 2018 19:38
..problematic baseclass definition (mypy complains) temp. commented out.
@@ -221,7 +240,7 @@ def __init__(self, state_path, mode):
elif mode == StateMode.ARBI:
self._write_store({})

def get_data(self, name):
def get_data(self, name: str) -> str:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't intend for this to be included in the commit.

Copy link
Owner

Choose a reason for hiding this comment

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

Which do you mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just the change to this line.

@theychx
Copy link
Collaborator Author

theychx commented Jul 19, 2018

The typing module is py3.5+.

@skorokithakis
Copy link
Owner

Arghhhh

@theychx theychx merged commit 9ec5321 into master Jul 20, 2018
@theychx theychx deleted the audio-groups branch July 20, 2018 07:48
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.

Support chromecast audio groups
3 participants