コード例 #1
0
 def _read_metainfo(self, infohash):
     path = os.path.join(self.data_dir, 'metainfo',
                         infohash.encode('hex'))
     f = file(path, 'rb')
     data = f.read()
     f.close()
     return ConvertedMetainfo(bdecode(data))
コード例 #2
0
ファイル: MultiTorrent.py プロジェクト: hitzjd/DHT
 def create_torrent_non_suck(self,
                             torrent_filename,
                             path_to_data,
                             hidden=False,
                             feedback=None):
     data = open(torrent_filename, 'rb').read()
     metainfo = ConvertedMetainfo(bdecode(data))
     return self.create_torrent(metainfo,
                                path_to_data,
                                path_to_data,
                                hidden=hidden,
                                feedback=feedback)
コード例 #3
0
def get(arg):
    """Obtains the contents of the .torrent metainfo file either from
       the local filesystem or from a remote server. 'arg' is either
       a filename or an URL.

       Returns a ConvertedMetainfo object which is the parsed metainfo
       from the contents of the .torrent file.  Any exception raised
       while obtaining the .torrent file or parsing its contents is
       caught and wrapped in one of the following errors:
       GetTorrent.URLException, GetTorrent.FileException, 
       GetTorrent.MetainfoException, or GetTorrent.UnknownArgument.
       (All have the base class GetTorrent.GetTorrentException)
       """
    data = _get(arg)
    metainfo = None
    try:
        b = bdecode(data)
        metainfo = ConvertedMetainfo(b)
    except Exception, e:
        raise MetainfoException(
            (_('"%s" is not a valid torrent file (%s).') % (arg, unicode(e))))
コード例 #4
0
ファイル: parsedir.py プロジェクト: galaxy001/libtorrent
def like_gettorrent(path):
    data = open(path, 'rb').read()
    b = bdecode(data)
    metainfo = ConvertedMetainfo(b)
    return metainfo
コード例 #5
0
        df = ThreadedDeferred(wrap_task(self.rawserver.external_add_task),
                              self._get_signature, installer_url)
        yield df
        signature = df.getResult()

        if torrentfile and signature:
            df = ThreadedDeferred(wrap_task(self.rawserver.external_add_task),
                                  self._check_signature, torrentfile,
                                  signature)
            yield df
            checked = df.getResult()
            if checked:
                self.debug(debug_prefix + 'signature verified successfully.')
                b = bdecode(torrentfile)
                metainfo = ConvertedMetainfo(b)
                infohash = metainfo.infohash
                self.available_version = available_version

                self.multitorrent.remove_auto_updates_except(infohash)

                try:
                    df = self.multitorrent.create_torrent(metainfo,
                                                          installer_path,
                                                          installer_path,
                                                          hidden=True,
                                                          is_auto_update=True)
                    yield df
                    df.getResult()
                except TorrentAlreadyRunning:
                    self.debug(debug_prefix +
コード例 #6
0
ファイル: fileutils.py プロジェクト: skn/floodgate
def metainfo_from_file(f):
    metainfo = ConvertedMetainfo(bdecode(f))
    return metainfo