Changeset 3611
- Timestamp:
- 10/10/08 23:22:14 (3 months ago)
- Location:
- trunk/beacon
- Files:
-
- 1 added
- 15 modified
-
bin/beacon-daemon (modified) (1 diff)
-
doc/epydoc (added)
-
setup.py (modified) (1 diff)
-
src/__init__.py (modified) (9 diffs)
-
src/client.py (modified) (1 diff)
-
src/db.py (modified) (2 diffs)
-
src/file.py (modified) (1 diff)
-
src/fusefs.py (modified) (1 diff)
-
src/item.py (modified) (7 diffs)
-
src/media.py (modified) (5 diffs)
-
src/server/db.py (modified) (1 diff)
-
src/server/devices.py (modified) (1 diff)
-
src/server/monitor.py (modified) (1 diff)
-
src/server/parser.py (modified) (2 diffs)
-
src/server/thumbnailer.py (modified) (1 diff)
-
src/server/videothumb.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/beacon/bin/beacon-daemon
r3607 r3611 270 270 271 271 #wait for dead child 272 os.waitpid(pid, 0) 273 274 print 'Beacon done.' 272 try: 273 os.waitpid(pid, 0) 274 except OSError: 275 pass -
trunk/beacon/setup.py
r3004 r3611 82 82 version = '0.1.0', 83 83 license = 'LGPL', 84 epydoc = [ 'doc/epydoc' ], 84 85 summary = "Media-oriented virtual filesystem", 85 86 scripts = [ 'bin/kaa-thumb', 'bin/beacon-daemon', 'bin/beacon-search', -
trunk/beacon/src/__init__.py
r3475 r3611 30 30 # ----------------------------------------------------------------------------- 31 31 32 __all__ = [ 'connect', 'get', 'query', 'register_filter', 'Item', 33 'THUMBNAIL_NORMAL', 'THUMBNAIL_LARGE' ] 32 """ 33 kaa.beacon 34 35 @group Server: connect, launch 36 @group Query: query, get, monitor, register_filter, wrap 37 @group Media Handling: list_media, delete_media 38 @group Database Manipulation: add_item, register_file_type_attrs, register_track_type_attrs, get_db_info 39 """ 40 41 __all__ = [ 'connect', 'launch', 'get', 'query', 'monitor', 'add_item', 'wrap', 42 'register_file_type_attrs', 'register_track_type_attrs', 'get_db_info', 43 'list_media', 'delete_media', 'register_filter', 'Item', 'Query', 'Media', 44 'File', 'VERSION', 'THUMBNAIL_NORMAL', 'THUMBNAIL_LARGE' ] 34 45 35 46 # python imports … … 52 63 from query import register_filter, wrap, Query 53 64 from item import Item 65 from file import File 66 from version import VERSION 67 from media import Media 54 68 from kaa.db import * 55 69 … … 98 112 def launch(autoshutdown=False, verbose='none'): 99 113 """ 100 Lauch a beacon server. 114 Lauch a beacon server and connect to it. 115 116 @param autoshutdown: if the server should shut down when no client is 117 connected anymore 118 @param verbose: verbose level for the server log 101 119 """ 102 120 beacon = os.path.dirname(__file__), '../../../../../bin/beacon-daemon' … … 119 137 Get object for the given filename. This function will raise an exception if 120 138 the client is not connected and the server is not running for a connect. 121 This function may return an InProgress object. 139 140 @returns: InProgress 141 @rtype: L{File} 122 142 """ 123 143 if not _client: … … 131 151 client is not connected and the server is not running for a connect. 132 152 133 @returns InProgress object with a kaa.beacon.Query 153 @returns: InProgress 154 @rtype: L{Query} 134 155 """ 135 156 if not _client: … … 142 163 Monitor a directory with subdirectories for changes. This is done in 143 164 the server and will keep the database up to date. 165 166 @param directory: directory path name 144 167 """ 145 168 if not _client: … … 178 201 """ 179 202 Gets statistics about the database. 180 (Only usefull for debugging) 203 204 @return: basic database information 181 205 """ 182 206 if not _client: … … 188 212 """ 189 213 List all media objects. 214 215 @returns: list of the available media 216 @rtype: list of L{Media} 190 217 """ 191 218 if not _client: … … 199 226 """ 200 227 Delete media with the given id. 228 229 @param id: Media object ID 201 230 """ 202 231 if not _client: -
trunk/beacon/src/client.py
r3475 r3611 412 412 # Update can take a while but it should not matter here. 413 413 # The InProgress object can be ignored 414 self._db.medialist.get_by_media_id(id). update(prop)414 self._db.medialist.get_by_media_id(id)._beacon_update(prop) 415 415 return 416 416 # Adding a media always returns an InProgress object. Attach -
trunk/beacon/src/db.py
r3609 r3611 302 302 # file deleted 303 303 i = items[pos] 304 if not i.isdir and not i.isfile ():304 if not i.isdir and not i.isfile: 305 305 # A remote URL in the directory 306 306 pos += 1 … … 324 324 # deleted files at the end 325 325 for i in items[pos+1-len(items):]: 326 if not i.isdir and not i.isfile ():326 if not i.isdir and not i.isfile: 327 327 # A remote URL in the directory 328 328 continue -
trunk/beacon/src/file.py
r3609 r3611 49 49 A file based database item. 50 50 51 Attributes: 52 url: unique url of the item 53 filename: complete filename 54 55 Functions: 56 get: get an attribute, optional argument force 57 __getitem__: get an attribute 58 __setitem__: set an attribute 59 keys: return all known attributes of the item 60 scanned: return True if the item is scanned 61 list: return list of subitems or directory content 62 isdir: return True if it is a directory 63 isfile: return True if it is a regular file 64 65 Do not access attributes starting with _beacon outside kaa.beacon 51 @ivar url: unique url of the item 52 @ivar filename: complete filename 53 @ivar isdir: True if it is a directory 54 @ivar isfile: True if it is a regular file 55 @ivar scanned: True if the item is scanned 56 57 @note: do not access attributes starting with _beacon outside kaa.beacon 66 58 """ 67 59 -
trunk/beacon/src/fusefs.py
r3609 r3611 87 87 self._query_update_time = int(time.time()) 88 88 for item in self._query: 89 if not item.isfile ()and not item.isdir:89 if not item.isfile and not item.isdir: 90 90 # no file or dir, we can't link to it 91 91 continue -
trunk/beacon/src/item.py
r3609 r3611 47 47 A database item. 48 48 49 Attributes: 50 url: unique url of the item 51 filename: empty string 52 isdir: False 53 isfile: False 54 scanned: True if the item is scanned 55 56 Functions: 57 get: get an attribute, optional argument force 58 __getitem__: get an attribute 59 __setitem__: set an attribute 60 keys: return all known attributes of the item 61 list: return list of subitems 62 63 Do not access attributes starting with _beacon outside kaa.beacon 49 @ivar url: unique url of the item 50 @ivar filename: complete filename or file items 51 @ivar isdir: True if it is a directory 52 @ivar isfile: True if it is a regular file 53 @ivar scanned: True if the item is scanned 54 @ivar thumbnail: Thumbnail for the Item 55 @type thumbnail: L{Thumbnail} 56 @note: do not access attributes starting with _beacon outside kaa.beacon 64 57 """ 65 58 … … 82 75 def get(self, key, default=None): 83 76 """ 84 Interface to kaa.beacon. Return the value of a given attribute. If 85 the attribute is not in the db, return None. If the key starts with 86 'tmp:', the data will be fetched from a dict that is not stored in 87 the db. Loosing the item object will remove that attribute. 77 Access attributes of the item. 78 79 Besides the keys in the database an item has the following attributes 80 accessable with this function: 81 82 - parent: parent L{Item} or L{Item} 83 - media: L{Media} object the item is on 84 - thumbnail: L{Thumbnail} object for the item or parent 85 - image: image path for the item or parent 86 - read_only: True if the item is on a read only media 87 88 @returns: the value of a given attribute. If the attribute is not in the db, 89 return None. 90 @note: If the key starts with C{'tmp:'}, the data will be fetched from the 91 temp directory and not from the db. 92 attribute. 88 93 """ 89 94 if key.startswith('tmp:'): … … 119 124 return t 120 125 # generate some title and save local it for future use 121 t = kaa.str_to_unicode(get_title(self._beacon_data['name'], self.isfile ()))126 t = kaa.str_to_unicode(get_title(self._beacon_data['name'], self.isfile)) 122 127 self._beacon_data['title'] = t 123 128 return t … … 132 137 def __setitem__(self, key, value): 133 138 """ 134 Interface to kaa.beacon. Set the value of a given attribute. If the key 135 starts with 'tmp:', the data will only be valid in this item and not 136 stored in the db. Loosing the item object will remove that attribute. 139 Set the value of a given attribute. If the key starts with 140 C{'tmp:'}, the data will only be valid in this item and not 141 stored in the db. Loosing the item object will remove that 142 attribute. 137 143 """ 138 144 if key.startswith('tmp:'): … … 146 152 def keys(self): 147 153 """ 148 Interface to kaa.beacon. Return all attributes of the item. 154 List item attributes 155 156 @returns: all attributes of the item. 149 157 """ 150 158 return self._beacon_data.keys() + self._beacon_tmpdata.keys() … … 152 160 def has_key(self, key): 153 161 """ 154 Returns True if the key is stored in the item. 162 Check if the item has a specific attributes set 163 164 @returns: True if the key is stored in the item. 155 165 """ 156 166 return key in self._beacon_data.keys() or \ … … 177 187 """ 178 188 return not self._beacon_isdir and self.filename != '' 189 190 @property 191 def thumbnail(self): 192 """ 193 Return Thumbnail for the Item 194 """ 195 return self.get('thumbnail') 179 196 180 197 def list(self): -
trunk/beacon/src/media.py
r3609 r3611 51 51 """ 52 52 def __init__(self, id, controller): 53 """ 54 Create a media object 55 56 @note: Objects are created by the hardware monitor subsystem, do not create 57 Media objects from outside beacon. 58 """ 53 59 log.info('new media %s', id) 54 60 self._beacon_controller = controller … … 57 63 self.crawler = None 58 64 59 60 65 def eject(self): 61 66 """ … … 64 69 self._beacon_controller.eject(self) 65 70 71 @property 72 def isdir(self): 73 """ 74 Return False for items directly on the media without dir, 75 like a dvd video. 76 """ 77 return False 78 79 def get(self, key, default=None): 80 """ 81 Get value. 82 """ 83 return self.prop.get(key, default) 84 85 def __getitem__(self, key): 86 """ 87 Get value 88 """ 89 return self.prop[key] 90 91 def __setitem__(self, key, value): 92 """ 93 Set value 94 """ 95 self.prop[key] = value 96 97 def __repr__(self): 98 """ 99 For debugging only. 100 """ 101 return '<kaa.beacon.Media %s>' % self.id 66 102 67 103 @kaa.coroutine() 68 def update(self, prop):104 def _beacon_update(self, prop): 69 105 """ 70 106 Update media properties. … … 107 143 self.label = self.id 108 144 109 110 def isdir(self):111 """112 Return False for items directly on the media without dir,113 e.g. a dvd video.114 """115 return False116 117 118 def get(self, key, default=None):119 """120 Get value.121 """122 return self.prop.get(key, default)123 124 125 def __getitem__(self, key):126 """127 Get value128 """129 return self.prop[key]130 131 132 def __setitem__(self, key, value):133 """134 Set value135 """136 self.prop[key] = value137 138 139 def __repr__(self):140 """141 For debugging only.142 """143 return '<kaa.beacon.Media %s>' % self.id144 145 146 145 @property 147 146 def _beacon_media(self): … … 182 181 yield self._dict.get(id) 183 182 media = Media(id, self._beacon_controller) 184 async = media. update(prop)183 async = media._beacon_update(prop) 185 184 if isinstance(async, kaa.InProgress): 186 185 # This will happen for the client because update -
trunk/beacon/src/server/db.py
r3470 r3611 43 43 44 44 # beacon imports 45 from kaa.beacon.item import Item46 from kaa.beacon.db import Database as RO_Database45 from ..item import Item 46 from ..db import Database as RO_Database 47 47 48 48 # get logging object -
trunk/beacon/src/server/devices.py
r3608 r3611 134 134 # already in db 135 135 media = self._db.medialist.get_by_media_id(id) 136 media. update(dev)136 media._beacon_update(dev) 137 137 self.handler.media_changed(media) 138 138 return -
trunk/beacon/src/server/monitor.py
r3609 r3611 40 40 41 41 # kaa.beacon imports 42 from kaa.beacon.item import Item42 from ..item import Item 43 43 from parser import parse 44 44 -
trunk/beacon/src/server/parser.py
r3609 r3611 45 45 46 46 # kaa.beacon imports 47 from kaa.beaconimport thumbnail48 from kaa.beacon.utils import get_title47 from .. import thumbnail 48 from ..utils import get_title 49 49 import utils 50 50 … … 86 86 mtime = item._beacon_mtime 87 87 if mtime == None: 88 if item.isdir or item.isfile ():88 if item.isdir or item.isfile: 89 89 log.warning('no mtime, skip %s' % item) 90 90 return 0 -
trunk/beacon/src/server/thumbnailer.py
r3361 r3611 44 44 45 45 # kaa.beacon imports 46 from kaa.beacon._libthumb import epeg, png, failed46 from .._libthumb import epeg, png, failed 47 47 from videothumb import VideoThumb 48 48 import cpuinfo -
trunk/beacon/src/server/videothumb.py
r3608 r3611 48 48 49 49 # kaa.beacon imports 50 from kaa.beacon._libthumb import epeg, png, failed50 from .._libthumb import epeg, png, failed 51 51 import cpuinfo 52 52
