Author: dmeyer
Date: Sat Mar 25 18:08:21 2006
New Revision: 1337
Added:
trunk/beacon/bin/beacon
- copied, changed from r1336, /trunk/beacon/bin/kaa-vfs
Removed:
trunk/beacon/bin/kaa-vfs
Modified:
trunk/beacon/README
trunk/beacon/setup.py
trunk/beacon/src/__init__.py
trunk/beacon/src/cdrom.py
trunk/beacon/src/client.py
trunk/beacon/src/db.py
trunk/beacon/src/directory.py
trunk/beacon/src/file.py
trunk/beacon/src/item.py
trunk/beacon/src/monitor.py
trunk/beacon/src/parser.py
trunk/beacon/src/query.py
trunk/beacon/src/server.py
Log:
rename *vfs* to *beacon*
Modified: trunk/beacon/README
==============================================================================
--- trunk/beacon/README (original)
+++ trunk/beacon/README Sat Mar 25 18:08:21 2006
@@ -1,8 +1,8 @@
-Small API doc for kaa.vfs. Some parts are still missing but everything
+Small API doc for kaa.beacon. Some parts are still missing but everything
written here should work. The variable / function names may change in
the future.
-DO NOT ACCESS ANY MEMBER FUNCTIONS OR VARIABLES STARTING WIRH _vfs!!!
+DO NOT ACCESS ANY MEMBER FUNCTIONS OR VARIABLES STARTING WIRH _beacon!!!
They are for internal use only and you can do stuff with the db you
should not be able to do.
@@ -12,7 +12,7 @@
You can use the monitor stuff (I will explain later) or you can use
the cache test app to fill the database. Open cache.py in the test dir
and change the db path to the localtion of your database
-(e.g. /var/lib/freevo/vfsdb). After that call python cache.py with a
+(e.g. /var/lib/freevo/beacondb). After that call python cache.py with a
directory as argument. The test app will recursive add the files to
the database.
@@ -24,20 +24,20 @@
Query object in return. Besides some monitoring stuff, the class has
an interator to walk through the list of results:
-| kaa.vfs.connect('/var/lib/freevo/vfsdb')
-| directory = kaa.vfs.get('/home/mp3')
+| kaa.beacon.connect('/var/lib/freevo/beacondb')
+| directory = kaa.beacon.get('/home/mp3')
| listing = directory.listdir()
| for item in listing:
| print item
Item is an object of the type Item (or higher classes like File or
Directory. You will be able to change that in later versions of
-kaa.vfs to your own classes). Directory object have a 'listdir()'
+kaa.beacon to your own classes). Directory object have a 'listdir()'
again (other types will also have a list in the future). You can
access the attributes from the database with the memeber function
'getattr()'. A File/Directory also has attributes 'url', 'filename'
and 'isdir'. To get a list of all possible attributes call 'keys()'.
-Using the attribute 'thumbnail' will return a kaa.thumb2 object for
+Using the attribute 'thumbnail' will return a Thumbnail object for
that item you can use to get/set/create thumbnails. The thumbnail
object has (besides other things) a member variable 'image' returning
the thumbnail filename with the highest resolution or None if no
@@ -64,4 +64,4 @@
-More about kaa.vfs and kaa.thumb2 later
+More about kaa.beacon later
Copied: trunk/beacon/bin/beacon (from r1336, /trunk/beacon/bin/kaa-vfs)
==============================================================================
--- /trunk/beacon/bin/kaa-vfs (original)
+++ trunk/beacon/bin/beacon Sat Mar 25 18:08:21 2006
@@ -18,9 +18,9 @@
log = logging.getLogger()
def usage(error_code):
- print 'kaa-vfs [options]'
- print '--start start vfs daemon'
- print '--stop stop running vfs daemon'
+ print 'beacon [options]'
+ print '--start start beacon'
+ print '--stop stop running beacon'
print '--daemon detach for parent process'
print '--autoshutdown stop server when no clients are connected'
print '--logfile file use file for logging'
@@ -67,12 +67,12 @@
usage(0)
if mode == 'stop':
- # stop a running vfs server
+ # stop a running beacon
import kaa.ipc
try:
- kaa.ipc.IPCClient('vfs').get_object('shutdown')()
+ kaa.ipc.IPCClient('beacon').get_object('shutdown')()
except kaa.ipc.IPCDisconnectedError:
pass
except:
@@ -80,7 +80,7 @@
sys.exit(0)
-# When we reach this point we need to start a new vfs server. If run
+# When we reach this point we need to start a new beacon server. If run
# in daemon mode we fork and detach from the parent. After that a logger
# is created and the thumbnail server will be forked out.
@@ -110,7 +110,7 @@
import kaa
import kaa.notifier
- import kaa.vfs.thumbnail.server
+ import kaa.beacon.thumbnail.server
# create tmp dir and change directory to it
tmpdir = os.path.join(kaa.TEMP, 'thumb')
@@ -120,7 +120,7 @@
# create thumbnailer object
try:
- thumbnailer = kaa.vfs.thumbnail.server.Thumbnailer(tmpdir)
+ thumbnailer = kaa.beacon.thumbnail.server.Thumbnailer(tmpdir)
except IOError, e:
log.error('thumbnail: %s' % e)
time.sleep(0.1)
@@ -133,13 +133,13 @@
-# vfs server
+# beacon server
import kaa
import kaa.notifier
import kaa.ipc
-import kaa.vfs.server
-import kaa.vfs.thumbnail.thumbnail
+import kaa.beacon.server
+import kaa.beacon.thumbnail.thumbnail
def garbage_collect():
g = gc.collect()
@@ -154,29 +154,29 @@
# connect thumbnailer
log.info('connect to thumbnailer')
-kaa.vfs.thumbnail.thumbnail.connect()
+kaa.beacon.thumbnail.thumbnail.connect()
try:
- ipc = kaa.ipc.IPCServer('vfs')
+ ipc = kaa.ipc.IPCServer('beacon')
except IOError, e:
- kaa.vfs.thumbnail.thumbnail.disconnect()
- log.error('vfs: %s' % e)
+ kaa.beacon.thumbnail.thumbnail.disconnect()
+ log.error('beacon: %s' % e)
time.sleep(0.1)
sys.exit(0)
-log.info('start vfs server')
-ipc.register_object(kaa.vfs.server.connect, 'vfs')
+log.info('start beacon')
+ipc.register_object(kaa.beacon.server.connect, 'beacon')
ipc.register_object(kaa.notifier.shutdown, 'shutdown')
-ipc.signals["client_closed"].connect(kaa.vfs.server._client_closed)
+ipc.signals["client_closed"].connect(kaa.beacon.server._client_closed)
# start garbage collector
kaa.notifier.Timer(garbage_collect).start(10)
if shutdown:
log.info('set autoshutdown timer to 3 seconds')
- kaa.vfs.server.autoshutdown(3)
+ kaa.beacon.server.autoshutdown(3)
kaa.notifier.loop()
-log.info('stop vfs server')
+log.info('stop beacon')
try:
os.kill(pid, 15)
except OSError:
Modified: trunk/beacon/setup.py
==============================================================================
--- trunk/beacon/setup.py (original)
+++ trunk/beacon/setup.py Sat Mar 25 18:08:21 2006
@@ -1,18 +1,18 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# setup.py - Setup script for kaa.vfs
+# setup.py - Setup script for kaa.beacon
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - Media VFS
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Jason Tackaberry, Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
# Jason Tackaberry <[EMAIL PROTECTED]>
-# Maintainer: The Kaa team
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
-# Please see the file doc/CREDITS for a complete list of authors.
+# 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
@@ -40,7 +40,7 @@
print 'kaa.base not installed'
sys.exit(1)
-ext = Extension("kaa.vfs.thumbnail.libthumb",
+ext = Extension("kaa.beacon.thumbnail.libthumb",
["src/thumbnail/thumbnail.c", "src/thumbnail/png.c" ],
config='src/thumbnail/config.h')
@@ -59,9 +59,9 @@
else:
print 'epeg extention disabled'
-setup (module = 'vfs',
+setup (module = 'beacon',
version = '0.1',
- description = "Media-oriented VFS",
- scripts = [ 'bin/kaa-thumb', 'bin/kaa-vfs' ],
+ description = "Media-oriented virtual filesystem",
+ scripts = [ 'bin/kaa-thumb', 'bin/kaa-beacon' ],
ext_modules = [ ext ]
)
Modified: trunk/beacon/src/__init__.py
==============================================================================
--- trunk/beacon/src/__init__.py (original)
+++ trunk/beacon/src/__init__.py Sat Mar 25 18:08:21 2006
@@ -1,11 +1,11 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# __init__.py - interface to kaa.vfs
+# __init__.py - interface to kaa.beacon
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -40,15 +40,15 @@
from thumbnail import Thumbnail, NORMAL, LARGE
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
# connected client object
_client = None
-def connect(vfsdb=None):
+def connect(database=None):
"""
- Connect to the vfs database dir given by 'vfsdb'. Id 'vfsdb' is None, the
- client will only connect to the thumbnailer. A kaa-vfs program must be
running.
+ Connect to the beacon database dir given by 'database'. Id 'database' is
None, the
+ client will only connect to the thumbnailer. A kaa-beacon program must be
running.
"""
global _client
@@ -58,11 +58,11 @@
log.info('connect to thumbnailer')
thumbnail.connect()
- if not vfsdb:
+ if not database:
return None
- log.info('connect to %s' % vfsdb)
- _client = Client(vfsdb)
+ log.info('connect to %s' % database)
+ _client = Client(database)
return _client
@@ -71,7 +71,7 @@
Get object for the given filename.
"""
if not _client:
- raise RuntimeError('vfs not connected')
+ raise RuntimeError('beacon not connected')
return _client.get(filename)
@@ -80,5 +80,5 @@
Query the database.
"""
if not _client:
- raise RuntimeError('vfs not connected')
+ raise RuntimeError('beacon not connected')
return _client.query(**args)
Modified: trunk/beacon/src/cdrom.py
==============================================================================
--- trunk/beacon/src/cdrom.py (original)
+++ trunk/beacon/src/cdrom.py Sat Mar 25 18:08:21 2006
@@ -35,7 +35,7 @@
from kaa.metadata.disc.discinfo import cdrom_disc_id
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
def ioctl(fd, code, *args, **kargs):
if code > sys.maxint:
@@ -56,7 +56,7 @@
def check(self):
tcb = ThreadCallback(self.check_thread)
tcb.signals['exception'].connect(log.error)
- tcb.register('vfs.cdrom')
+ tcb.register('beacon.cdrom')
def check_thread(self):
@@ -114,7 +114,7 @@
tcb = ThreadCallback(kaa.metadata.parse, self.device)
tcb.signals['exception'].connect(log.error)
tcb.signals['completed'].connect(self.scan_result)
- tcb.register('vfs.cdrom')
+ tcb.register('beacon.cdrom')
def scan_result(self, metadata):
@@ -123,7 +123,7 @@
log.info('detected %s with tracks', type)
type_list = self.db.object_types['track_%s' % type]
disc = self.db.add_object("media", name=metadata.id, content=type,
- vfs_immediately = True)
+ beacon_immediately = True)
parent = ('media', disc['id'])
for pos, track in enumerate(metadata.tracks):
self.db.add_object('track_%s' % type, name = str(pos), parent
= parent,
Modified: trunk/beacon/src/client.py
==============================================================================
--- trunk/beacon/src/client.py (original)
+++ trunk/beacon/src/client.py Sat Mar 25 18:08:21 2006
@@ -1,17 +1,17 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# client.py - Client interface for the VFS
+# client.py - Client interface for Beacon
# -----------------------------------------------------------------------------
# $Id$
#
-# This is the client interface to the vfs. The server needs to be running.
+# This is the client interface to beacon. The server needs to be running.
# To use the server a Client object must be created. Once created, it is
# possible to start a query on the client.
#
# TODO: make it possible to update an item that is not in the database.
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -46,28 +46,28 @@
from kaa.weakref import weakref
from kaa.notifier import OneShotTimer
-# kaa.vfs imports
+# kaa.beacon imports
from db import Database
from query import Query
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
class Client(object):
"""
- VFS Client. This client uses the db read only and needs a server on
+ Beacon client. This client uses the db read only and needs a server on
the same machine doing the file scanning and changing of the db.
"""
def __init__(self, db):
db = os.path.abspath(db)
# monitor function from the server to start a new monitor for a query
- self._server = ipc.IPCClient('vfs').get_object('vfs')(db)
+ self._server = ipc.IPCClient('beacon').get_object('beacon')(db)
self._server_monitor = self._server.monitor
# read only version of the database
self.database = Database(db, self)
# connect to server notifications
- self.id = self._server.connect(self, self._vfs_notify)
+ self.id = self._server.connect(self, self._beacon_notify)
# internal list of active queries
self._queries = []
# internal list of items to update
@@ -102,12 +102,12 @@
if status:
q = copy.copy(query._query)
if 'parent' in q:
- q['parent'] = q['parent']._vfs_id
+ q['parent'] = q['parent']._beacon_id
self._server_monitor(self.id, query.id, q,
__ipc_noproxy_args=True, __ipc_oneway=True)
- def _vfs_request(self, filename):
+ def _beacon_request(self, filename):
"""
Request information about a filename.
"""
@@ -115,7 +115,7 @@
__ipc_noproxy_args=True)
- def _vfs_notify(self, id, msg, *args, **kwargs):
+ def _beacon_notify(self, id, msg, *args, **kwargs):
"""
Internal notification callback from the server. The Monitor does not
has a reference to the Query because this would result in circular
@@ -124,8 +124,8 @@
"""
for query in self._queries:
if query and query.id == id:
- if hasattr(query, '_vfs_%s' % msg):
- getattr(query, '_vfs_%s' % msg)(*args, **kwargs)
+ if hasattr(query, '_beacon_%s' % msg):
+ getattr(query, '_beacon_%s' % msg)(*args, **kwargs)
return
log.error('Error: unknown message from server: %s' % msg)
@@ -145,13 +145,13 @@
# do the update now
items = []
for i in self._changed:
- id = i._vfs_id
+ id = i._beacon_id
if not id:
# TODO: How to update an item not in the db? Right now we
# can't do that and will drop the item.
continue
- items.append((id, i._vfs_changes))
- i._vfs_changes = {}
+ items.append((id, i._beacon_changes))
+ i._beacon_changes = {}
self._changed = []
self._server.update(items, __ipc_oneway=True,
__ipc_noproxy_args=True)
return
@@ -166,7 +166,7 @@
"""
Convert object to string (usefull for debugging)
"""
- return '<vfs.Client>'
+ return '<beacon.Client>'
def __del__(self):
Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py (original)
+++ trunk/beacon/src/db.py Sat Mar 25 18:08:21 2006
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# db.py - Database for the VFS
+# db.py - Beacon database
# -----------------------------------------------------------------------------
# $Id$
#
@@ -9,7 +9,7 @@
# o Support tracks and other non file based items
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -45,7 +45,7 @@
from kaa.db import *
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
MAX_BUFFER_CHANGES = 20
@@ -64,12 +64,12 @@
# functions to it. But we need different kinds of classes for client
# and server because the client needs to use ipc for the mounting.
- def __init__(self, device, directory, vfsdir, db, client):
+ def __init__(self, device, directory, beacon_dir, db, client):
self.device = device
self.directory = directory
self.name = None
self.id = None
- self.vfsdir = vfsdir
+ self.beacon_dir = beacon_dir
self.db = db
self.overlay = ''
self.url = ''
@@ -106,7 +106,7 @@
if media:
self.url = media['content'] + '//' + self.directory
if name:
- self.overlay = os.path.join(self.vfsdir, name)
+ self.overlay = os.path.join(self.beacon_dir, name)
if not os.path.isdir(self.overlay):
os.mkdir(self.overlay)
else:
@@ -139,7 +139,7 @@
"""
Convert object to string (usefull for debugging)
"""
- return '<vfs.Mountpoint for %s>' % self.directory
+ return '<beacon.Mountpoint for %s>' % self.directory
def __del__(self):
@@ -156,7 +156,7 @@
Init function
"""
# internal db dir, it contains the real db and the
- # overlay dir for the vfs
+ # overlay dir for the beacon
self.dbdir = dbdir
# remeber client
@@ -252,15 +252,15 @@
parent = self._get_dir(os.path.dirname(dirname), media)
name = os.path.basename(dirname)
- if not parent._vfs_id:
+ if not parent._beacon_id:
return create_dir(name, parent)
- current = self._db.query(type="dir", name=name, parent=parent._vfs_id)
+ current = self._db.query(type="dir", name=name,
parent=parent._beacon_id)
if not current and self.client:
return create_dir(name, parent)
if not current:
- current = self._db.add_object("dir", name=name,
parent=parent._vfs_id)
+ current = self._db.add_object("dir", name=name,
parent=parent._beacon_id)
self._db.commit()
else:
current = current[0]
@@ -302,9 +302,9 @@
commit is called just after this function is called.
"""
log.debug('DELETE %s' % entry)
- for child in self._db.query(parent = entry._vfs_id):
+ for child in self._db.query(parent = entry._beacon_id):
self._delete(child)
- self._db.delete_object((entry._vfs_id))
+ self._db.delete_object((entry._beacon_id))
def _query_dir(self, parent):
@@ -314,14 +314,14 @@
"""
dirname = parent.filename[:-1]
items = []
- for i in self._db.query(parent = parent._vfs_id):
+ for i in self._db.query(parent = parent._beacon_id):
if i['type'] == 'dir':
items.append(create_dir(i, parent))
else:
items.append(create_file(i, parent))
# sort items based on url. The listdir is also sorted, that makes
# checking much faster
- items.sort(lambda x,y: cmp(x._vfs_name, y._vfs_name))
+ items.sort(lambda x,y: cmp(x._beacon_name, y._beacon_name))
# TODO: this could block for cdrom drives and network filesystems.
Maybe
# put the listdir in a thread
@@ -331,7 +331,7 @@
# user can turn the feature off.
pos = -1
- for pos, (f, overlay) in enumerate(parent._vfs_listdir()):
+ for pos, (f, overlay) in enumerate(parent._beacon_listdir()):
if pos == len(items):
# new file at the end
if os.path.isdir(parent.filename + f):
@@ -340,7 +340,7 @@
continue
items.append(create_file(f, parent, overlay))
continue
- while f > items[pos]._vfs_name:
+ while f > items[pos]._beacon_name:
# file deleted
i = items[pos]
items.remove(i)
@@ -350,7 +350,7 @@
# list. It will be deleted right before the next commit.
self.changes.append((self._delete, i, [], {}))
# delete
- if f == items[pos]._vfs_name:
+ if f == items[pos]._beacon_name:
# same file
continue
# new file
@@ -386,9 +386,9 @@
if dirname.startswith(m.directory):
break
parent = self._get_dir(dirname, m)
- if parent._vfs_id:
+ if parent._beacon_id:
# parent is a valid db item, query
- e = self._db.query(parent=parent._vfs_id, name=basename)
+ e = self._db.query(parent=parent._beacon_id, name=basename)
if e:
# entry is in the db
basename = e[0]
@@ -424,7 +424,7 @@
if i['type'] == 'dir':
# it is a directory, make a dir item
return create_dir(i, parent)
- if parent._vfs_isdir:
+ if parent._beacon_isdir:
# parent is dir, this item is not
return create_file(i, parent)
# neither dir nor file, something else
@@ -435,7 +435,7 @@
"""
Return all items for the given parent object.
"""
- if parent._vfs_isdir:
+ if parent._beacon_isdir:
return self._query_dir(parent)
raise AttributeError('oops, fix me')
@@ -491,7 +491,7 @@
if r['type'] == 'dir':
# it is a directory, make a dir item
result.append(create_dir(r, parent))
- elif parent._vfs_isdir:
+ elif parent._beacon_isdir:
# parent is dir, this item is not
result.append(create_file(r, parent))
else:
@@ -515,7 +515,7 @@
def add_object(self, type, *args, **kwargs):
"""
- Add an object to the db. If the keyword 'vfs_immediately' is set, the
+ Add an object to the db. If the keyword 'beacon_immediately' is set,
the
object will be added now and the db will be locked until the next
commit.
To avoid locking, do not se the keyword, but this means that a requery
on
the object won't find it before the next commit.
@@ -528,10 +528,10 @@
kwargs[key] = metadata[key]
del kwargs['metadata']
- if 'vfs_immediately' in kwargs:
+ if 'beacon_immediately' in kwargs:
if len(self.changes):
self.commit()
- del kwargs['vfs_immediately']
+ del kwargs['beacon_immediately']
return self._db.add_object(type, *args, **kwargs)
self.changes.append((self._db.add_object, type, args, kwargs))
@@ -541,7 +541,7 @@
def update_object(self, (type, id), *args, **kwargs):
"""
- Update an object to the db. If the keyword 'vfs_immediately' is set,
the
+ Update an object to the db. If the keyword 'beacon_immediately' is
set, the
object will be updated now and the db will be locked until the next
commit.
To avoid locking, do not se the keyword, but this means that a requery
on
the object will return the old values.
@@ -554,10 +554,10 @@
kwargs[key] = metadata[key]
del kwargs['metadata']
- if 'vfs_immediately' in kwargs:
+ if 'beacon_immediately' in kwargs:
if len(self.changes):
self.commit()
- del kwargs['vfs_immediately']
+ del kwargs['beacon_immediately']
return self._db.update_object((type, id), *args, **kwargs)
self.changes.append((self._db.update_object, (type, id), args, kwargs))
Modified: trunk/beacon/src/directory.py
==============================================================================
--- trunk/beacon/src/directory.py (original)
+++ trunk/beacon/src/directory.py Sat Mar 25 18:08:21 2006
@@ -1,11 +1,11 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# directory.py - Directory item of the VFS
+# directory.py - Beacon directory item
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -34,11 +34,11 @@
import stat
import logging
-# kaa.vfs imports
+# kaa.beacon imports
from item import Item
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
UNKNOWN = -1
@@ -54,7 +54,7 @@
setattr: function to set an attribute
keys: function to return all known attributes of the item
- Do not access attributes starting with _vfs outside kaa.vfs
+ Do not access attributes starting with _beacon outside kaa.beacon
"""
def __init__(self, data, parent):
# Notes: filename end with '/'
@@ -63,13 +63,13 @@
id = None
self.filename = parent.filename + data + '/'
data = { 'name': data, 'mtime': UNKNOWN }
- if parent and parent._vfs_id:
- data['parent_type'], data['parent_id'] = parent._vfs_id
- media = parent._vfs_media
+ if parent and parent._beacon_id:
+ data['parent_type'], data['parent_id'] = parent._beacon_id
+ media = parent._beacon_media
elif isinstance(parent, Directory):
# db data
id = (data['type'], data['id'])
- media = parent._vfs_media
+ media = parent._beacon_media
self.filename = parent.filename + data['name'] + '/'
else:
# root directory
@@ -79,32 +79,32 @@
self.filename = media.directory
Item.__init__(self, id, 'file://' + self.filename, data, parent, media)
- self._vfs_overlay = False
- self._vfs_isdir = True
- self._vfs_ovdir = media.overlay + '/' +
self.filename[len(media.directory):]
+ self._beacon_overlay = False
+ self._beacon_isdir = True
+ self._beacon_ovdir = media.overlay + '/' +
self.filename[len(media.directory):]
- def _vfs_mtime(self):
+ def _beacon_mtime(self):
"""
Return modification time of the item itself.
The modification time of a directory is the max value of the mtime from
the directory itself and the overlay directory (if that exists).
"""
- if os.path.isdir(self._vfs_ovdir):
- return max(os.stat(self._vfs_ovdir)[stat.ST_MTIME],
+ if os.path.isdir(self._beacon_ovdir):
+ return max(os.stat(self._beacon_ovdir)[stat.ST_MTIME],
os.stat(self.filename)[stat.ST_MTIME])
return os.stat(self.filename)[stat.ST_MTIME]
- def _vfs_request(self):
+ def _beacon_request(self):
"""
Request the item to be scanned.
"""
-
self._vfs_database_update(self._vfs_db()._vfs_request(self.filename[:-1]))
+
self._beacon_database_update(self._beacon_db()._beacon_request(self.filename[:-1]))
- def _vfs_listdir(self):
+ def _beacon_listdir(self):
"""
Internal function to list all files in the directory and the overlay
directory. The result is a list of tuples. The first item is the
@@ -117,7 +117,7 @@
return []
try:
- result = [ ( x, True ) for x in os.listdir(self._vfs_ovdir) \
+ result = [ ( x, True ) for x in os.listdir(self._beacon_ovdir) \
if not x.startswith('.') and not x in listdir ]
except OSError:
result = []
@@ -126,15 +126,15 @@
return result
- def _vfs_os_listdir(self):
+ def _beacon_os_listdir(self):
"""
Internal function to list all files in the directory and the overlay
directory. The result is a list of complete filenames. The function
will use an internal cache.
FIXME: This is an ugly solution.
"""
- if hasattr(self, '_vfs_os_listdir_cache'):
- return self._vfs_os_listdir_cache
+ if hasattr(self, '_beacon_os_listdir_cache'):
+ return self._beacon_os_listdir_cache
try:
result = [ (x, self.filename + x) for x in
os.listdir(self.filename)
@@ -143,11 +143,11 @@
return []
try:
- result += [ ( x, self._vfs_ovdir + x ) for x in
os.listdir(self._vfs_ovdir) \
+ result += [ ( x, self._beacon_ovdir + x ) for x in
os.listdir(self._beacon_ovdir) \
if not x.startswith('.') and not x in listdir ]
except OSError:
pass
- self._vfs_os_listdir_cache = result
+ self._beacon_os_listdir_cache = result
return result
@@ -155,18 +155,18 @@
"""
Convert object to string (usefull for debugging)
"""
- str = '<vfs.Directory %s' % self.filename
- if self._vfs_data['mtime'] == UNKNOWN:
+ str = '<beacon.Directory %s' % self.filename
+ if self._beacon_data['mtime'] == UNKNOWN:
str += ' (new)'
return str + '>'
def listdir(self):
"""
- Interface to kaa.vfs: List all files in the directory.
+ Interface to kaa.beacon: List all files in the directory.
"""
- if not self._vfs_id:
+ if not self._beacon_id:
log.info('requesting data for %s', self)
- self._vfs_request()
- return self._vfs_db().query(parent=self)
+ self._beacon_request()
+ return self._beacon_db().query(parent=self)
Modified: trunk/beacon/src/file.py
==============================================================================
--- trunk/beacon/src/file.py (original)
+++ trunk/beacon/src/file.py Sat Mar 25 18:08:21 2006
@@ -1,11 +1,11 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# file.py - File item of the VFS
+# file.py - Beacon file item
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -34,12 +34,12 @@
import stat
import logging
-# kaa.vfs imports
+# kaa.beacon imports
from item import Item
from directory import Directory
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
UNKNOWN = -1
@@ -55,7 +55,7 @@
setattr: function to set an attribute
keys: function to return all known attributes of the item
- Do not access attributes starting with _vfs outside kaa.vfs
+ Do not access attributes starting with _beacon outside kaa.beacon
"""
def __init__(self, data, parent, overlay=False):
if isinstance(data, str):
@@ -63,20 +63,20 @@
id = None
self.filename = parent.filename + data
data = { 'name': data, 'mtime': UNKNOWN }
- if parent and parent._vfs_id:
- data['parent_type'], data['parent_id'] = parent._vfs_id
- media = parent._vfs_media
+ if parent and parent._beacon_id:
+ data['parent_type'], data['parent_id'] = parent._beacon_id
+ media = parent._beacon_media
elif isinstance(parent, Directory):
# db data
id = (data['type'], data['id'])
- media = parent._vfs_media
+ media = parent._beacon_media
self.filename = parent.filename + data['name']
Item.__init__(self, id, 'file://' + self.filename, data, parent, media)
- self._vfs_overlay = overlay
+ self._beacon_overlay = overlay
- def _vfs_mtime(self):
+ def _beacon_mtime(self):
"""
Return modification time of the item itself.
@@ -84,28 +84,28 @@
mtime of foo.jpg is the sum of the mtime of foo.jpg and foo.jpg.xml
or for foo.mp3 the mtime is the sum of foo.mp3 and foo.jpg.
"""
- search = self._vfs_data['name']
+ search = self._beacon_data['name']
if search.rfind('.') > 0:
search = search[:search.rfind('.')]
mtime = 0
- for basename, filename in self._vfs_parent._vfs_os_listdir():
+ for basename, filename in self._beacon_parent._beacon_os_listdir():
if basename.startswith(search):
mtime += os.stat(filename)[stat.ST_MTIME]
return mtime
- def _vfs_request(self):
+ def _beacon_request(self):
"""
Request the item to be scanned.
"""
-
self._vfs_database_update(self._vfs_db()._vfs_request(self.filename[:-1]))
+
self._beacon_database_update(self._beacon_db()._beacon_request(self.filename[:-1]))
def __repr__(self):
"""
Convert object to string (usefull for debugging)
"""
- str = '<vfs.File %s' % self.filename
- if self._vfs_data['mtime'] == UNKNOWN:
+ str = '<beacon.File %s' % self.filename
+ if self._beacon_data['mtime'] == UNKNOWN:
str += ' (new)'
return str + '>'
Modified: trunk/beacon/src/item.py
==============================================================================
--- trunk/beacon/src/item.py (original)
+++ trunk/beacon/src/item.py Sat Mar 25 18:08:21 2006
@@ -1,11 +1,11 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# item.py - Item of the VFS
+# item.py - Beacon item
# -----------------------------------------------------------------------------
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -35,11 +35,11 @@
# kaa imports
from kaa.strutils import str_to_unicode
-# kaa.vfs imports
+# kaa.beacon imports
from thumbnail import Thumbnail
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
class Item(object):
"""
@@ -51,63 +51,63 @@
setattr: function to set an attribute
keys: function to return all known attributes of the item
- Do not access attributes starting with _vfs outside kaa.vfs
+ Do not access attributes starting with _beacon outside kaa.beacon
"""
- def __init__(self, _vfs_id, url, data, parent, media):
+ def __init__(self, _beacon_id, url, data, parent, media):
# url of the item
self.url = url
# internal data
- self._vfs_id = _vfs_id
- self._vfs_data = data
- self._vfs_tmpdata = {}
- self._vfs_parent = parent
- self._vfs_media = media
- self._vfs_isdir = False
- self._vfs_changes = {}
- self._vfs_name = data['name']
+ self._beacon_id = _beacon_id
+ self._beacon_data = data
+ self._beacon_tmpdata = {}
+ self._beacon_parent = parent
+ self._beacon_media = media
+ self._beacon_isdir = False
+ self._beacon_changes = {}
+ self._beacon_name = data['name']
- def _vfs_database_update(self, data):
+ def _beacon_database_update(self, data):
"""
Callback from db with new data
"""
- self._vfs_data = data
- self._vfs_id = (data['type'], data['id'])
- for key, value in self._vfs_changes.items():
- self._vfs_data[key] = value
+ self._beacon_data = data
+ self._beacon_id = (data['type'], data['id'])
+ for key, value in self._beacon_changes.items():
+ self._beacon_data[key] = value
- def _vfs_db(self):
+ def _beacon_db(self):
"""
Get the database connection (the client)
"""
- return self._vfs_media.client
+ return self._beacon_media.client
- def _vfs_mtime(self):
+ def _beacon_mtime(self):
"""
Return modification time of the item itself.
"""
return 0
- def _vfs_changed(self):
+ def _beacon_changed(self):
"""
Return if the item is changed (based on modification time of
the data and in the database).
"""
- return self._vfs_mtime() != self._vfs_data['mtime']
+ return self._beacon_mtime() != self._beacon_data['mtime']
- def _vfs_request(self):
+ def _beacon_request(self):
"""
Request the item to be scanned.
"""
pass
- def _vfs_tree(self):
+ def _beacon_tree(self):
"""
Return an iterator to walk through the parents.
"""
@@ -118,12 +118,12 @@
"""
Convert object to string (usefull for debugging)
"""
- return '<vfs.Item %s>' % self.url
+ return '<beacon.Item %s>' % self.url
def getattr(self, key, request=True):
"""
- Interface to kaa.vfs. Return the value of a given attribute. If
+ Interface to kaa.beacon. Return the value of a given attribute. If
the attribute is not in the db, return None. If the key starts with
'tmp:', the data will be fetched from a dict that is not stored in
the db. Loosing the item object will remove that attribute. If
@@ -131,68 +131,68 @@
False and the item is not in the db, results will be very limited.
"""
if key.startswith('tmp:'):
- return self._vfs_tmpdata[key[4:]]
+ return self._beacon_tmpdata[key[4:]]
if key == 'parent':
- return self._vfs_parent
+ return self._beacon_parent
if key == 'thumbnail' and hasattr(self, 'filename'):
return Thumbnail(self.filename, url=self.url)
if key == 'image':
image = ''
- if self._vfs_data.has_key('image'):
- image = self._vfs_data['image']
- if not image and self._vfs_parent:
+ if self._beacon_data.has_key('image'):
+ image = self._beacon_data['image']
+ if not image and self._beacon_parent:
# This is not a good solution, maybe the parent is not
# up to date. Well, we have to live with that for now.
- return self._vfs_parent.getattr('image')
+ return self._beacon_parent.getattr('image')
return image
if key == 'title':
- if self._vfs_data.has_key('title'):
- t = self._vfs_data['title']
+ if self._beacon_data.has_key('title'):
+ t = self._beacon_data['title']
if t:
return t
- t = self._vfs_data['name']
+ t = self._beacon_data['name']
if t.find('.') > 0:
t = t[:t.rfind('.')]
return str_to_unicode(t)
- if request and not self._vfs_id:
+ if request and not self._beacon_id:
log.info('requesting data for %s', self)
- self._vfs_request()
+ self._beacon_request()
- if self._vfs_data.has_key(key):
- return self._vfs_data[key]
+ if self._beacon_data.has_key(key):
+ return self._beacon_data[key]
return None
def setattr(self, key, value, request=True):
"""
- Interface to kaa.vfs. Set the value of a given attribute. If the key
+ Interface to kaa.beacon. Set the value of a given attribute. If the key
starts with 'tmp:', the data will only be valid in this item and not
stored in the db. Loosing the item object will remove that attribute.
If
request is True, scan the item if it is not in the db. If request is
False and the item is not in the db, the value may be lost.
"""
if key.startswith('tmp:'):
- self._vfs_tmpdata[key[4:]] = value
+ self._beacon_tmpdata[key[4:]] = value
return
- if not self._vfs_id:
+ if not self._beacon_id:
log.info('requesting data for %s', self)
- self._vfs_request()
- self._vfs_data[key] = value
- if not self._vfs_changes and self._vfs_id:
- self._vfs_db().update(self)
- self._vfs_changes[key] = value
+ self._beacon_request()
+ self._beacon_data[key] = value
+ if not self._beacon_changes and self._beacon_id:
+ self._beacon_db().update(self)
+ self._beacon_changes[key] = value
def keys(self):
"""
- Interface to kaa.vfs. Return all attributes of the item.
+ Interface to kaa.beacon. Return all attributes of the item.
"""
- return self._vfs_data.keys() + self._vfs_tmpdata.keys()
+ return self._beacon_data.keys() + self._beacon_tmpdata.keys()
class ParentIterator(object):
@@ -209,5 +209,5 @@
if not self.item:
raise StopIteration
ret = self.item
- self.item = self.item._vfs_parent
+ self.item = self.item._beacon_parent
return ret
Modified: trunk/beacon/src/monitor.py
==============================================================================
--- trunk/beacon/src/monitor.py (original)
+++ trunk/beacon/src/monitor.py Sat Mar 25 18:08:21 2006
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# monitor.py - Monitor for changes in the VFS
+# monitor.py - Monitor for changes in Beacon
# -----------------------------------------------------------------------------
# $Id$
#
@@ -8,7 +8,7 @@
# add docs for functions, variables and how to use this file
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -40,12 +40,12 @@
from kaa.weakref import weakref
from kaa.notifier import WeakTimer, Timer, execute_in_timer, Callback
-# kaa.vfs imports
+# kaa.beacon imports
import parser
import cdrom
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
class Notification(object):
def __init__(self, remote, id):
@@ -127,7 +127,7 @@
return True
i = items.pop(0)
# FIXME: check parents
- if i._vfs_changed():
+ if i._beacon_changed():
changed.append(i)
return True
@@ -209,7 +209,7 @@
def __repr__(self):
- return '<vfs.Monitor for %s>' % self._query
+ return '<beacon.Monitor for %s>' % self._query
def __del__(self):
Modified: trunk/beacon/src/parser.py
==============================================================================
--- trunk/beacon/src/parser.py (original)
+++ trunk/beacon/src/parser.py Sat Mar 25 18:08:21 2006
@@ -8,7 +8,7 @@
# add docs for functions, variables and how to use this file
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -44,38 +44,38 @@
import kaa.metadata
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
def parse(db, item, store=False):
log.info('check %s', item.url)
- mtime = item._vfs_mtime()
+ mtime = item._beacon_mtime()
if not mtime:
log.info('oops, no mtime %s' % item)
return
- parent = item._vfs_parent
+ parent = item._beacon_parent
if not parent:
log.error('no parent %s' % item)
return
- if not parent._vfs_id:
+ if not parent._beacon_id:
# There is a parent without id, update the parent now. We know that the
# parent should be in the db, so commit and it should work
db.commit()
- if not parent._vfs_id:
+ if not parent._beacon_id:
# this should never happen
raise AttributeError('parent for %s has no dbid' % item)
- if item._vfs_data['mtime'] == mtime:
+ if item._beacon_data['mtime'] == mtime:
log.debug('up-to-date %s' % item)
return
log.info('scan %s' % item)
attributes = { 'mtime': mtime }
metadata = kaa.metadata.parse(item.filename)
- if item._vfs_data.has_key('type'):
- type = item._vfs_data['type']
+ if item._beacon_data.has_key('type'):
+ type = item._beacon_data['type']
elif metadata and metadata['media'] and \
db.object_types().has_key(metadata['media']):
type = metadata['media']
- elif item._vfs_isdir:
+ elif item._beacon_isdir:
type = 'dir'
else:
type = 'file'
@@ -114,16 +114,16 @@
# Note: the items are not updated yet, the changes are still in
# the queue and will be added to the db on commit.
- if item._vfs_id:
+ if item._beacon_id:
# Update
- db.update_object(item._vfs_id, **attributes)
- item._vfs_data.update(attributes)
+ db.update_object(item._beacon_id, **attributes)
+ item._beacon_data.update(attributes)
else:
# Create. Maybe the object is already in the db. This could happen
because
# of bad timing but should not matter. Only one entry will be there
after
# the next update
- db.add_object(type, name=item._vfs_data['name'], parent=parent._vfs_id,
- overlay=item._vfs_overlay,
callback=item._vfs_database_update,
+ db.add_object(type, name=item._beacon_data['name'],
parent=parent._beacon_id,
+ overlay=item._beacon_overlay,
callback=item._beacon_database_update,
**attributes)
if store:
db.commit()
@@ -157,8 +157,8 @@
if item:
self.notify('progress', self.pos, self.max, item.url)
parse(self.db, item)
- if item._vfs_id:
- self.notify('updated', [ (item.url, item._vfs_data) ])
+ if item._beacon_id:
+ self.notify('updated', [ (item.url, item._beacon_data) ])
else:
self.updated.append(item)
@@ -170,10 +170,10 @@
updated = []
- while self.updated and self.updated[0] and self.updated[0]._vfs_id:
+ while self.updated and self.updated[0] and self.updated[0]._beacon_id:
updated.append(self.updated.pop(0))
if updated:
- updated = [ (x.url, x._vfs_data) for x in updated ]
+ updated = [ (x.url, x._beacon_data) for x in updated ]
updated.sort(lambda x,y: cmp(x[0], y[0]))
self.notify('updated', updated)
Modified: trunk/beacon/src/query.py
==============================================================================
--- trunk/beacon/src/query.py (original)
+++ trunk/beacon/src/query.py Sat Mar 25 18:08:21 2006
@@ -5,7 +5,7 @@
# $Id$
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -37,7 +37,7 @@
from kaa.notifier import Signal
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
class Query(object):
@@ -71,7 +71,7 @@
self._monitor = status
- def _vfs_progress(self, pos, max, url):
+ def _beacon_progress(self, pos, max, url):
"""
Progress message from server.
"""
@@ -79,7 +79,7 @@
return
- def _vfs_checked(self):
+ def _beacon_checked(self):
"""
Checked message from server.
"""
@@ -87,14 +87,14 @@
return
- def _vfs_updated(self, items):
+ def _beacon_updated(self, items):
"""
Checked message from server.
"""
url, data = items.pop(0)
for r in self.result:
if r.url == url:
- r._vfs_database_update(data)
+ r._beacon_database_update(data)
if not items:
break
url, data = items.pop(0)
@@ -102,7 +102,7 @@
log.error('not all items found')
- def _vfs_changed(self):
+ def _beacon_changed(self):
self.result = self._client.database.query(**self._query)
self.signals['changed'].emit()
@@ -111,7 +111,7 @@
"""
Convert object to string (usefull for debugging)
"""
- return '<vfs.Client.Query for %s>' % self._query
+ return '<beacon.Client.Query for %s>' % self._query
def __del__(self):
Modified: trunk/beacon/src/server.py
==============================================================================
--- trunk/beacon/src/server.py (original)
+++ trunk/beacon/src/server.py Sat Mar 25 18:08:21 2006
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
-# server.py - Server interface for the VFS
+# server.py - Server interface for Beacon
# -----------------------------------------------------------------------------
# $Id$
#
@@ -8,7 +8,7 @@
# add docs for functions, variables and how to use this file
#
# -----------------------------------------------------------------------------
-# kaa-vfs - A virtual filesystem with metadata
+# kaa-beacon - A virtual filesystem with metadata
# Copyright (C) 2005 Dirk Meyer
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
@@ -43,13 +43,13 @@
from kaa.weakref import weakref
from kaa.notifier import OneShotTimer, Timer
-# kaa.vfs imports
+# kaa.beacon imports
import parser
from db import *
from monitor import Monitor
# get logging object
-log = logging.getLogger('vfs')
+log = logging.getLogger('beacon')
# ipc debugging
# ipc.DEBUG = 1
@@ -110,7 +110,7 @@
# add root mountpoint
self.add_mountpoint(None, '/')
- self.set_mountpoint('/', 'kaa.vfs.root')
+ self.set_mountpoint('/', 'kaa.beacon.root')
# commit and wait for the results (there are no results,
# this code is only used to force waiting until the db is
@@ -208,14 +208,14 @@
self._db.commit()
data = self._db.query(filename=filename)
items = []
- for i in data._vfs_tree():
- if i._vfs_id:
+ for i in data._beacon_tree():
+ if i._beacon_id:
break
items.append(i)
while items:
parser.parse(self._db, items.pop(), store=True)
self._db.commit()
- return data._vfs_data
+ return data._beacon_data
def __del__(self):
@@ -268,7 +268,7 @@
return True
shutdown_timer -= 1
if shutdown_timer == 0:
- log.info('vfs server timeout')
+ log.info('beacon timeout')
sys.exit(0)
return True
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog