#!/usr/bin/env python # This command line tool sends messages to the Entertainer's message bus. # Copyright (C) 2007 Lauri Taimila # # 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 # 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 this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. __licence__ = "GPLv2" __copyright__ = "2007, Lauri Taimila" __author__ = "Lauri Taimila " import sys from backend.core.message import Message from backend.core.message_type_priority import MessageType, MessagePriority from backend.core.message_bus_proxy import MessageBusProxy # Dictionary of the message types message_dict = { "RECORDING_CONFLICT" : MessageType.RECORDING_CONFLICT, "RECORDING_STARTED" : MessageType.RECORDING_STARTED, "RECORDING_STOPPED" : MessageType.RECORDING_STOPPED, "UPDATE_FEEDS" : MessageType.UPDATE_FEEDS, "FEED_DB_UPDATED" : MessageType.FEED_DB_UPDATED, "CONTENT_CONF_UPDATED": MessageType.CONTENT_CONF_UPDATED, "PREFERENCES_CONF_UPDATED" : MessageType.PREFERENCES_CONF_UPDATED, "REBUILD_IMAGE_CACHE": MessageType.REBUILD_IMAGE_CACHE, "REBUILD_MUSIC_CACHE": MessageType.REBUILD_MUSIC_CACHE, "REBUILD_FEED_CACHE": MessageType.REBUILD_FEED_CACHE, "REBUILD_VIDEO_CACHE": MessageType.REBUILD_VIDEO_CACHE } try: argument = (sys.argv[1])[10:] message = Message(message_dict[argument]) except: print """Usage: messagebus-notifier --message=MESSAGE_TYPE 'MESSAGE_TYPE' should be replaced one of the followings: - RECORDING_CONFLICT - RECORDING_STARTED - RECORDING_STOPPED - UPDATE_FEEDS - FEED_DB_UPDATED - CONTENT_CFG_UPDATED - PREFERENCES_CFG_UPDATED - REBUILD_IMAGE_CACHE - REBUILD_MUSIC_CACHE - REBUILD_VIDEO_CACHE - REBUILD_FEED_CACHE """ sys.exit(1) try: proxy = MessageBusProxy(client_name = "Command line message-bus notifier") proxy.connectToMessageBus() proxy.sendMessage(message) proxy.disconnectFromMessageBus() except: print "Backend is not running. Start backend and try again." sys.exit(1)