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

Initialize headers from config in reset_base_headers() #707

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Mar 21, 2021

WIP: #706

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2021

OK, here's some idea that could work. Don't mind the PR title and body, will update them once the PR comes useful.

So, WDYT, is this acceptable?

'X-Plex-Device': plexapi.X_PLEX_DEVICE,
'X-Plex-Device-Name': plexapi.X_PLEX_DEVICE_NAME,
'X-Plex-Client-Identifier': plexapi.X_PLEX_IDENTIFIER,
'X-Plex-Platform': CONFIG.get('header.platorm', CONFIG.get('header.platform')),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it's about time to drop support for the 'header.platorm' typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was fixed in 2018, matching 3.2.0 version:

@glensc
Copy link
Contributor Author

glensc commented Apr 4, 2021

How about this approach? If needed, I could extract to smaller changes.

@Hellowlol
Copy link
Collaborator

Hellowlol commented Apr 4, 2021

I still don’t see the point. IMO you need to add a example on why this is better. Fix your flake errors, run the test suit locally, including the tests for the client and squash the commits.

I don’t like the name reset_default_headers as isn’t anymore, is the headers is in config file (it was a bad name in the first place) Why is the headers a local variable the class? Why not use it directly?

for section in self._sections:
for name, value in self._sections[section].items():
if name != '__name__':
config[section.lower()][name.lower()] = value
return dict(config)

def _defaults(self):
from uuid import getnode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don’t in-line std libs.

from platform import uname
from plexapi import PROJECT, VERSION

platform_name, device_name, platform_version = uname()[0:3]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix the slicing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explain fix how? fix what? what is wrong with the current code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is the current slicing wrong. how is the correct way?

@glensc
Copy link
Contributor Author

glensc commented Apr 5, 2021

Fix your flake errors, run the test suit locally, including the tests for the client and squash the commits.

I don't see point fixing tests until it's certain this is worth finishing! That's why I asked about the changes, not the style! Also, do note the PR is in a Draft state.

@glensc
Copy link
Contributor Author

glensc commented Apr 5, 2021

I don’t like the name reset_default_headers as isn’t anymore, is the headers is in config file (it was a bad name in the first place)

I used an existing name, please suggest a better name not only complain it's bad.

  • get_base_headers?
  • get_plex_headers?

@glensc
Copy link
Contributor Author

glensc commented Apr 5, 2021

Why is the headers a local variable the class? Why not use it directly?

I think I explained it in an issue this PR is referring to (#706). to make the headers instance-based, not global. so the self._headers is now copied into the instance. is that headers you are referring to?

since Config object may be modified runtime (after __init__) using copy initialized in __init__.py is the original problem.

ps: since Github has no threading in comment mode, submit a review as code comments, so can reply in a thread and resolve disucssions.

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.

2 participants