-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add WoL CLI with convenience features #195
base: master
Are you sure you want to change the base?
Conversation
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 :) |
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