/usr/share/pyshared/freevo/helpers/remote.py is in python-freevo 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #! /usr/bin/python
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# a small tkinter example remote program
# -----------------------------------------------------------------------
# $Id: remote.py 11445 2009-04-28 15:01:44Z duncan $
#
# Notes: very basic layout.
# need ENABLE_NETWORK_REMOTE = 1 in you local_conf.py
# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
import sys
import socket
from optparse import Option, BadOptionError, OptionValueError, OptionParser, IndentedHelpFormatter
import config
def parse_options():
"""
Parse command line options
"""
import version
formatter=IndentedHelpFormatter(indent_increment=2, max_help_position=36, width=100, short_first=0)
parser = OptionParser(conflict_handler='resolve', formatter=formatter, usage="""
A small tkinter example remote program
You need to set ENABLE_NETWORK_REMOTE = 1 in you local_conf.py""", version='%prog ' + version.version)
parser.add_option('--host', default=config.REMOTE_CONTROL_TCP_HOST,
help='The host to control [default:%default]')
parser.add_option('--port', type='int', default=config.REMOTE_CONTROL_TCP_PORT,
help='The port for the host [default:%default]')
return parser.parse_args()
try:
from Tkinter import *
except:
print 'Warning: Tkinter not found. This script won\'t work.'
print
usage()
panels = [
['1', '2', '3'],
['4', '5', '6'],
['7', '8', '9'],
['ENTER', '0', 'EXIT'],
['MENU', 'UP', 'GUIDE'],
['LEFT', 'SELECT', 'RIGHT'],
['DISPLAY', 'DOWN', 'SUBTITLE'],
['CH+', 'VOL+', 'PIP_ONOFF'],
['CH-', 'VOL-', 'PIP_SWAP'],
['PREV_CH', 'MUTE', 'PIP_MOVE'],
['PLAY', 'PAUSE', 'REC'],
['REW', 'STOP', 'FFWD'],
['EJECT', 'SLEEP', 'TV_VCR'],
]
# the big remote. can possibly be embedded in other stuff.
class FreevoRemote(Frame):
def __init__(self, options, args, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.host = options.host
self.port = options.port
# add the power button
Button(self, text='POWER', command=self.PowerClick).pack(expand=YES, fill=BOTH)
#create the frame for panel
bframe = Frame(self)
rcnt = 0
for r in panels:
ccnt = 0
for b in r:
#create the button for each element
btn = Button(bframe, text=b, command=(lambda b=b: self.ButtonClick(b)))
btn.grid(row=rcnt, column=ccnt, sticky=NSEW)
ccnt = ccnt + 1
# add the now complete row to panel
bframe.rowconfigure(rcnt, weight=1)
rcnt = rcnt + 1
bframe.columnconfigure(0, weight=1)
bframe.columnconfigure(1, weight=1)
bframe.columnconfigure(2, weight=1)
#add the panel to self
bframe.pack(side=TOP, expand=YES, fill=BOTH)
def PowerClick(self):
self.ButtonClick('POWER')
self.quit()
def ButtonClick(self, b):
print b
#sockobj = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockobj.connect((self.host, self.port))
sockobj.send(b)
sockobj.close()
if __name__ == '__main__':
(options, args) = parse_options()
root = FreevoRemote(options, args)
root.master.title('Freevo Remote')
root.mainloop()
|