/usr/share/pyshared/ControlAula/Utils/Publications.py is in ltsp-controlaula 1.8.0-3.
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 | ##############################################################################
# -*- coding: utf-8 -*-
# Project: ControlAula
# Module: Announce.py
# Purpose: Do the avahi publications.
# Language: Python 2.5
# Date: 29-May-2009.
# Ver: 28-May-2009.
# Author: José L. Redrejo Rodríguez
# Copyright: 2009 - José L. Redrejo Rodríguez <jredrejo @nospam@ debian.org>
#
# ControlAula 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 3 of the License, or
# (at your option) any later version.
# ControlAula is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY 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 ControlAula. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import avahi
import dbus
import logging
class Publications(object):
'''
"""A simple class to publish a network service with zeroconf using
avahi.
'''
def __init__(self, name, port,stype="_controlaula._tcp",text="", domain="", host=""):
'''
Initialize the parameters of the avahi announce
Use always port 3000 for this zeroconf-services announces
'''
self.name = name
self.stype = stype
self.domain = domain
self.host = host
self.port = port
self.text = text
self.online = False
def publish(self):
bus = dbus.SystemBus()
try:
server = dbus.Interface(
bus.get_object(
avahi.DBUS_NAME,
avahi.DBUS_PATH_SERVER),
avahi.DBUS_INTERFACE_SERVER)
g = dbus.Interface(
bus.get_object(avahi.DBUS_NAME,
server.EntryGroupNew()),
avahi.DBUS_INTERFACE_ENTRY_GROUP)
g.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC,dbus.UInt32(0),
self.name, self.stype, self.domain, self.host,
dbus.UInt16(self.port), avahi.string_array_to_txt_array(self.text ))
g.Commit()
self.group = g
except:
logging.getLogger().error('Avahi is not working in this computer, relay on plan B to work')
self.online=True
def unpublish(self):
self.group.Reset()
self.online=False
|