Changeset 198

Show
Ignore:
Timestamp:
07/03/08 10:13:31 (3 months ago)
Author:
dino
Message:
  • some docscrings
  • refactoring
  • avahi_name not configable
Location:
projects/apt-zeroconf/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • projects/apt-zeroconf/trunk/apt-zeroconf

    r184 r198  
    3030pidfile = '/var/run/apt-zeroconf.pid' 
    3131logfile = '/var/log/apt-zeroconf' 
     32 
    3233 
    3334if options.background: 
  • projects/apt-zeroconf/trunk/aptzeroconf/__init__.py

    r193 r198  
    3535logging.basicConfig(level=logging.DEBUG, 
    3636        format='%(asctime)s [%(threadName)s] [%(levelname)-7s] %(message)s', 
    37         datefmt='%Y-%m-%d %H:%M:%S' 
    38 ) 
     37        datefmt='%Y-%m-%d %H:%M:%S') 
    3938 
    4039import signal 
     
    4746 
    4847def main(): 
     48    logging.debug('apt-zeroconf %s' % __version__) 
     49 
    4950    # Kick off the httpd 
    50     logging.debug('apt-zeroconf %s' % __version__) 
    5151    logging.debug('Starting httpd on port %i.' % config['http_port']) 
    5252    httpd = HttpServer() 
  • projects/apt-zeroconf/trunk/aptzeroconf/avaphi.py

    r190 r198  
    3636from aptzeroconf.config import config 
    3737 
    38 stype = '_apt._tcp' 
    39 domain = '' 
    40 host = '' 
    41 txt = [] 
    42  
    4338 
    4439class AZCAvahiService(threading.Thread): 
     
    5045        self.n_rename = 0 
    5146 
    52         self.name = config['avahi_name'] % config['hostname'] 
    53         self.stype = stype 
    54         self.domain = domain 
    55         self.host = host 
     47        self.name = 'apt-zeroconf repository on %s' % config['hostname'] 
     48        self.stype = '_apt._tcp' 
     49        self.domain = '' 
     50        self.host = '' 
    5651        self.port = config['http_port'] 
    57         self.txt = txt 
     52        self.data = ['downloading=False'] # TODO use me! 
    5853 
    5954        hosts.set_service(self) 
     
    8176                self.name, self.stype, self.domain, self.host, 
    8277                dbus.UInt16(self.port), 
    83                 avahi.string_array_to_txt_array(self.txt)) 
     78                avahi.string_array_to_txt_array(self.data)) 
    8479        self.group.Commit() 
    8580 
     
    187182            return 
    188183 
     184        data = {} 
     185        for i in avahi.txt_array_to_string_array(txt): 
     186            i = i.split('=') 
     187            data[i[0]] = [1] 
     188 
    189189        url = make_url(address, port, protocol) 
    190190        self['%s:%s:%s' % (name, interface, domain)] = { 
    191                 'host': host, 'address': address, 'port': port, 'txt': txt, 
     191                'host': host, 'address': address, 'port': port, 'data': data, 
    192192                'proto': protocol, 'url': url, 
    193193                'pkglist': self._fetch_list(url)} 
  • projects/apt-zeroconf/trunk/aptzeroconf/util.py

    r184 r198  
    2525# synchronized decorator 
    2626def synchronized(lock): 
     27    """Wrapper function to make threadsave code easy. To be used as  
     28       decorater.""" 
    2729    def wrap(f): 
    2830        def func(*args, **kw): 
     
    3840EPOCH_PATTERN = re.compile(r'\_\d+\%3a') 
    3941 
    40 def prune_epoch(f): 
    41     return EPOCH_PATTERN.sub('_', f) 
     42def prune_epoch(fname): 
     43    """Prune epoch from package name as apt does. """ 
     44    return EPOCH_PATTERN.sub('_', fname) 
    4245 
    4346def make_url(address, port, proto): 
     
    4548    return '%s:%i' % \ 
    4649        ((proto == avahi.PROTO_INET6 and '[%s]' or '%s') % address, port) 
    47  
  • projects/apt-zeroconf/trunk/support/apt-zeroconf.conf

    r172 r198  
    55apt_cache_path = /var/cache/apt/archives 
    66 
    7 # name of the avahi-service, %s will be replaced with the hostname 
    8 avahi_name = apt-zeroconf repository on %s 
    97# override hostname if needed 
    108;hostname = machine