~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to duplicity/dup_temp.py

  • Committer: kenneth at loafman
  • Date: 2019-06-11 15:52:04 UTC
  • mfrom: (1372.2.8 0-7-snap-duplicity)
  • Revision ID: kenneth@loafman.com-20190611155204-ck3otzhy9d3x8kxv
* Merged in lp:~aaron-whitehouse/duplicity/07-snap
  - Add snapcraft packaging instructions for 0.7 series

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
"""Manage temporary files"""
23
23
 
24
 
import os, sys
 
24
import os
 
25
import sys
 
26
import shutil
25
27
 
26
28
from duplicity import log
27
29
from duplicity import util
183
185
        elif pr.encrypted:
184
186
            gpg.GPGWriteFile(src_iter, tgt.name, globals.gpg_profile, size=sys.maxsize)
185
187
        else:
186
 
            os.system("cp -p \"%s\" \"%s\"" % (src.name, tgt.name))
 
188
            shutil.copyfile(src.name, tgt.name)
187
189
        globals.backend.move(tgt)  # @UndefinedVariable
188
190
 
189
191
    def to_final(self):
232
234
        """
233
235
        self.hooklist.append(hook)
234
236
 
235
 
 
236
237
    def get_name(self):
237
238
        """
238
239
        Return the name of the file
249
250
    def __init__(self, data):
250
251
        self.data = data
251
252
 
 
253
 
252
254
class SrcIter:
253
255
    """
254
256
    Iterate over source and return Block of data.
256
258
    def __init__(self, src):
257
259
        self.src = src
258
260
        self.fp = src.open("rb")
 
261
 
259
262
    def next(self):
260
263
        try:
261
264
            res = Block(self.fp.read(self.get_read_size()))
262
265
        except Exception:
263
 
            log.FatalError(_("Failed to read %s: %s") % 
 
266
            log.FatalError(_("Failed to read %s: %s") %
264
267
                           (util.ufn(self.src.name), sys.exc_info()),
265
268
                           log.ErrorCode.generic)
266
269
        if not res.data:
267
270
            self.fp.close()
268
271
            raise StopIteration
269
272
        return res
 
273
 
270
274
    def get_read_size(self):
271
275
        return 128 * 1024
 
276
 
272
277
    def get_footer(self):
273
278
        return ""