~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to duplicity/progress.py

  • Committer: Kenneth Loafman
  • Date: 2014-12-12 14:39:54 UTC
  • Revision ID: kenneth@loafman.com-20141212143954-wyln65yd1ynzsrlx
* Source formatted, using PyDev, all source files to fix some easily fixed
  PEP8 issues. Use ignore space when comparing against previous versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        progressfd.close()
81
81
 
82
82
 
83
 
    def __init__(self, iterable = [], maxlen = 10):
 
83
    def __init__(self, iterable=[], maxlen=10):
84
84
        super(Snapshot, self).__init__(iterable, maxlen)
85
85
        self.last_vol = 0
86
86
 
163
163
        if self.stall_last_time is None:
164
164
            self.stall_last_time = current_time
165
165
        if (current_time - self.stall_last_time).seconds > max(5, 2 * globals.progress_rate):
166
 
            log.TransferProgress(100.0 * self.progress_estimation, 
167
 
                                    self.time_estimation, self.total_bytecount, 
 
166
            log.TransferProgress(100.0 * self.progress_estimation,
 
167
                                    self.time_estimation, self.total_bytecount,
168
168
                                    (current_time - self.start_time).seconds,
169
 
                                    self.speed, 
 
169
                                    self.speed,
170
170
                                    True
171
171
                                )
172
172
            return
199
199
            # Compute mean ratio of data transfer, estimating unknown progress
200
200
            change_ratio = float(self.total_bytecount) / float(diffdir.stats.RawDeltaSize)
201
201
            change_delta = change_ratio - self.change_mean_ratio
202
 
            self.change_mean_ratio += change_delta / float(self.nsteps) # mean cumulated ratio
 
202
            self.change_mean_ratio += change_delta / float(self.nsteps)  # mean cumulated ratio
203
203
            self.change_r_estimation += change_delta * (change_ratio - self.change_mean_ratio)
204
204
            change_sigma = math.sqrt(math.fabs(self.change_r_estimation / float(self.nsteps)))
205
205
        
210
210
                Use 50% confidence interval lower bound during first half of the progression. Conversely, use 50% C.I. upper bound during
211
211
                the second half. Scale it to the changes/total ratio
212
212
            """
213
 
            self.current_estimation = float(changes) / float(total_changes) * ( 
 
213
            self.current_estimation = float(changes) / float(total_changes) * (
214
214
                                            (self.change_mean_ratio - 0.67 * change_sigma) * (1.0 - self.current_estimation) + 
215
215
                                            (self.change_mean_ratio + 0.67 * change_sigma) * self.current_estimation 
216
216
                                        )
218
218
            In case that we overpassed the 100%, drop the confidence and trust more the mean as the sigma may be large.
219
219
            """
220
220
            if self.current_estimation > 1.0:
221
 
                self.current_estimation = float(changes) / float(total_changes) * ( 
 
221
                self.current_estimation = float(changes) / float(total_changes) * (
222
222
                                                (self.change_mean_ratio - 0.33 * change_sigma) * (1.0 - self.current_estimation) + 
223
223
                                                (self.change_mean_ratio + 0.33 * change_sigma) * self.current_estimation 
224
224
                                            )
238
238
        """
239
239
        Estimate the time just as a projection of the remaining time, fit to a [(1 - x) / x] curve
240
240
        """
241
 
        self.elapsed_sum += elapsed # As sum of timedeltas, so as to avoid clock skew in long runs (adding also microseconds)
 
241
        self.elapsed_sum += elapsed  # As sum of timedeltas, so as to avoid clock skew in long runs (adding also microseconds)
242
242
        projection = 1.0
243
243
        if self.progress_estimation > 0:
244
244
            projection = (1.0 - self.progress_estimation) / self.progress_estimation
260
260
        for x in self.transfers:
261
261
            self.speed = 0.3 * x + 0.7 * self.speed
262
262
 
263
 
        log.TransferProgress(100.0 * self.progress_estimation, 
264
 
                                self.time_estimation, 
265
 
                                self.total_bytecount, 
266
 
                                (current_time - self.start_time).seconds, 
 
263
        log.TransferProgress(100.0 * self.progress_estimation,
 
264
                                self.time_estimation,
 
265
                                self.total_bytecount,
 
266
                                (current_time - self.start_time).seconds,
267
267
                                self.speed,
268
268
                                False
269
269
                            )
277
277
        volume and for the current volume
278
278
        """
279
279
        changing = max(bytecount - self.last_bytecount, 0)
280
 
        self.total_bytecount += int(changing) # Annotate only changing bytes since last probe
 
280
        self.total_bytecount += int(changing)  # Annotate only changing bytes since last probe
281
281
        self.last_bytecount = bytecount
282
282
        if changing > 0:
283
283
            self.stall_last_time = datetime.now()