Author: dmeyer
Date: Thu Dec 28 10:50:37 2006
New Revision: 2289
Modified:
trunk/beacon/bin/beacon
trunk/beacon/src/server/__init__.py
trunk/beacon/src/server/config.cxml
trunk/beacon/src/server/hwmon/hal.py
trunk/beacon/src/server/hwmon/server.py
Log:
improve removable drive detection
Modified: trunk/beacon/bin/beacon
==============================================================================
--- trunk/beacon/bin/beacon (original)
+++ trunk/beacon/bin/beacon Thu Dec 28 10:50:37 2006
@@ -307,7 +307,7 @@
pid = os.fork()
if not pid:
# hwmon part (import this first because of hal/gtk)
- hwmon = kaa.beacon.server.HardwareMonitorServer()
+ hwmon = kaa.beacon.server.HardwareMonitorServer(os.path.join(database,
"config"))
# thumbnailer part
thumb = kaa.beacon.server.Thumbnailer()
Modified: trunk/beacon/src/server/__init__.py
==============================================================================
--- trunk/beacon/src/server/__init__.py (original)
+++ trunk/beacon/src/server/__init__.py Thu Dec 28 10:50:37 2006
@@ -35,9 +35,9 @@
return server.Server(database)
-def HardwareMonitorServer():
+def HardwareMonitorServer(config):
import hwmon.server
- return hwmon.server.Server()
+ return hwmon.server.Server(config)
def HardwareMonitorClient():
Modified: trunk/beacon/src/server/config.cxml
==============================================================================
--- trunk/beacon/src/server/config.cxml (original)
+++ trunk/beacon/src/server/config.cxml Thu Dec 28 10:50:37 2006
@@ -30,6 +30,14 @@
</var>
</group>
+ <var name="discs" type="str" default="">
+ <desc>
+ List of devices that are not removable discs. This helps beacon to
+ detect removable discs already attached when starting beacon.
+ Example: discs = "/dev/hda /dev/hdb"
+ </desc>
+ </var>
+
<dict name="plugins">
<desc>Dict of plugins to enable (True/False)</desc>
<var default="False">
Modified: trunk/beacon/src/server/hwmon/hal.py
==============================================================================
--- trunk/beacon/src/server/hwmon/hal.py (original)
+++ trunk/beacon/src/server/hwmon/hal.py Thu Dec 28 10:50:37 2006
@@ -49,6 +49,8 @@
# use gtk main loop
kaa.notifier.init('gtk', x11=False)
+# kaa.beacon imports
+from kaa.beacon.server.config import config
from kaa.beacon.utils import fstab
from cdrom import eject
@@ -216,7 +218,7 @@
def _device_new(udi):
obj = _bus.get_object("org.freedesktop.Hal", udi)
obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device",
- reply_handler=kaa.notifier.Callback(_device_add, udi),
+ reply_handler=kaa.notifier.Callback(_device_add, udi,
True),
error_handler=log.error)
@@ -242,7 +244,7 @@
#add new device
-def _device_add(prop, udi):
+def _device_add(prop, udi, removable=False):
# only handle mountable devices
if not 'volume.mount_point' in prop:
if 'linux.sysfs_path' in prop and 'block.device' in prop:
@@ -253,7 +255,16 @@
signals['add'].emit(dev)
return
- if not prop.get('volume.is_disc'):
+ if prop.get('block.device') and config.discs and \
+ prop.get('block.device')[:-1] in config.discs.split(' '):
+ # fixed device set in config
+ return
+
+ if config.discs:
+ # fixed drives are set so this is a removable
+ removable = True
+
+ if not prop.get('volume.is_disc') and not removable:
# no disc, check if the device is removable
try:
@@ -281,7 +292,7 @@
# Error reading info. Either file not found,
linux.sysfs_path_device
# not in prop or no read permissions. So not removable in that
case.
return
- elif prop.get('block.device'):
+ elif prop.get('volume.is_disc') and prop.get('block.device'):
# set nice beacon unique id
try:
prop['volume.uuid'] =
kaa.metadata.cdrom.status(prop.get('block.device'))[1]
Modified: trunk/beacon/src/server/hwmon/server.py
==============================================================================
--- trunk/beacon/src/server/hwmon/server.py (original)
+++ trunk/beacon/src/server/hwmon/server.py Thu Dec 28 10:50:37 2006
@@ -54,13 +54,22 @@
except ImportError:
cdrom = None
+# load server config
+from kaa.beacon.server.config import config
+
# get logging object
log = logging.getLogger('beacon.hwmon')
+
class Server(object):
- def __init__(self):
+ def __init__(self, configfile):
log.info('start hardware monitor')
+
+ # load config
+ config.set_filename(configfile)
+ config.load()
+
self.master = None
self.rpc = None
self.devices = {}
@@ -110,7 +119,10 @@
# FIMXE: make this make unique if possible
dev.prop['beacon.id'] = str(dev.prop.get('volume.uuid'))
else:
- log.error('impossible to find unique string for beacon.id')
+ error = 'impossible to find unique string for beacon.id'
+ if dev.prop.get('block.device'):
+ error = 'unable to mount %s' % dev.prop.get('block.device')
+ log.error(error)
return True
# FIXME: add a nice title
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog