Убрал ненужныем методы SavePath()

sandbox1
inpos 2016-03-10 10:21:17 +03:00
parent 1e22099b28
commit 5c8a26b985
1 changed files with 10 additions and 12 deletions

View File

@ -139,7 +139,7 @@ class TorrentFile(object):
tfs = None tfs = None
num = int() num = int()
closed = True closed = True
savePath = str() save_path = str()
fileEntry = None fileEntry = None
index = int() index = int()
filePtr = None filePtr = None
@ -151,15 +151,13 @@ class TorrentFile(object):
self.fileEntry = fileEntry self.fileEntry = fileEntry
self.name = self.Name() self.name = self.Name()
self.unicode_name = self.name.decode(chardet.detect(self.name)['encoding']) self.unicode_name = self.name.decode(chardet.detect(self.name)['encoding'])
self.savePath = savePath self.save_path = savePath
self.index = index self.index = index
self.piece_length = int(self.pieceLength()) self.piece_length = int(self.pieceLength())
self.startPiece, self.endPiece = self.Pieces() self.startPiece, self.endPiece = self.Pieces()
self.pieces_deadlined = [False for x in range(self.endPiece - self.startPiece)] self.pieces_deadlined = [False for x in range(self.endPiece - self.startPiece)]
self.offset = self.Offset() self.offset = self.Offset()
self.size = self.Size() self.size = self.Size()
def SavePath(self):
return self.savePath
def Index(self): def Index(self):
return tf.index return tf.index
def Downloaded(self): def Downloaded(self):
@ -171,10 +169,10 @@ class TorrentFile(object):
return None return None
if self.filePtr is None: if self.filePtr is None:
#print('savePath: %s' % (self.savePath,)) #print('savePath: %s' % (self.savePath,))
while not os.path.exists(self.savePath): while not os.path.exists(self.save_path):
logging.info('Waiting: %s' % (self.savePath,)) logging.info('Waiting: %s' % (self.save_path,))
time.sleep(0.5) time.sleep(0.5)
self.filePtr = io.open(self.savePath, 'rb') self.filePtr = io.open(self.save_path, 'rb')
return self.filePtr return self.filePtr
def log(self, message): def log(self, message):
fnum = self.num fnum = self.num
@ -300,11 +298,13 @@ class TorrentFS(object):
shuttingDown = False shuttingDown = False
fileCounter = int() fileCounter = int()
progresses = list() progresses = list()
save_path = None
def __init__(self, root, handle, startIndex): def __init__(self, root, handle, startIndex):
self.root = root self.root = root
self.handle = handle self.handle = handle
self.waitForMetadata() self.waitForMetadata()
self.save_path = localize_path(self.root.torrentParams['save_path'])
self.priorities = [[i, p] for i,p in enumerate(self.handle.file_priorities())] self.priorities = [[i, p] for i,p in enumerate(self.handle.file_priorities())]
if startIndex < 0: if startIndex < 0:
logging.info('No -file-index specified, downloading will be paused until any file is requested') logging.info('No -file-index specified, downloading will be paused until any file is requested')
@ -369,15 +369,13 @@ class TorrentFS(object):
file_.progress = float(file_.downloaded)/float(file_.Size()) file_.progress = float(file_.downloaded)/float(file_.Size())
files[i] = file_ files[i] = file_
return files return files
def SavePath(self):
return self.root.torrentParams['save_path']
def FileAt(self, index): def FileAt(self, index):
info = self.TorrentInfo() info = self.TorrentInfo()
if index < 0 or index >= info.num_files(): if index < 0 or index >= info.num_files():
raise IndexError raise IndexError
fileEntry = info.file_at(index) fileEntry = info.file_at(index)
fe_path = fileEntry.path fe_path = fileEntry.path
path = os.path.abspath(os.path.join(self.SavePath(), localize_path(fe_path))) path = os.path.abspath(os.path.join(self.save_path, localize_path(fe_path)))
return TorrentFile( return TorrentFile(
self, self,
fileEntry, fileEntry,
@ -385,9 +383,9 @@ class TorrentFS(object):
index index
) )
def FileByName(self, name): def FileByName(self, name):
savePath = os.path.abspath(os.path.join(self.SavePath(), localize_path(name))) savePath = os.path.abspath(os.path.join(self.save_path, localize_path(name)))
for file_ in self.Files(): for file_ in self.Files():
if file_.savePath == savePath: if file_.save_path == savePath:
return file_ return file_
raise IOError raise IOError
def Open(self, name): def Open(self, name):