-
Notifications
You must be signed in to change notification settings - Fork 69
Add WoL CLI with convenience features #195
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
base: development
Are you sure you want to change the base?
Conversation
samba2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this one raised? Reviewing on m
y phone so I might be blind😉
|
umm, you only commented on the PR, not a particular line/file, so I can only guess 🤔 |
|
Thank you very much for the pull-request and sorry for the delay. I have not checked the code by a test run so far, but by style. For the argument-parser I suggest to define separate options instead of a single complex one. I skipped the index def wake_host(fh, args):
if args.device_mac_address:
mac = args.device_mac_address
elif args.device_ip_address:
try:
host = fh.get_specific_host_entry_by_ip(args.device_ip_address)
except (FritzArgumentError, FritzLookUpError) as err:
msg = f"Error: unknown IP {args.device_ip_address}"
raise FritzArgumentError(msg)
mac = host['NewMACAddress']
elif args.device_name:
device_name = args.device_name.lower()
for entry in fh.get_generic_host_entries():
if entry['NewHostName'].lower() == device_name:
mac = entry['NewMACAddress']
break
else:
msg = f"Error: unknown device name '{args.device_name}'"
raise FritzArgumentError(msg)
else:
msg = f"Error: missing device specification"
raise FritzArgumentError(msg)
fh.wakeonlan_host(mac)
def add_arguments(parser):
parser.add_argument(
"--device-ip",
dest="device_ip_address",
default=None,
help="ip-address of device to wake up",
)
parser.add_argument(
"--device-mac",
dest="device_mac_address",
default=None,
help="mac-address of device to wake up",
)
parser.add_argument(
"--device-name",
dest="device_name",
default=None,
help="name of device to wake up",
) |
|
Thank you for the detailed feedback, I'll adapt the code towards your suggestions as soon as my schedule allows for :) |
|
I'm very much interested in this. Now I understand the whole dynamic between open source projects and switching priorities and life etc. That being said, is there any chance this could be finished at some point? |
|
So, the anniversary to my last comment is on the horizon, and thanks to @marklagendijk this PR was brought to my attention again. @kbr I do think it would make sense to add the dev dependencies like nox and pytest to the Additionally I grouped the arguments for the CLI tool into a mutex argument group with matching description so the executing logic does not have to check for multiple passed flags. If the short hand flags I chose for the parameters are undesired, let me know and I'll remove them again. Let's get this merged :) |
|
Thank you for caring about this again. Flags for the cli are ok (I dislike a bit the uppercase Regarding |
|
Thank you for the clarification on your perspective, it sounds reasonable 👍 |
As discussed in #148 and preliminarily implemented in #149, I adapted the code from @samba2 according to requested code style changes from @kbr, then refactored and added additional logic to make it easy to wake a host by either MAC, IP, hostname or the ID number of the internal hosts table of the fritz box.
I'm eager to hear your thoughts on this.
Should close #148 and #149