How to use the wakeonlan.wol function in wakeonlan

To help you get started, we’ve selected a few wakeonlan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tranquilit / WAPT / waptserver / server.py View on Github external
uuids = request.get_json()['uuids']
        hosts_data = Hosts\
            .select(Hosts.uuid, Hosts.computer_fqdn, Hosts.mac_addresses, Hosts.wapt_status, Hosts.host_info)\
            .where(Hosts.uuid.in_(uuids))\
            .dicts()
        result = []
        for host in hosts_data:
            macs = host['mac_addresses']
            msg = u''
            if macs:
                logger.debug(
                    _('Sending magic wakeonlan packets to {} for machine {}').format(
                        macs,
                        host['computer_fqdn']
                    ))
                wakeonlan.wol.send_magic_packet(*macs)
                for line in host['host_info']['networking']:
                    if 'broadcast' in line:
                        broadcast = line['broadcast']
                        wakeonlan.wol.send_magic_packet(
                            *
                            macs,
                            ip_address='%s' %
                            broadcast)
                result.append(dict(uuid=host['uuid'], computer_fqdn=host['computer_fqdn'], mac_addresses=host['mac_addresses']))
        msg = _(u'Wakeonlan packets sent to {} machines.').format(len(result))
        result = result
        return make_response(result,
                             msg=msg,
                             success=True)
    except Exception as e:
        logger.debug(traceback.format_exc())
github tranquilit / WAPT-archives / waptserver / waptserver.py View on Github external
uuids = request.get_json()['uuids']
        hosts_data = Hosts\
            .select(Hosts.uuid, Hosts.computer_fqdn, Hosts.mac_addresses, Hosts.wapt_status, Hosts.host_info)\
            .where(Hosts.uuid.in_(uuids))\
            .dicts()
        result = []
        for host in hosts_data:
            macs = host['mac_addresses']
            msg = u''
            if macs:
                logger.debug(
                    _('Sending magic wakeonlan packets to {} for machine {}').format(
                        macs,
                        host['computer_fqdn']
                    ))
                wakeonlan.wol.send_magic_packet(*macs)
                for line in host['host_info']['networking']:
                    if 'broadcast' in line:
                        broadcast = line['broadcast']
                        wakeonlan.wol.send_magic_packet(
                            *
                            macs,
                            ip_address='%s' %
                            broadcast)
                result.append(dict(uuid=host['uuid'], computer_fqdn=host['computer_fqdn'], mac_addresses=host['mac_addresses']))
        msg = _(u'Wakeonlan packets sent to {} machines.').format(len(result))
        result = result
        return make_response(result,
                             msg=msg,
                             success=True)
    except Exception as e:
        return make_response_from_exception(e)
github cuckoosandbox / cuckoo / cuckoo / machinery / physical.py View on Github external
def wake_on_lan(self, hostname):
        """Start a machine that's currently shutdown."""
        if hostname in self.fog_machines:
            macaddr, download = self.fog_machines[hostname]
            wakeonlan.wol.send_magic_packet(macaddr)
github kalliope-project / kalliope / kalliope / neurons / wake_on_lan / wake_on_lan.py View on Github external
self.mac_address = kwargs.get('mac_address', None)
        self.broadcast_address = kwargs.get('broadcast_address', '255.255.255.255')
        self.port = kwargs.get('port', 9)

        # check parameters
        if self._is_parameters_ok():
            # convert to unicode for testing
            broadcast_address_unicode = self.broadcast_address.decode('utf-8')
            # check the ip address is a valid one
            ipaddress.ip_address(broadcast_address_unicode)

            logger.debug("Call Wake_on_lan_neuron with parameters: mac_address: %s, broadcast_address: %s, port: %s"
                         % (self.mac_address, self.broadcast_address, self.port))

            # send the magic packet, the mac address format will be check by the lib
            wol.send_magic_packet(self.mac_address, ip_address=self.broadcast_address, port=self.port)
github tranquilit / WAPT / waptserver / server.py View on Github external
.dicts()
        result = []
        for host in hosts_data:
            macs = host['mac_addresses']
            msg = u''
            if macs:
                logger.debug(
                    _('Sending magic wakeonlan packets to {} for machine {}').format(
                        macs,
                        host['computer_fqdn']
                    ))
                wakeonlan.wol.send_magic_packet(*macs)
                for line in host['host_info']['networking']:
                    if 'broadcast' in line:
                        broadcast = line['broadcast']
                        wakeonlan.wol.send_magic_packet(
                            *
                            macs,
                            ip_address='%s' %
                            broadcast)
                result.append(dict(uuid=host['uuid'], computer_fqdn=host['computer_fqdn'], mac_addresses=host['mac_addresses']))
        msg = _(u'Wakeonlan packets sent to {} machines.').format(len(result))
        result = result
        return make_response(result,
                             msg=msg,
                             success=True)
    except Exception as e:
        logger.debug(traceback.format_exc())
        logger.critical('trigger_wakeonlan failed %s' % (repr(e)))
        return make_response_from_exception(e)
github tranquilit / WAPT-archives / waptserver / waptserver.py View on Github external
.dicts()
        result = []
        for host in hosts_data:
            macs = host['mac_addresses']
            msg = u''
            if macs:
                logger.debug(
                    _('Sending magic wakeonlan packets to {} for machine {}').format(
                        macs,
                        host['computer_fqdn']
                    ))
                wakeonlan.wol.send_magic_packet(*macs)
                for line in host['host_info']['networking']:
                    if 'broadcast' in line:
                        broadcast = line['broadcast']
                        wakeonlan.wol.send_magic_packet(
                            *
                            macs,
                            ip_address='%s' %
                            broadcast)
                result.append(dict(uuid=host['uuid'], computer_fqdn=host['computer_fqdn'], mac_addresses=host['mac_addresses']))
        msg = _(u'Wakeonlan packets sent to {} machines.').format(len(result))
        result = result
        return make_response(result,
                             msg=msg,
                             success=True)
    except Exception as e:
        return make_response_from_exception(e)

wakeonlan

A small python module for wake on lan.

MIT
Latest version published 12 months ago

Package Health Score

65 / 100
Full package analysis