Changeset 169b9b


Ignore:
Timestamp:
01/17/2014 07:17:18 PM (12 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Branches:
2.0.x, develop, master
Children:
2b64d7
Parents:
0da6739
git-author:
Calum Lind <calumlind+deluge@gmail.com> (11/20/2013 11:55:22 PM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (01/17/2014 07:17:18 PM)
Message:

Fixes for #607 : Add completed_time to core and Completed column in GTK UI

Location:
deluge
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • deluge/core/torrent.py

    r0da6739 r169b9b  
    5555log = logging.getLogger(__name__)
    5656
     57
    5758def sanitize_filepath(filepath, folder=False):
    5859    """
     
    7980    else:
    8081        return newfilepath
     82
    8183
    8284class TorrentOptions(dict):
     
    106108        self["mapped_files"] = {}
    107109
     110
    108111class Torrent(object):
    109112    """Torrent holds information about torrents added to the libtorrent session.
     
    382385    def set_trackers(self, trackers):
    383386        """Sets trackers"""
    384         if trackers == None:
     387        if trackers is None:
    385388            trackers = []
    386389            for value in self.handle.trackers():
     
    575578        file_progress = self.handle.file_progress()
    576579        ret = []
    577         for i,f in enumerate(self.get_files()):
     580        for i, f in enumerate(self.get_files()):
    578581            try:
    579582                ret.append(float(file_progress[i]) / float(f["size"]))
     
    681684            "all_time_download":      lambda: self.status.all_time_download,
    682685            "compact":                lambda: self.options["compact_allocation"],
    683             "distributed_copies":     lambda: 0.0 if self.status.distributed_copies < 0 else \
    684                 self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
     686            "distributed_copies":     lambda: 0.0 if self.status.distributed_copies < 0 else
     687            self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
    685688            "download_payload_rate":  lambda: self.status.download_payload_rate,
    686689            "file_priorities":        lambda: self.options["file_priorities"],
     
    709712            "save_path":              lambda: self.options["download_location"],
    710713            "seeding_time":           lambda: self.status.seeding_time,
    711             "seeds_peers_ratio":      lambda: -1.0 if self.status.num_incomplete == 0 else \
    712                 self.status.num_complete / float(self.status.num_incomplete), # Use -1.0 to signify infinity
     714            "seeds_peers_ratio":      lambda: -1.0 if self.status.num_incomplete == 0 else
     715            self.status.num_complete / float(self.status.num_incomplete), # Use -1.0 to signify infinity
    713716            "seed_rank":              lambda: self.status.seed_rank,
    714717            "state":                  lambda: self.state,
     
    735738            "total_size":             lambda: self.torrent_info.total_size() if self.has_metadata else 0,
    736739            "eta":                    self.get_eta,
    737             "file_progress":          self.get_file_progress, # Adjust progress to be 0-100 value
     740            "file_progress":          self.get_file_progress,  # Adjust progress to be 0-100 value
    738741            "files":                  self.get_files,
    739742            "is_seed":                lambda: self.status.is_seeding,
     
    742745            "ratio":                  self.get_ratio,
    743746            "tracker_host":           self.get_tracker_host,
     747            "completed_time":         lambda: self.status.completed_time,
    744748            "last_seen_complete":     lambda: self.status.last_seen_complete,
    745749            "name":                   self.get_name,
    746750            "pieces":                 self._get_pieces_info,
    747 
    748             }
     751        }
    749752
    750753    def get_name(self):
  • deluge/ui/gtkui/torrentview.py

    r0da6739 r169b9b  
    5454
    5555log = logging.getLogger(__name__)
     56
    5657
    5758def queue_peer_seed_sort_function(v1, v2):
     
    6667    if v2 > v1:
    6768        return -1
     69
    6870
    6971def queue_column_sort(model, iter1, iter2, data):
     
    8789        return -1
    8890
     91
    8992def seed_peer_column_sort(model, iter1, iter2, data):
    9093    v1 = model[iter1][data]         # num seeds/peers
     
    9699    return queue_peer_seed_sort_function(v1, v3)
    97100
     101
    98102class SearchBox(object):
    99103    def __init__(self, torrentview):
     
    183187                self.prefiltered.pop(self.prefiltered.index(torrent_id))
    184188                row[filter_column] = not row[filter_column]
    185 
    186189
    187190            if not row[filter_column]:
     
    295298        self.add_func_column(_("Added"), funcs.cell_data_date, [float],
    296299                             status_field=["time_added"], default=False)
     300        self.add_func_column(_("Completed"),
     301                             funcs.cell_data_date_or_never, [float],
     302                             status_field=["completed_time"], default=False)
    297303        self.add_func_column(_("Last Seen Complete"),
    298304                             funcs.cell_data_date_or_never, [float],
     
    394400        self.treeview.get_selection().unselect_all()
    395401        search_filter = self.filter and self.filter.get('name', None) or None
    396         self.filter = dict(filter_dict) #copied version of filter_dict.
     402        self.filter = dict(filter_dict)  # Copied version of filter_dict.
    397403        if search_filter and 'name' not in filter_dict:
    398404            self.filter['name'] = search_filter
     
    412418            # If not, we can ignore it.
    413419            if self.columns[column].column.get_visible() is True \
    414                 and self.columns[column].hidden is False \
    415                 and self.columns[column].status_field is not None:
     420                    and self.columns[column].hidden is False \
     421                    and self.columns[column].status_field is not None:
    416422                for field in self.columns[column].status_field:
    417423                    status_keys.append(field)
     
    479485                    # The status dict is the same, so do nothing to update for this torrent
    480486                    continue
    481             except KeyError, e:
     487            except KeyError:
    482488                pass
    483489
     
    540546                break
    541547
    542     def mark_dirty(self, torrent_id = None):
     548    def mark_dirty(self, torrent_id=None):
    543549        for row in self.liststore:
    544550            if not torrent_id or row[self.columns["torrent_id"].column_indices[0]] == torrent_id:
    545551                #log.debug("marking %s dirty", torrent_id)
    546552                row[self.columns["dirty"].column_indices[0]] = True
    547                 if torrent_id: break
     553                if torrent_id:
     554                    break
    548555
    549556    def get_selected_torrent(self):
     
    611618
    612619            if self.get_selected_torrents():
    613                 if self.model_filter.get_value(row, self.columns["torrent_id"].column_indices[0]) not in self.get_selected_torrents():
     620                if self.model_filter.get_value(row, self.columns["torrent_id"].column_indices[0]) \
     621                        not in self.get_selected_torrents():
    614622                    self.treeview.get_selection().unselect_all()
    615623                    self.treeview.get_selection().select_iter(row)
Note: See TracChangeset for help on using the changeset viewer.