Browse | Submit A New Snippet | Create A Package

 

dreambox_msg.py

Type:
Full Script
Category:
Other
License:
GNU General Public License
Language:
Python
 
Description:
send popup message to TV with enigma based sat receiver, see also ruby section for a script written in ruby

Versions Of This Snippet::

peter bauer
Snippet ID Download Version Date Posted Author Delete
5971.02010-07-30 17:37peter bauer

Download a raw-text version of this code by clicking on "Download Version"

 


Latest Snippet Version: :1.0

#!/usr/bin/python
# written and tested with
# python 2.6.5 on linux
# peter bauer
# peba@inode.at

import os, string, urllib, sys

global dbox_ip
dbox_ip=("192.168.1.2")
command=("ping -c1 ")
param=command + dbox_ip 
str=os.popen(param).read()  #gets a file object

if "error" in str:          #error in ping command
    print ("host " + dbox_ip + " not reachable")
    print "exiting program\n"
    exit ()
else:
    print ("host " + dbox_ip + " is reachable")


class DreamMsg:
    def __init__(self):
        self.message = ""
    def send(self,message):
        http_message="http://" + dbox_ip + "/cgi-bin/message?" + message
        urllib.urlopen(http_message).read()

sender=DreamMsg()

args=sys.argv           #get ARGV
if len(args) == 2:
     mess=sys.argv[1].replace(" ","+")
     sender.send(mess)
else:			#read from tty
     print "Please enter message below and press Return"
     mess = sys.stdin.readline().replace(" ","+").rstrip("\n")
     sender.send(mess)
		

Submit a new version

You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..