/usr/share/pyshared/freevo/util/lirc.py is in python-freevo 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o644.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | # -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# A module to help with some lirc tasks.
# -----------------------------------------------------------------------
# $Id: lirc.py 11399 2009-04-11 12:36:50Z duncan $
#
# Notes:
# 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 string, os, re
def parse_lircd(conf):
remotes = {}
remote = None
input_codes = 0
try:
lircd = open(conf, 'r')
except:
print 'Unable to open %s.' % conf
return
for line in lircd.readlines():
line = string.strip(line)
if not line or line[0] == '#': continue
data = line.split()
if len(data) < 2: continue
if data[0].lower() == 'begin' and data[1].lower() == 'remote':
remote = LircRemote()
continue
if remote:
if input_codes:
if data[0].lower() == 'end' and data[1].lower() == 'codes':
input_codes = 0
continue
#remote.codes[data[0]] = long(data[1])
remote.codes[data[0]] = data[1]
continue
if data[0].lower() == 'name':
remote.name = data[1]
elif data[0].lower() == 'bits':
remote.bits = int(data[1])
elif data[0].lower() == 'flags':
remote.flags = data[1]
elif data[0].lower() == 'eps':
remote.eps = int(data[1])
elif data[0].lower() == 'aeps':
remote.aeps = int(data[1])
elif data[0].lower() == 'one':
remote.one[0] = int(data[1])
remote.one[1] = int(data[2])
elif data[0].lower() == 'zero':
remote.zero[0] = int(data[1])
remote.zero[1] = int(data[2])
elif data[0].lower() == 'plead':
remote.plead = int(data[1])
elif data[0].lower() == 'gap':
remote.gap = int(data[1])
elif data[0].lower() == 'toggle_bit':
remote.toggle_bit = int(data[1])
elif data[0].lower() == 'begin' and data[1].lower() == 'codes':
input_codes = 1
continue
if data[0].lower() == 'end' and data[1].lower() == 'remote':
remotes[remote.name] = remote
return remotes
def dump_remotes(remotes):
for remote in remotes.values():
print 'Remote: %s' % remote.name
print ' bits: %d' % remote.bits
print ' flags: %s' % remote.flags
print ' eps: %d' % remote.eps
print ' aeps: %d' % remote.aeps
print ' one: %d %d' % (remote.one[0], remote.one[1])
print ' zero: %d %d' % (remote.zero[0], remote.zero[1])
print ' plead: %d' % remote.plead
print ' gap: %d' % remote.gap
print ' toggle_bit: %d' % remote.toggle_bit
print ' Codes:'
for code in remote.codes.keys():
print ' %s: %s' % (code, remote.codes[code])
class LircRemote:
def __init__(self):
self.name = 'undefined'
self.bits = 0
self.flags = None
self.eps = 0
self.aeps = 0
self.one = [0, 0]
self.zero = [0, 0]
self.plead = 0
self.gap = 0
self.toggle_bit = 0
self.codes = {}
# dump_remotes(parse_lircd('/etc/lircd.conf'))
|