comparison src/plugins/plugin_misc_file.py @ 1598:b144babc2658

core, plugin file: fixed progress id + data is now returned by getProgress, instead of being an argument to fill
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:20:33 +0100
parents 846a39900fa6
children e0a152f2cf6d
comparison
equal deleted inserted replaced
1597:91a605feed8c 1598:b144babc2658
64 @param size(None, int): size of the file 64 @param size(None, int): size of the file
65 """ 65 """
66 self.host = host 66 self.host = host
67 self.uid = uid or unicode(uuid.uuid4()) 67 self.uid = uid or unicode(uuid.uuid4())
68 self._file = open(path, mode) 68 self._file = open(path, mode)
69 self.size = None 69 self.size = size
70 self.profile = profile 70 self.profile = profile
71 self.eof = defer.Deferred() 71 self.eof = defer.Deferred()
72 self.host.registerProgressCb(self.uid, self.getProgress, profile) 72 self.host.registerProgressCb(self.uid, self.getProgress, profile)
73 self.host.bridge.progressStarted(self.uid, self.profile) 73 self.host.bridge.progressStarted(self.uid, self.profile)
74 self.eof.addCallback(lambda ignore: self.host.bridge.progressFinished(self.uid, self.profile)) 74 self.eof.addCallback(lambda ignore: self.host.bridge.progressFinished(self.uid, self.profile))
94 self._file.seek(offset, whence) 94 self._file.seek(offset, whence)
95 95
96 def tell(self): 96 def tell(self):
97 return self._file.tell() 97 return self._file.tell()
98 98
99 def getProgress(self, progress_id, data, profile): 99 def getProgress(self, progress_id, profile):
100 return {'position': self._file.tell(), 'size': self.size or 0} 100 return {'position': self._file.tell(), 'size': self.size or -1}
101 101
102 102
103 class FilePlugin(object): 103 class FilePlugin(object):
104 File=SatFile 104 File=SatFile
105 105