Code Monkey home page Code Monkey logo

pywakeonlan's Introduction

wakeonlan

Pypi version

Supported Python versions

Build Status

Documentation Status

Code coverage

A small python module for wake on lan.

For more information on the wake on lan protocol please take a look at Wikipedia.

Installation

pip install wakeonlan

Usage

To wake up a computer using wake on lan it must first be enabled in the BIOS settings. Please note the computer you are trying to power on does not have an ip address, but it does have a mac address. The package needs to be sent as a broadcast package.

As a python module

Import the module

>>> from wakeonlan import send_magic_packet

Wake up a single computer by its mac address

>>> send_magic_packet('ff.ff.ff.ff.ff.ff')

Wake up multiple computers by their mac addresses.

>>> send_magic_packet('ff.ff.ff.ff.ff.ff', ... '00-00-00-00-00-00', ... 'FFFFFFFFFFFF')

An external host may be specified. Do note that port forwarding on that host is required. The default ip address is 255.255.255.255 and the default port is 9.

>>> send_magic_packet('ff.ff.ff.ff.ff.ff', ... ip_address='example.com', ... port=1337)

A network adapter may be specified. The magic packet will be routed through this interface.

>>> send_magic_packet('ff.ff.ff.ff.ff.ff', ... interface='192.168.0.2')

As a standalone script

usage: wakeonlan [-h] [-6] [-i IP] [-p PORT] [-n INTERFACE] mac address [mac address ...]

Wake one or more computers using the wake on lan protocol.

positional arguments:
  mac address           The mac addresses of the computers you are trying to wake.

options:
  -h, --help            show this help message and exit
  -6, --ipv6            To indicate if ipv6 should be used by default instead of ipv4. (default: False)
  -i IP, --ip IP        The ip address of the host to send the magic packet to. (default: 255.255.255.255)
  -p PORT, --port PORT  The port of the host to send the magic packet to. (default: 9)
  -n INTERFACE, --interface INTERFACE
                        The ip address of the network adapter to route the magic packet through. (default: None)

Dependencies

  • Python 3.x

License

MIT © Remco Haszing

pywakeonlan's People

Contributors

alimg avatar davidpratt512 avatar fabaff avatar mrtnritter avatar raghur avatar remcohaszing avatar vladislavru avatar xenlo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywakeonlan's Issues

在Python 3.12中发出的报文为DISCARD,不知道为啥

Frame 27999: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) on interface \Device\NPF_{AAC3F4B3-E22F-4E27-BBEA-76D5C23BFC39}, id 0
Ethernet II, Src: Micro-St_9f:24:f4 (d9:bb:c1:9f:24:f4), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Destination: Broadcast (ff:ff:ff:ff:ff:ff)
Source: Micro-St_9f:24:f4 (d9:bb:c1:9f:24:f4)
Type: IPv4 (0x0900)
Internet Protocol Version 4, Src: 192.168.255.10, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 54238, Dst Port: 9
Discard Protocol
Data: ffffffffffffd9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4d9bbc19f24f4
[Reported Length: 102]

不知道是不是版本的原因

from mock

Beginner programmer here.This is such a great code! I am having one issue and I am not sure why it started happening. Once I ran the set up and started the test_wakeonlan it would stop at mock.

So originally when I got the code to run just running running setup and creating a pytest.py file. It stopped on me all of the sudden not sure why. Any Ideas or certain order I am supposed to run this? Again I am a beginner starting with python I understand it but I do not know how to write many programs.

Thanks!

Permissions issue on Raspberry Pi OS

Trying to utilize a Raspberry Pi 4 as a wake on lan hub for other devices on my network. The following script works via Windows and via Ubuntu Server 18.04 but not via Raspian Buster.

from wakeonlan import send_magic_packet;

def wakeup():
    send_magic_packet('_MAC_', ip_address='_subnet_.255', port=9)

if __name__ == "__main__":
    wakeup()

When used on Raspbian, a permissions error occurs:

Traceback (most recent call last):
  File "foo.py", line 7, in <module>
    wakeup()
  File "foo.py", line 4, in wakeup
    send_magic_packet('_MAC_', ip_address='_subnet_.255', port=9)
  File "/usr/local/lib/python3.7/dist-packages/wakeonlan.py", line 58, in send_magic_packet
    sock.send(packet)
PermissionError: [Errno 1] Operation not permitted

As you can see this is running via Python 3, I have tried running the script with sudo with the same results. Running it through an elevated Python 3 shell produces no error but also no result.

