Example #1
0
    def is_private(self):
        """ Returns whether this TorrentDef is a private torrent.
        @return Boolean """
        if not self.metainfo_valid:
            raise NotYetImplementedException()

        return int(self.metainfo['info'].get('private', 0)) == 1
Example #2
0
    def is_multifile_torrent(self):
        """ Returns whether this TorrentDef is a multi-file torrent.
        @return Boolean
        """
        if not self.metainfo_valid:
            raise NotYetImplementedException()  # must save first

        return 'files' in self.metainfo['info']
Example #3
0
    def resume_download_from_file(self, filename):
        """
        Recreates Download from resume file

        @return a Download object.

        Note: this cannot be made into a method of Download, as the Download
        needs to be bound to a session, it cannot exist independently.
        """
        raise NotYetImplementedException()
Example #4
0
    def get_length(self, selectedfiles=None):
        """ Returns the total size of the content in the torrent. If the
        optional selectedfiles argument is specified, the method returns
        the total size of only those files.
        @return A length (long)
        """
        if not self.metainfo_valid:
            raise NotYetImplementedException()  # must save first

        return maketorrent.get_length_from_metainfo(self.metainfo, selectedfiles)
Example #5
0
    def get_index_of_file_in_files(self, file):
        if not self.metainfo_valid:
            raise NotYetImplementedException()  # must save first

        info = self.metainfo['info']

        if file is not None and 'files' in info:
            for i in range(len(info['files'])):
                x = info['files'][i]

                intorrentpath = maketorrent.pathlist2filename(x['path'])
                if intorrentpath == file:
                    return i
            return ValueError("File not found in torrent")
        else:
            raise ValueError("File not found in single-file torrent")
Example #6
0
    def get_files_with_length(self, exts=None):
        """ The list of files in the finalized torrent def.
        @param exts (Optional) list of filename extensions (without leading .)
        to search for.
        @return A list of filenames.
        """
        if not self.metainfo_valid:
            raise NotYetImplementedException()  # must save first

        videofiles = []
        for filename, length in self._get_all_files_as_unicode_with_length():
            prefix, ext = os.path.splitext(filename)
            if ext != "" and ext[0] == ".":
                ext = ext[1:]
            if exts is None or ext.lower() in exts:
                videofiles.append((filename, length))
        return videofiles
Example #7
0
    def create_source_item(self, source):
        """
        put the source object in the sourcelist available for enable/disable
        """
        item_count = self.GetItemCount()

        if isinstance(source, RSSFeedSource):

            # update label for directory as we pushed it down
            self.InsertStringItem(self.labels[1], source.get_source_text(), 1)
            item = self.GetItem(self.labels[1])
            item.Check(source.enabled)
            item.SetData(source)
            self.SetItem(item)
            self.labels[1] += 1
            self.labels[2] += 1
        elif isinstance(source, DirectorySource):
            self.InsertStringItem(self.labels[2], source.get_source_text(), 1)
            item = self.GetItem(self.labels[2])
            item.Check(source.enabled)
            item.SetData(source)
            self.SetItem(item)
            self.labels[2] += 1
        elif isinstance(source, ChannelSource):
            self.InsertStringItem(self.labels[2] + 1,
                                  source.get_source_text() or "Loading..", 1)
            item = self.GetItem(self.labels[2] + 1)
            item.Check(source.enabled)
            item.SetData(source)
            self.SetItem(item)

            self.channel_list[source.source] = source
        elif isinstance(source, Channel):
            # channel can't be 'added'. Initialization only
            self.InsertStringItem(item_count, source.name, 1)
            self.SetItemData(item_count, source)
        else:
            raise NotYetImplementedException('Source type unknown')
Example #8
0
 def upload_speed_callback(self, speed):
     raise NotYetImplementedException()
Example #9
0
    def get_creation_date(self, default=0):
        if not self.metainfo_valid:
            raise NotYetImplementedException()  # must save first

        return self.metainfo.get("creation date", default)
Example #10
0
 def test_not_yet_implemented_exception(self):
     raise NotYetImplementedException("NotYetImplementedException")
Example #11
0
    def create_header_info(self, parent):
        """
        function to create wx header/info panel above the credit mining list
        """
        if self.guiutility.frame.top_bg:
            header = FancyPanel(parent, border=wx.BOTTOM, name="cm_header")
            text = wx.StaticText(header, -1, 'Investment overview')

            def on_add_source(_):
                """
                callback when a user wants to add new source
                """
                dlg = AddBoostingSource(None)
                if dlg.ShowModal() == wx.ID_OK:
                    source, archive = dlg.get_value()
                    if source:
                        self.boosting_manager.add_source(source)
                        self.boosting_manager.set_archive(source, archive)

                        self.sourcelist.create_source_item(
                            self.boosting_manager.boosting_sources[source])

                dlg.Destroy()

            def on_remove_source(_):
                """
                callback when a user wants to remove source
                """
                dlg = RemoveBoostingSource(None)
                if dlg.ShowModal() == wx.ID_OK and dlg.get_value():
                    self.boosting_manager.remove_source(dlg.get_value())
                    self.sourcelist.refresh_sourcelist_data()
                dlg.Destroy()

            addsource = LinkStaticText(header, 'Add', icon=None)
            addsource.Bind(wx.EVT_LEFT_UP, on_add_source)
            removesource = LinkStaticText(header, 'Remove', icon=None)
            removesource.Bind(wx.EVT_LEFT_UP, on_remove_source)

            self.b_up = wx.StaticText(header,
                                      -1,
                                      'Total bytes up: -',
                                      name="b_up")
            self.b_down = wx.StaticText(header,
                                        -1,
                                        'Total bytes down: -',
                                        name="b_down")
            self.s_up = wx.StaticText(header,
                                      -1,
                                      'Total speed up: -',
                                      name="s_up")
            self.s_down = wx.StaticText(header,
                                        -1,
                                        'Total speed down: -',
                                        name="s_down")
            self.iv_sum = wx.StaticText(header,
                                        -1,
                                        'Investment summary: -',
                                        name="iv_sum")
            _set_font(text, size_increment=2, fontweight=wx.FONTWEIGHT_BOLD)
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.AddStretchSpacer()
            titlesizer = wx.BoxSizer(wx.HORIZONTAL)
            titlesizer.Add(text, 0, wx.ALIGN_BOTTOM | wx.RIGHT, 5)
            titlesizer.Add(wx.StaticText(header, -1, '('), 0, wx.ALIGN_BOTTOM)
            titlesizer.Add(addsource, 0, wx.ALIGN_BOTTOM)
            titlesizer.Add(wx.StaticText(header, -1, '/'), 0, wx.ALIGN_BOTTOM)
            titlesizer.Add(removesource, 0, wx.ALIGN_BOTTOM)
            titlesizer.Add(wx.StaticText(header, -1, ' boosting source)'), 0,
                           wx.ALIGN_BOTTOM)
            sizer.Add(titlesizer, 0, wx.LEFT | wx.BOTTOM, 5)
            sizer.Add(self.b_up, 0, wx.LEFT, 5)
            sizer.Add(self.b_down, 0, wx.LEFT, 5)
            sizer.Add(self.s_up, 0, wx.LEFT, 5)
            sizer.Add(self.s_down, 0, wx.LEFT, 5)
            sizer.Add(self.iv_sum, 0, wx.LEFT, 5)
            sizer.AddStretchSpacer()
            header.SetSizer(sizer)
            header.SetMinSize((-1, 100))
        else:
            raise NotYetImplementedException('')

        return header