Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Send WOL when no response ping

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
joz
Posts: 1
Joined: Sun Sep 19, 2010 9:44 am

Send WOL when no response ping

Post by joz »

---UPDATE---
Nevermind what I thought up below I have looked a bit further into network receiver/sender and setup a solution dependent on that, seems to do the job well so far I've tested (which is not a lot yet). Did find that when I set a password for the sender/receiver I had an MD5 checksum error (password was 100% correct, both sides), no password works.
--------------



Hi all,

I'm totally unfamiliar with python, so excuse my noobishness :)
What I'm trying to accomplish is the following scenario;
I have a NAS (well, just a desktop) that goes to sleep. I run MediaPortal on my HTPC and it loads stuff of the NAS but ofcourse can't while it's asleep. Now to overcome some issues with MP I would like to be able to ping my NAS when I press play. If I do not get an answer I (in a second or so) I want eventghost to send a wol to the nas first, then wait a couple seconds (I think 10 would be fine) and then fire play to MP.
If it receive a response to the ping it can play immediatly.

I have found some script that pings and looks for the response, seemed like a nice start. Can't get it to go though cause it's chokin' on re.search, no clue why. This does nothing else yet, just trying something first, if I can't get this to go myself it's kinda hopeless :) Might have to dig into python a lot more.
Any help getting there would be awesome!

Code: Select all

import re
from subprocess import Popen, PIPE
from threading import Thread

print 'starting'
class Pinger(object):
    def __init__(self, hosts):
        for host in hosts:
            pa = PingAgent(host)
            pa.start()
        
class PingAgent(Thread):
    def __init__(self, host):
        Thread.__init__(self)        
        self.host = host

    def run(self):
        p = Popen('ping -n 1 ' + self.host, stdout=PIPE)
        m = re.search('Gemiddelde = (.*)ms', p.stdout.read())
        if m: print 'Round Trip Time: %s ms -', p.stdout.read(), self.host
        else: print  'Error: Invalid Response -', self.host
              
                             

hosts = [
    '192.168.1.30'
   ]
Pinger(hosts)
p.s.
I also though about not having the timeout for the NAS to wake but using the network sender/receiver, so the NAS will send an event to the HTPC when it's set to go.
bskchaos
Experienced User
Posts: 56
Joined: Tue Mar 25, 2008 3:04 pm

Re: Send WOL when no response ping

Post by bskchaos »

Interesting.

I created a very simple page and use EG to handle a WOL utility.
I will check your script to leech some ideas.
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: Send WOL when no response ping

Post by miljbee »

I wrote a ping plugin :

You can get it here : http://www.eventghost.org/forum/viewtop ... f=9&t=2318

There is two different version.

I you just plan to ping on demand, I would recommand you to get the first realease.

Just have a look at the readme of the two versions to choose the one you need by yourself.

Regards,
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
Post Reply