Changeset 8a6ec7


Ignore:
Timestamp:
11/22/2009 02:34:51 AM (15 years ago)
Author:
Pedro Algarvio <ufs@ufsoft.org>
Branches:
2.0.x, develop, extjs4-port, master
Children:
1b7a50
Parents:
535940
Message:

Merge SVN and HG heads.

Location:
deluge
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • deluge/component.py

    r535940 r8a6ec7  
    102102            self.depend[name] = depend
    103103
     104    def deregister(self, name):
     105        """Deregisters a component"""
     106        if name in self.components:
     107            log.debug("Deregistering Component: %s", name)
     108            self.stop_component(name)
     109            del self.components[name]
     110
    104111    def get(self, name):
    105112        """Returns a reference to the component 'name'"""
     
    127134    def stop(self):
    128135        """Stops all components"""
    129         for component in self.components.keys():
    130             self.stop_component(component)
     136        # We create a separate list of the keys and do an additional check to
     137        # make sure the key still exists in the components dict.
     138        # This is because components could be deregistered during a stop and
     139        # the dictionary would get modified while iterating through it.
     140        components = self.components.keys()
     141        for component in components:
     142            if component in self.components:
     143                self.stop_component(component)
    131144
    132145    def stop_component(self, component):
     
    188201    _ComponentRegistry.register(name, obj, depend)
    189202
     203def deregister(name):
     204    """Deregisters a component"""
     205    _ComponentRegistry.deregister(name)
     206
    190207def start(component=None):
    191208    """Starts all components"""
  • deluge/core/rpcserver.py

    r535940 r8a6ec7  
    132132                request = rencode.loads(dobj.decompress(data))
    133133            except Exception, e:
    134                 log.debug("Received possible invalid message (%r): %s", data, e)
     134                #log.debug("Received possible invalid message (%r): %s", data, e)
    135135                # This could be cut-off data, so we'll save this in the buffer
    136136                # and try to prepend it on the next dataReceived()
  • deluge/core/torrentmanager.py

    r535940 r8a6ec7  
    211211    def stop(self):
    212212        # Stop timers
    213         self.save_state_timer.stop()
    214         self.save_resume_data_timer.stop()
     213        if self.save_state_timer.running:
     214            self.save_state_timer.stop()
     215
     216        if self.save_resume_data_timer.running:
     217            self.save_resume_data_timer.stop()
    215218
    216219        # Save state on shutdown
  • deluge/event.py

    r535940 r8a6ec7  
    4242"""
    4343
     44event_list = []
     45
     46class DelugeEventMetaClass(type):
     47    """
     48    This metaclass simply keeps a list of all events classes created.
     49    """
     50    def __init__(cls, name, bases, dct):
     51        event_list.append(name)
     52        super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
     53
    4454class DelugeEvent(object):
    4555    """
     
    5060
    5161    """
     62    __metaclass__ = DelugeEventMetaClass
     63
    5264    def _get_name(self):
    5365        return self.__class__.__name__
  • deluge/pluginmanagerbase.py

    r535940 r8a6ec7  
    8888        # Disable all plugins that are enabled
    8989        for key in self.plugins.keys():
    90             self.plugins[key].disable()
     90            self.disable_plugin(key)
    9191
    9292    def __getitem__(self, key):
     
    154154        try:
    155155            self.plugins[name].disable()
     156            component.deregister(self.plugins[name].plugin.get_component_name())
    156157            del self.plugins[name]
    157158            self.config["enabled_plugins"].remove(name)
  • deluge/plugins/blocklist/blocklist/common.py

    r535940 r8a6ec7  
    5050        return new
    5151    return safer
     52
     53def remove_zeros(ip):
     54    """
     55    Removes unneeded zeros from ip addresses.
     56   
     57    Example: 000.000.000.003 -> 0.0.0.3
     58   
     59    :param ip: the ip address
     60    :type ip: string
     61   
     62    :returns: the ip address without the unneeded zeros
     63    :rtype: string
     64   
     65    """
     66    return ".".join([part.lstrip("0").zfill(1) for part in ip.split(".")])
  • deluge/plugins/blocklist/blocklist/core.py

    r535940 r8a6ec7  
    129129        self.failed_attempts = 0
    130130        self.auto_detected = False
     131        if force:
     132            self.reader = None
    131133
    132134        # Start callback chain
     
    219221            headers['If-Modified-Since'] = self.config["last_update"]
    220222
    221         log.debug("Attempting to download blocklist %s" % url)
    222         log.debug("Sending headers: %s" % headers)
     223        log.debug("Attempting to download blocklist %s", url)
     224        log.debug("Sending headers: %s", headers)
    223225        self.up_to_date = False
    224226        self.is_downloading = True
     
    240242            location = error_msg.split(" to ")[1]
    241243            if "Moved Permanently" in error_msg:
    242                 log.debug("Setting blocklist url to %s" % location)
     244                log.debug("Setting blocklist url to %s", location)
    243245                self.config["url"] = location
    244246            f.trap(f.type)
     
    292294            self.auto_detected = True
    293295
    294         log.debug("Importing using reader: %s",self.reader)
     296        log.debug("Importing using reader: %s", self.reader)
    295297        log.debug("Reader type: %s compression: %s", self.config["list_type"], self.config["list_compression"])
    296298        d = threads.deferToThread(self.reader(blocklist).read, on_read_ip_range)
     
    328330           # If we have a backup and we haven't already used it
    329331            e = f.trap(Exception)
    330             log.warning("Error reading blocklist: ", e)
     332            log.warning("Error reading blocklist: %s", e)
    331333            self.use_cache = True
    332334            try_again = True
     
    348350        self.config["list_compression"] = detect_compression(blocklist)
    349351        self.config["list_type"] = detect_format(blocklist, self.config["list_compression"])
    350         log.debug("Auto-detected type: %s compression: %s", self.config["list_type"],  self.config["list_compression"])
     352        log.debug("Auto-detected type: %s compression: %s", self.config["list_type"], self.config["list_compression"])
    351353        if not self.config["list_type"]:
    352354            self.config["list_compression"] = ""
  • deluge/plugins/blocklist/blocklist/detect.py

    r535940 r8a6ec7  
    7878        if decompressor:
    7979            reader = decompressor(reader)
    80            
    8180    return reader
  • deluge/plugins/blocklist/blocklist/readers.py

    r535940 r8a6ec7  
    3434#
    3535
    36 from deluge.log import LOG as log
    37 from common import raiseError
     36from common import raiseError, remove_zeros
     37import re
    3838
    39 def remove_zeros(ip):
    40     """
    41     Removes unneeded zeros from ip addresses.
    42    
    43     Example: 000.000.000.003 -> 0.0.0.3
    44    
    45     :param ip: the ip address
    46     :type ip: string
    47    
    48     :returns: the ip address without the unneeded zeros
    49     :rtype: string
    50    
    51     """
    52     new_ip = []
    53     for part in ip.split("."):
    54         while part[0] == "0" and len(part) > 1:
    55             part = part[1:]
    56         new_ip.append(part)
    57     return ".".join(new_ip)
    58    
    5939class ReaderParseError(Exception):
    6040    pass
     
    9171                try:
    9272                    (start, end) = self.parse(line)
     73                    if not re.match("^(\d{1,3}\.){4}$", start + ".") or \
     74                       not re.match("^(\d{1,3}\.){4}$", end + "."):
     75                        valid = False
    9376                except:
    9477                    valid = False
     
    11699    @raiseError(ReaderParseError)
    117100    def parse(self, line):
    118         return line.strip().split(":")[1].split("-")
     101        return line.strip().split(":")[-1].split("-")
    119102
    120103class PeerGuardianReader(SafePeerReader):
  • deluge/ui/console/main.py

    r535940 r8a6ec7  
    250250        """
    251251        self.batch_write = batch
    252         if not batch:
     252        if not batch and self.interactive:
    253253            self.screen.refresh()
    254254
  • deluge/ui/gtkui/common.py

    r535940 r8a6ec7  
    3535
    3636"""Common functions for various parts of gtkui to use."""
     37
     38import os
    3739
    3840import pygtk
  • deluge/ui/gtkui/glade/add_torrent_dialog.glade

    r535940 r8a6ec7  
    44  <!-- interface-naming-policy toplevel-contextual -->
    55  <widget class="GtkDialog" id="dialog_add_torrent">
    6     <property name="height_request">560</property>
    76    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    87    <property name="border_width">5</property>
     
    1514        <property name="visible">True</property>
    1615        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     16        <property name="orientation">vertical</property>
    1717        <property name="spacing">2</property>
    1818        <child>
     
    2121            <property name="can_focus">True</property>
    2222            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     23            <property name="orientation">vertical</property>
    2324            <child>
    2425              <widget class="GtkFrame" id="frame2">
     
    3839                        <property name="visible">True</property>
    3940                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     41                        <property name="orientation">vertical</property>
    4042                        <child>
    4143                          <widget class="GtkScrolledWindow" id="scrolledwindow1">
     
    346348                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
    347349                    <property name="border_width">5</property>
     350                    <property name="orientation">vertical</property>
    348351                    <property name="spacing">5</property>
    349352                    <child>
     
    426429                                    <property name="visible">True</property>
    427430                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     431                                    <property name="orientation">vertical</property>
    428432                                    <child>
    429433                                      <widget class="GtkRadioButton" id="radio_full">
     
    658662                                    <property name="visible">True</property>
    659663                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     664                                    <property name="orientation">vertical</property>
    660665                                    <property name="spacing">5</property>
    661666                                    <child>
     
    902907              </widget>
    903908              <packing>
     909                <property name="expand">False</property>
     910                <property name="fill">False</property>
    904911                <property name="position">0</property>
    905912              </packing>
     
    916923              </widget>
    917924              <packing>
     925                <property name="expand">False</property>
     926                <property name="fill">False</property>
    918927                <property name="position">1</property>
    919928              </packing>
     
    943952        <property name="visible">True</property>
    944953        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     954        <property name="orientation">vertical</property>
    945955        <property name="spacing">2</property>
    946956        <child>
     
    948958            <property name="visible">True</property>
    949959            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     960            <property name="orientation">vertical</property>
    950961            <property name="spacing">5</property>
    951962            <child>
     
    10541065              </widget>
    10551066              <packing>
     1067                <property name="expand">False</property>
     1068                <property name="fill">False</property>
    10561069                <property name="position">0</property>
    10571070              </packing>
     
    10701083              </widget>
    10711084              <packing>
     1085                <property name="expand">False</property>
     1086                <property name="fill">False</property>
    10721087                <property name="position">1</property>
    10731088              </packing>
     
    10971112        <property name="visible">True</property>
    10981113        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     1114        <property name="orientation">vertical</property>
    10991115        <property name="spacing">2</property>
    11001116        <child>
     
    11021118            <property name="visible">True</property>
    11031119            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     1120            <property name="orientation">vertical</property>
    11041121            <property name="spacing">5</property>
    11051122            <child>
     
    12471264              </widget>
    12481265              <packing>
     1266                <property name="expand">False</property>
     1267                <property name="fill">False</property>
    12491268                <property name="position">0</property>
    12501269              </packing>
     
    12631282              </widget>
    12641283              <packing>
     1284                <property name="expand">False</property>
     1285                <property name="fill">False</property>
    12651286                <property name="position">1</property>
    12661287              </packing>
  • deluge/ui/gtkui/gtkui.py

    r535940 r8a6ec7  
    310310                                    _("Error Starting Daemon"),
    311311                                    _("There was an error starting the daemon process.  Try running it from a console to see if there is an error.")).run()
    312                                
    313                         # We'll try 30 reconnects at 500ms intervals
    314                         try_counter = 30
    315                        
     312
    316313                        def on_connect(connector):
    317314                            component.start()
     
    324321                                import time
    325322                                time.sleep(0.5)
    326                                 do_connect()
     323                                do_connect(try_counter)
    327324                            return result
    328                            
    329                         def do_connect():
     325
     326                        def do_connect(try_counter):
    330327                            client.connect(*host[1:]).addCallback(on_connect).addErrback(on_connect_fail, try_counter)
    331                                                    
     328
    332329                        if try_connect:
    333                             do_connect()
    334                                                    
     330                            do_connect(6)
     331                    break
    335332
    336333            if self.config["show_connection_manager_on_start"]:
  • deluge/ui/gtkui/ipcinterface.py

    r535940 r8a6ec7  
    3636
    3737import sys
    38 import os.path
     38import os
    3939import base64
    4040
     
    105105                sys.exit(0)
    106106        else:
     107            lockfile = socket + ".lock"
     108            log.debug("Checking if lockfile exists: %s", lockfile)
     109            if os.path.lexists(lockfile):
     110                try:
     111                    os.kill(int(os.readlink(lockfile)), 0)
     112                except OSError:
     113                    log.debug("Removing lockfile since it's stale.")
     114                    try:
     115                        os.remove(lockfile)
     116                        os.remove(socket)
     117                    except Exception, e:
     118                        log.error("Problem deleting lockfile or socket file!")
     119                        log.exception(e)
     120
    107121            try:
    108122                self.factory = Factory()
  • deluge/ui/web/index.html

    r535940 r8a6ec7  
    22<html xmlns="http://www.w3.org/1999/xhtml">
    33    <head>
    4         <title>Deluge: Web UI (alpha) ${version}</title>
     4        <title>Deluge: Web UI ${version}</title>
    55       
    66        <link rel="shortcut icon" href="/icons/deluge.png" type="image/png" />
Note: See TracChangeset for help on using the changeset viewer.