I am not sure how to resolve since it works on Ubuntu Server and Windows. Any advice would be appreciated.

IPv6 usage is confusing

At an ipv6-only host I get only that

rpi:~ # wakeonlan -6 1C:6F:65:C9:87:46
Traceback (most recent call last):
  File "/root/.local/bin/wakeonlan", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/share/pipx/venvs/wakeonlan/lib64/python3.11/site-packages/wakeonlan/__init__.py", line 127, in main
    send_magic_packet(
  File "/root/.local/share/pipx/venvs/wakeonlan/lib64/python3.11/site-packages/wakeonlan/__init__.py", line 74, in send_magic_packet
    sock.connect((ip_address, port))
OSError: address family mismatched
rpi:~ # 

without -6 option it also doesn't work:

rpi:~ # wakeonlan  1C:6F:65:C9:87:46
Traceback (most recent call last):
  File "/root/.local/bin/wakeonlan", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/share/pipx/venvs/wakeonlan/lib64/python3.11/site-packages/wakeonlan/__init__.py", line 127, in main
    send_magic_packet(
  File "/root/.local/share/pipx/venvs/wakeonlan/lib64/python3.11/site-packages/wakeonlan/__init__.py", line 74, in send_magic_packet
    sock.connect((ip_address, port))
OSError: [Errno 101] Network is unreachable
rpi:~ # 

Python 3

I am installing in on my pi and it seems to install only in my library for pyton 2.7, how can i force it to use it in python 3 (unfortunately i have to use python 3)

Thank you

Not working on windows 10

The script (and underlaying program) doesn't seem to be working on windows 10, any info on that?

It does detect wrong entered MAC details, but after execution the PC doesn't start.

It doesn't seem to be a local problem, other WOL utility's seem to work fine.
Also it doesn't seem to be a script problem, running the program using other utility's (ex. home assistant) doesn't seem to work either.

Modernize setup

I would like to modernize the setup for this package.

  • Drop Python 2 support
  • Remove Python 2 specific syntax
  • Use poetry
  • Use black
  • Use GitHub actions

Add missing typed marker

When running mypy on my code that I have now have type hinted I get the following
image
Can this be added to fix this error please?

OSError: [Errno 49] Can't assign requested address

I tried the send_magic_packet and it worked for a couple of attempts. After which I keep getting OSError.

from wakeonlan import send_magic_packet
send_magic_packet('01:2E:45:67:89:10')  # dummy mac address

Traceback below:

Traceback (most recent call last):
  File "/controls.py", line 139, in <module>
    send_magic_packet(os.getenv('tv_mac'))
  File "/venv/lib/python3.8/site-packages/wakeonlan.py", line 81, in send_magic_packet
    sock.send(packet)
OSError: [Errno 49] Can't assign requested address

Push a new version to pypi

106af61 is quite a sever issue causing some of my devices to not react to magic packets as they reject invalid formats.

As big projects such as home-assistant depend on it, I'd really appreciate a new version being pushed to pypi.

Stopped working, what have I broken?

Windows 10
Using this app from the Microsoft Store, I can start my computer - https://www.microsoft.com/store/productId/9NBLGGH51PB3
Running this with the exact same mac address does not:
image
Same with an actual python file
image

It was working before but stopped around 29th May, I cannot think of anything I changed to affect it.
Neither can I see any new releases here, so I guess it is me but the computer is surely set correctly as the other thing works and I can't see anything wrong with the code.

Help would be appreciated. Ask if I've missed something.

Edit: Changed semi-colons ":" to full stops "." in MAC address because I realised it had those in the readme. Still nothing though.
E.g. ff:ff:ff:ff:ff:ff -> ff.ff.ff.ff.ff.ff

Add LICENSE to tarball on PyPi

For packaging it would be useful if the package file is included in the tarball on PyPi. Please consider doing this for future releases.

No module named 'wakeonlan'

My issue is simple:
I'm trying to run some code I wrote in python with flask.

When I run it, it gives me the following error:
ModuleNotFoundError: No module named 'wakeonlan'

Now you might be thinking I just forgot to install wakeonlan, but that's the thing: I didn't. wakeonlan is installed and running wakeonlan --version does result in it telling me what version of wakeonlan have installed.

I'm running this on a raspberry pi 4 using Raspberry Pi OS 64bit if that makes any difference.

I'm new to python, flask, linux and pi so I'msorry if this is a real easy fix. I am noob.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.