Changeset 3611

Show
Ignore:
Timestamp:
10/10/08 23:22:14 (3 months ago)
Author:
dmeyer
Message:

doc update

Location:
trunk/beacon
Files:
1 added
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/beacon/bin/beacon-daemon

    r3607 r3611  
    270270 
    271271#wait for dead child 
    272 os.waitpid(pid, 0) 
    273  
    274 print 'Beacon done.' 
     272try: 
     273    os.waitpid(pid, 0) 
     274except OSError: 
     275    pass 
  • trunk/beacon/setup.py

    r3004 r3611  
    8282       version     = '0.1.0', 
    8383       license     = 'LGPL', 
     84       epydoc      = [ 'doc/epydoc' ], 
    8485       summary     = "Media-oriented virtual filesystem", 
    8586       scripts     = [ 'bin/kaa-thumb', 'bin/beacon-daemon', 'bin/beacon-search', 
  • trunk/beacon/src/__init__.py

    r3475 r3611  
    3030# ----------------------------------------------------------------------------- 
    3131 
    32 __all__ = [ 'connect', 'get', 'query', 'register_filter', 'Item', 
    33             'THUMBNAIL_NORMAL', 'THUMBNAIL_LARGE' ] 
     32""" 
     33kaa.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' ] 
    3445 
    3546# python imports 
     
    5263from query import register_filter, wrap, Query 
    5364from item import Item 
     65from file import File 
     66from version import VERSION 
     67from media import Media 
    5468from kaa.db import * 
    5569 
     
    98112def launch(autoshutdown=False, verbose='none'): 
    99113    """ 
    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 
    101119    """ 
    102120    beacon = os.path.dirname(__file__), '../../../../../bin/beacon-daemon' 
     
    119137    Get object for the given filename. This function will raise an exception if 
    120138    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} 
    122142    """ 
    123143    if not _client: 
     
    131151    client is not connected and the server is not running for a connect. 
    132152 
    133     @returns InProgress object with a kaa.beacon.Query 
     153    @returns: InProgress 
     154    @rtype: L{Query} 
    134155    """ 
    135156    if not _client: 
     
    142163    Monitor a directory with subdirectories for changes. This is done in 
    143164    the server and will keep the database up to date. 
     165 
     166    @param directory: directory path name 
    144167    """ 
    145168    if not _client: 
     
    178201    """ 
    179202    Gets statistics about the database. 
    180     (Only usefull for debugging) 
     203 
     204    @return: basic database information 
    181205    """ 
    182206    if not _client: 
     
    188212    """ 
    189213    List all media objects. 
     214 
     215    @returns: list of the available media 
     216    @rtype: list of L{Media} 
    190217    """ 
    191218    if not _client: 
     
    199226    """ 
    200227    Delete media with the given id. 
     228 
     229    @param id: Media object ID 
    201230    """ 
    202231    if not _client: 
  • trunk/beacon/src/client.py

    r3475 r3611  
    412412            # Update can take a while but it should not matter here. 
    413413            # 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) 
    415415            return 
    416416        # Adding a media always returns an InProgress object. Attach 
  • trunk/beacon/src/db.py

    r3609 r3611  
    302302                # file deleted 
    303303                i = items[pos] 
    304                 if not i.isdir and not i.isfile(): 
     304                if not i.isdir and not i.isfile: 
    305305                    # A remote URL in the directory 
    306306                    pos += 1 
     
    324324            # deleted files at the end 
    325325            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: 
    327327                    # A remote URL in the directory 
    328328                    continue 
  • trunk/beacon/src/file.py

    r3609 r3611  
    4949    A file based database item. 
    5050 
    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 
    6658    """ 
    6759 
  • trunk/beacon/src/fusefs.py

    r3609 r3611  
    8787        self._query_update_time = int(time.time()) 
    8888        for item in self._query: 
    89             if not item.isfile() and not item.isdir: 
     89            if not item.isfile and not item.isdir: 
    9090                # no file or dir, we can't link to it 
    9191                continue 
  • trunk/beacon/src/item.py

    r3609 r3611  
    4747    A database item. 
    4848 
    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 
    6457    """ 
    6558 
     
    8275    def get(self, key, default=None): 
    8376        """ 
    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. 
    8893        """ 
    8994        if key.startswith('tmp:'): 
     
    119124                return t 
    120125            # 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)) 
    122127            self._beacon_data['title'] = t 
    123128            return t 
     
    132137    def __setitem__(self, key, value): 
    133138        """ 
    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. 
    137143        """ 
    138144        if key.startswith('tmp:'): 
     
    146152    def keys(self): 
    147153        """ 
    148         Interface to kaa.beacon. Return all attributes of the item. 
     154        List item attributes 
     155 
     156        @returns: all attributes of the item. 
    149157        """ 
    150158        return self._beacon_data.keys() + self._beacon_tmpdata.keys() 
     
    152160    def has_key(self, key): 
    153161        """ 
    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. 
    155165        """ 
    156166        return key in self._beacon_data.keys() or \ 
     
    177187        """ 
    178188        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') 
    179196 
    180197    def list(self): 
  • trunk/beacon/src/media.py

    r3609 r3611  
    5151    """ 
    5252    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        """ 
    5359        log.info('new media %s', id) 
    5460        self._beacon_controller = controller 
     
    5763        self.crawler = None 
    5864 
    59  
    6065    def eject(self): 
    6166        """ 
     
    6469        self._beacon_controller.eject(self) 
    6570 
     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 
    66102 
    67103    @kaa.coroutine() 
    68     def update(self, prop): 
     104    def _beacon_update(self, prop): 
    69105        """ 
    70106        Update media properties. 
     
    107143            self.label = self.id 
    108144 
    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 False 
    116  
    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 value 
    128         """ 
    129         return self.prop[key] 
    130  
    131  
    132     def __setitem__(self, key, value): 
    133         """ 
    134         Set value 
    135         """ 
    136         self.prop[key] = value 
    137  
    138  
    139     def __repr__(self): 
    140         """ 
    141         For debugging only. 
    142         """ 
    143         return '<kaa.beacon.Media %s>' % self.id 
    144  
    145  
    146145    @property 
    147146    def _beacon_media(self): 
     
    182181            yield self._dict.get(id) 
    183182        media = Media(id, self._beacon_controller) 
    184         async = media.update(prop) 
     183        async = media._beacon_update(prop) 
    185184        if isinstance(async, kaa.InProgress): 
    186185            # This will happen for the client because update 
  • trunk/beacon/src/server/db.py

    r3470 r3611  
    4343 
    4444# beacon imports 
    45 from kaa.beacon.item import Item 
    46 from kaa.beacon.db import Database as RO_Database 
     45from ..item import Item 
     46from ..db import Database as RO_Database 
    4747 
    4848# get logging object 
  • trunk/beacon/src/server/devices.py

    r3608 r3611  
    134134            # already in db 
    135135            media = self._db.medialist.get_by_media_id(id) 
    136             media.update(dev) 
     136            media._beacon_update(dev) 
    137137            self.handler.media_changed(media) 
    138138            return 
  • trunk/beacon/src/server/monitor.py

    r3609 r3611  
    4040 
    4141# kaa.beacon imports 
    42 from kaa.beacon.item import Item 
     42from ..item import Item 
    4343from parser import parse 
    4444 
  • trunk/beacon/src/server/parser.py

    r3609 r3611  
    4545 
    4646# kaa.beacon imports 
    47 from kaa.beacon import thumbnail 
    48 from kaa.beacon.utils import get_title 
     47from .. import thumbnail 
     48from ..utils import get_title 
    4949import utils 
    5050 
     
    8686    mtime = item._beacon_mtime 
    8787    if mtime == None: 
    88         if item.isdir or item.isfile(): 
     88        if item.isdir or item.isfile: 
    8989            log.warning('no mtime, skip %s' % item) 
    9090            return 0 
  • trunk/beacon/src/server/thumbnailer.py

    r3361 r3611  
    4444 
    4545# kaa.beacon imports 
    46 from kaa.beacon._libthumb import epeg, png, failed 
     46from .._libthumb import epeg, png, failed 
    4747from videothumb import VideoThumb 
    4848import cpuinfo 
  • trunk/beacon/src/server/videothumb.py

    r3608 r3611  
    4848 
    4949# kaa.beacon imports 
    50 from kaa.beacon._libthumb import epeg, png, failed 
     50from .._libthumb import epeg, png, failed 
    5151import cpuinfo 
    5252