Author: dmeyer
Date: Tue Oct 31 17:43:29 2006
New Revision: 1949
Added:
trunk/beacon/src/server/hwmon/client.py
- copied, changed from r1945, /trunk/beacon/src/server/hwmon/hwmon.py
Removed:
trunk/beacon/src/server/hwmon/hwmon.py
Modified:
trunk/beacon/src/server/__init__.py
trunk/beacon/src/server/crawl.py
trunk/beacon/src/server/hwmon/__init__.py
trunk/beacon/src/server/hwmon/cdrom.py
trunk/beacon/src/server/hwmon/hal.py
trunk/beacon/src/server/hwmon/server.py
trunk/beacon/src/server/monitor.py
trunk/beacon/src/server/parser.py
trunk/beacon/src/server/server.py
trunk/beacon/src/server/thumbnailer.py
trunk/beacon/src/server/videothumb.py
Log:
Make sure every file has a correct GPL header
Modified: trunk/beacon/src/server/__init__.py
==============================================================================
--- trunk/beacon/src/server/__init__.py (original)
+++ trunk/beacon/src/server/__init__.py Tue Oct 31 17:43:29 2006
@@ -1,18 +1,50 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# server/__init__.py - Interface for writing a beacon server
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+
+
def BeaconServer(database):
import server
return server.Server(database)
+
def HardwareMonitorServer():
import hwmon.server
return hwmon.server.Server()
-
+
+
def HardwareMonitorClient():
import hwmon
return hwmon
-
+
+
def Thumbnailer():
import thumbnailer
return thumbnailer.init()
-
-def connect_hardware_monitor():
- import hwmon.server
Modified: trunk/beacon/src/server/crawl.py
==============================================================================
--- trunk/beacon/src/server/crawl.py (original)
+++ trunk/beacon/src/server/crawl.py Tue Oct 31 17:43:29 2006
@@ -5,7 +5,7 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-beacon - A virtual filesystem with metadata
+# kaa.beacon.server - A virtual filesystem with metadata
# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -475,7 +475,7 @@
data = { 'length': 0, 'artist': u'', 'album': u'', 'image': '' }
check_attr = data.keys()[:]
check_attr.remove('length')
-
+
for child in self.db.query(parent=directory):
data['length'] += child._beacon_data.get('length', 0) or 0
for attr in check_attr:
@@ -491,13 +491,13 @@
# or an image directory and we don't want to set the image from
# maybe one item in that directory as our directory image.
data['image'] = None
-
+
if not directory._beacon_data['image_from_items'] and \
directory._beacon_data['image']:
# The directory had an image defined and found by the parser.
# Delete image from data, we don't want to override it.
del data['image']
-
+
for attr in data.keys():
if not data[attr]:
# Set empty string to None
Modified: trunk/beacon/src/server/hwmon/__init__.py
==============================================================================
--- trunk/beacon/src/server/hwmon/__init__.py (original)
+++ trunk/beacon/src/server/hwmon/__init__.py Tue Oct 31 17:43:29 2006
@@ -1,11 +1,47 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# hwmon__init__.py - hardware monitor
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+
+# python imports
import time
import socket
+# kaa imports
import kaa.notifier
-from hwmon import Client as _Client
+# kaa.beacon imports
from kaa.beacon.media import medialist
+# kaa.beacon.server.hwmon imports
+from client import Client as _Client
+
_client = None
def connect():
Modified: trunk/beacon/src/server/hwmon/cdrom.py
==============================================================================
--- trunk/beacon/src/server/hwmon/cdrom.py (original)
+++ trunk/beacon/src/server/hwmon/cdrom.py Tue Oct 31 17:43:29 2006
@@ -1,3 +1,34 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# cdrom.py - CDROM monitor not using HAL
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+
__all__ = [ 'signals', 'Device', 'start', 'eject' ]
import os
@@ -70,7 +101,7 @@
except (OSError, IOError), e:
log.exception('close fd')
-
+
class Device(object):
def __init__(self, prop):
@@ -118,11 +149,11 @@
if self._eject:
eject(self.prop['block.device'])
-
+
def __getattr__(self, attr):
return getattr(self.prop, attr)
-
+
class RomDrive(object):
def __init__(self, device, mountpoint, type, options):
self.device = device
@@ -141,8 +172,8 @@
return
MainThreadCallback(signals['remove'].emit)(self.disc)
self.disc = None
-
-
+
+
@kaa.notifier.execute_in_thread('beacon.cdrom')
def check(self):
log.debug('check drive status %s', self.device)
Copied: trunk/beacon/src/server/hwmon/client.py (from r1945,
/trunk/beacon/src/server/hwmon/hwmon.py)
==============================================================================
--- /trunk/beacon/src/server/hwmon/hwmon.py (original)
+++ trunk/beacon/src/server/hwmon/client.py Tue Oct 31 17:43:29 2006
@@ -1,16 +1,52 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# client.py - client part of the hardware monitor
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# This module is used inside the beacon server to communicate with the
+# hardware monitor process.
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+
+# python imports
import logging
import os
import stat
+# kaa imports
import kaa.rpc
+# kaa.beacon imports
from kaa.beacon.media import medialist
-import kaa.beacon.utils as utils
+from kaa.beacon.utils import get_title
# get logging object
log = logging.getLogger('beacon.hwmon')
-ADD_DISC_SUPPORT = 1
class Client(object):
@@ -27,7 +63,7 @@
medialist.connect(self.db, self)
self.rpc('connect')
self._device_add(rootfs)
-
+
def mount(self, dev):
if hasattr(dev, 'prop'):
@@ -38,11 +74,11 @@
id = dev.get('beacon.id')
return self.rpc('device.mount', id)
-
+
def eject(self, dev):
return self.rpc('device.eject', dev.prop.get('beacon.id'))
-
+
@kaa.rpc.expose('device.add')
def _device_add(self, dev):
# FIXME: check if the device is still valid
@@ -86,7 +122,7 @@
dev['volume.read_only'] = True
self.handler.media_changed(m)
return
-
+
@kaa.rpc.expose('device.remove')
def _device_remove(self, id):
@@ -117,7 +153,7 @@
vid = self.db.add_object("video",
name="",
parent=('media', mid),
-
title=unicode(utils.get_title(metadata['label'])),
+
title=unicode(get_title(metadata['label'])),
media = mid,
beacon_immediately=True)['id']
self.db.commit(force=True)
@@ -152,7 +188,7 @@
media=mid,
mtime=0)
self.db.commit()
-
+
else:
log.info('detect %s as normal filesystem' % id)
mid = self.db.add_object("media", name=id, content='file',
Modified: trunk/beacon/src/server/hwmon/hal.py
==============================================================================
--- trunk/beacon/src/server/hwmon/hal.py (original)
+++ trunk/beacon/src/server/hwmon/hal.py Tue Oct 31 17:43:29 2006
@@ -1,3 +1,34 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# hal.py - dbus/hal based monitor
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+
__all__ = [ 'signals', 'Device', 'start' ]
import sys
@@ -10,7 +41,7 @@
import kaa.metadata
# check for dbus and it's version
-import dbus
+import dbus
if getattr(dbus, 'version', (0,0,0)) < (0,51,0):
raise ImportError('dbus >= 0.51.0 not found')
import dbus.glib
@@ -40,7 +71,7 @@
self.prop = prop
self._eject = False
self._bus = bus
-
+
# -------------------------------------------------------------------------
# Public API
# -------------------------------------------------------------------------
@@ -85,7 +116,7 @@
_device_remove(self.udi)
if self.prop.get('volume.is_disc'):
eject(self.prop['block.device'])
-
+
def __getattr__(self, attr):
return getattr(self.prop, attr)
@@ -163,7 +194,7 @@
hal.connect_to_signal('DeviceAdded', _device_new)
hal.connect_to_signal('DeviceRemoved', _device_remove)
return False
-
+
# -----------------------------------------------------------------------------
# Device handling
@@ -187,7 +218,7 @@
obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device",
reply_handler=kaa.notifier.Callback(_device_add, udi),
error_handler=log.error)
-
+
#lost device
def _device_remove(udi):
@@ -208,7 +239,7 @@
# signal changes
if isinstance(dev.prop.get('info.parent'), dict):
signals['remove'].emit(dev)
-
+
#add new device
def _device_add(prop, udi):
@@ -239,7 +270,7 @@
# it is handled as removable device and we handle
# everything as beacon mountpoint. To avoid problems, the
# user could specify a black list.
-
+
fd = open(os.path.dirname(prop["linux.sysfs_path_device"]) +
'/removable')
rm = fd.read(1)
fd.close()
Modified: trunk/beacon/src/server/hwmon/server.py
==============================================================================
--- trunk/beacon/src/server/hwmon/server.py (original)
+++ trunk/beacon/src/server/hwmon/server.py Tue Oct 31 17:43:29 2006
@@ -1,11 +1,49 @@
-import sys
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# server.py - hardware monitor
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# This module is used inside the beacon server to communicate with the
+# hardware monitor process.
+#
+# -----------------------------------------------------------------------------
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# -----------------------------------------------------------------------------
+# python imports
+import sys
import logging
-import kaa.rpc
+# kaa imports
+import kaa.rpc
import kaa.notifier
import kaa.metadata
+# import the different hardware monitor modules
+# this server is going to use
+
try:
import hal
except ImportError:
@@ -41,13 +79,13 @@
service.signals['remove'].connect(self._device_remove)
service.signals['changed'].connect(self._device_changed)
service.start()
-
+
def _hal_failure(self, reason):
log.error(reason)
if cdrom:
self._start_service(cdrom)
-
+
# -------------------------------------------------------------------------
# Client handling
@@ -62,7 +100,7 @@
# exit when the main server dies
client.signals['closed'].connect(sys.exit)
-
+
# -------------------------------------------------------------------------
# Device handling
# -------------------------------------------------------------------------
@@ -76,13 +114,13 @@
return True
# FIXME: add a nice title
-
+
self.devices[dev.get('beacon.id')] = dev
if not self.rpc:
return True
self.rpc('device.add', dev.prop)
-
-
+
+
def _device_remove(self, dev):
try:
del self.devices[dev.get('beacon.id')]
@@ -93,7 +131,7 @@
return True
self.rpc('device.remove', dev.prop.get('beacon.id'))
-
+
def _device_changed(self, dev, prop):
if not self.rpc:
return True
@@ -136,4 +174,3 @@
if not dev:
return None
dev.eject()
-
Modified: trunk/beacon/src/server/monitor.py
==============================================================================
--- trunk/beacon/src/server/monitor.py (original)
+++ trunk/beacon/src/server/monitor.py Tue Oct 31 17:43:29 2006
@@ -5,7 +5,7 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-beacon - A virtual filesystem with metadata
+# kaa.beacon.server - A virtual filesystem with metadata
# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
Modified: trunk/beacon/src/server/parser.py
==============================================================================
--- trunk/beacon/src/server/parser.py (original)
+++ trunk/beacon/src/server/parser.py Tue Oct 31 17:43:29 2006
@@ -7,7 +7,7 @@
# Note: this file is only imported by the server
#
# -----------------------------------------------------------------------------
-# kaa-beacon - A virtual filesystem with metadata
+# kaa.beacon.server - A virtual filesystem with metadata
# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -140,7 +140,7 @@
metadata = {}
attributes = { 'mtime': mtime, 'image': metadata.get('image') }
-
+
if db.object_types().has_key(metadata.get('media')):
type = metadata['media']
elif item._beacon_isdir:
Modified: trunk/beacon/src/server/server.py
==============================================================================
--- trunk/beacon/src/server/server.py (original)
+++ trunk/beacon/src/server/server.py Tue Oct 31 17:43:29 2006
@@ -5,7 +5,7 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-beacon - A virtual filesystem with metadata
+# kaa.beacon.server - A virtual filesystem with metadata
# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -118,7 +118,7 @@
width = (int, ATTR_SEARCHABLE),
height = (int, ATTR_SEARCHABLE),
comment = (unicode, ATTR_KEYWORDS | ATTR_IGNORE_CASE),
- rotation = (int, ATTR_SIMPLE),
+ rotation = (int, ATTR_SIMPLE),
date = (unicode, ATTR_SEARCHABLE))
# tracks for rom discs or iso files
Modified: trunk/beacon/src/server/thumbnailer.py
==============================================================================
--- trunk/beacon/src/server/thumbnailer.py (original)
+++ trunk/beacon/src/server/thumbnailer.py Tue Oct 31 17:43:29 2006
@@ -1,12 +1,12 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# server.py - Server interface for the thumbnailer
+# thumbnailer.py - Server interface for the thumbnailer
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-thumb - Thumbnailing module
-# Copyright (C) 2005-2006 Dirk Meyer, et al.
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
@@ -75,7 +75,7 @@
self._ipc = kaa.rpc.Server(os.path.join(tmpdir, 'socket'))
self._ipc.signals['client_connected'].connect(self.client_connect)
self._ipc.connect(self)
-
+
# video module
self.videothumb = VideoThumb(self)
@@ -152,7 +152,7 @@
self.notify_client(job)
self._activate(0.01)
return True
-
+
if job.filename.lower().endswith('jpg'):
imagefile = job.imagefile + '.jpg'
if os.path.isfile(imagefile):
@@ -201,7 +201,7 @@
self.notify_client(job)
self._activate(THUMBNAIL_TIMER)
return True
-
+
# broken file
log.info('unable to create thumbnail for %s', job.filename)
self.create_failed(job)
@@ -235,7 +235,7 @@
def init():
global thumbnailer
-
+
# create tmp dir and change directory to it
tmpdir = os.path.join(kaa.TEMP, 'thumb')
if not os.path.isdir(tmpdir):
Modified: trunk/beacon/src/server/videothumb.py
==============================================================================
--- trunk/beacon/src/server/videothumb.py (original)
+++ trunk/beacon/src/server/videothumb.py Tue Oct 31 17:43:29 2006
@@ -11,8 +11,8 @@
# Loosly based on videothumb.py commited to the freevo wiki
#
# -----------------------------------------------------------------------------
-# kaa-thumb - Thumbnailing module
-# Copyright (C) 2005-2006 Dirk Meyer, et al.
+# kaa.beacon.server - A virtual filesystem with metadata
+# Copyright (C) 2006 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
@@ -95,7 +95,7 @@
# not changed, refuse the recreate thumbnail
self._current = None
return self._run()
-
+
try:
mminfo = self._current.metadata
pos = str(int(mminfo.video[0].length / 2.0))
@@ -141,7 +141,7 @@
if os.stat(c)[stat.ST_SIZE] > current_capture[1]:
current_capture = c, os.stat(c)[stat.ST_SIZE]
current_capture = current_capture[0]
-
+
try:
# scale thumbnail
width, height = job.size
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog