~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to bin/duplicity

  • 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:
65
65
    message = message.encode(locale.getpreferredencoding(), 'replace')
66
66
    return getpass.getpass(message)
67
67
 
68
 
def get_passphrase(n, action, for_signing = False):
 
68
def get_passphrase(n, action, for_signing=False):
69
69
    """
70
70
    Check to make sure passphrase is indeed needed, then get
71
71
    the passphrase from environment, from gpg-agent, or user
95
95
 
96
96
    # check if we can reuse an already set (signing_)passphrase
97
97
    # if signing key is also an encryption key assume that the passphrase is identical
98
 
    if ( for_signing
 
98
    if (for_signing
99
99
         and (globals.gpg_profile.sign_key in globals.gpg_profile.recipients
100
100
         or globals.gpg_profile.sign_key in globals.gpg_profile.hidden_recipients)
101
 
         and 'PASSPHRASE' in os.environ ):
 
101
         and 'PASSPHRASE' in os.environ):
102
102
        log.Notice(_("Reuse configured PASSPHRASE as SIGN_PASSPHRASE"))
103
103
        return os.environ['PASSPHRASE']
104
104
    # if one encryption key is also the signing key assume that the passphrase is identical
105
 
    if ( not for_signing
 
105
    if (not for_signing
106
106
         and (globals.gpg_profile.sign_key in globals.gpg_profile.recipients
107
107
         or globals.gpg_profile.sign_key in globals.gpg_profile.hidden_recipients)
108
 
         and 'SIGN_PASSPHRASE' in os.environ ):
 
108
         and 'SIGN_PASSPHRASE' in os.environ):
109
109
        log.Notice(_("Reuse configured SIGN_PASSPHRASE as PASSPHRASE"))
110
110
        return os.environ['SIGN_PASSPHRASE']
111
111
 
160
160
                    if use_cache and globals.gpg_profile.signing_passphrase:
161
161
                        pass1 = globals.gpg_profile.signing_passphrase
162
162
                    else:
163
 
                        pass1 = getpass_safe(_("GnuPG passphrase for signing key:")+" ")
 
163
                        pass1 = getpass_safe(_("GnuPG passphrase for signing key:") + " ")
164
164
                else:
165
165
                    if use_cache and globals.gpg_profile.passphrase:
166
166
                        pass1 = globals.gpg_profile.passphrase
167
167
                    else:
168
 
                        pass1 = getpass_safe(_("GnuPG passphrase:")+" ")
 
168
                        pass1 = getpass_safe(_("GnuPG passphrase:") + " ")
169
169
 
170
170
            if n == 1:
171
171
                pass2 = pass1
291
291
        info = backend.query_info([dest_filename])[dest_filename]
292
292
        size = info['size']
293
293
        if size is None:
294
 
            return # error querying file
 
294
            return  # error querying file
295
295
        if size != orig_size:
296
296
            code_extra = "%s %d %d" % (util.escape(dest_filename), orig_size, size)
297
297
            log.FatalError(_("File %s was corrupted during upload.") % util.ufn(dest_filename),
304
304
        instead of copying.
305
305
        """
306
306
        putsize = tdp.getsize()
307
 
        if globals.skip_volume != vol_num: # for testing purposes only
 
307
        if globals.skip_volume != vol_num:  # for testing purposes only
308
308
            backend.put(tdp, dest_filename)
309
309
        validate_block(putsize, dest_filename)
310
310
        if tdp.stat:
382
382
 
383
383
    while not at_end:
384
384
        # set up iterator
385
 
        tarblock_iter.remember_next_index() # keep track of start index
 
385
        tarblock_iter.remember_next_index()  # keep track of start index
386
386
 
387
387
        # Create volume
388
388
        vol_num += 1
939
939
                   "\n" + chain_times_str(chainlist))
940
940
        # Add signature files too, since they won't be needed anymore
941
941
        chainlist += col_stats.get_signature_chains_older_than(globals.remove_time)
942
 
        chainlist.reverse() # save oldest for last
 
942
        chainlist.reverse()  # save oldest for last
943
943
        for chain in chainlist:
944
944
            # if remove_all_inc_of_but_n_full_mode mode, remove only incrementals one and not full
945
945
            if globals.remove_all_inc_of_but_n_full_mode:
1143
1143
                    # password for the --encrypt-key
1144
1144
                    globals.gpg_profile.passphrase = get_passphrase(1, "sync")
1145
1145
                else:
1146
 
                    local_missing = [] # don't download if we can't decrypt
 
1146
                    local_missing = []  # don't download if we can't decrypt
1147
1147
            for fn in local_spurious:
1148
1148
                remove_local(fn)
1149
1149
            if hasattr(globals.backend, 'pre_process_download'):
1337
1337
        log.shutdown()
1338
1338
        sys.exit(2)
1339
1339
 
1340
 
    globals.lockfile.acquire(timeout = 0)
 
1340
    globals.lockfile.acquire(timeout=0)
1341
1341
 
1342
1342
    try:
1343
1343
        do_backup(action)
1351
1351
    if globals.pydevd:
1352
1352
        pysrc = "/opt/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.4.2011111522/pysrc"
1353
1353
        sys.path.append(pysrc)
1354
 
        import pydevd #@UnresolvedImport
 
1354
        import pydevd  # @UnresolvedImport
1355
1355
        pydevd.settrace()
1356
1356
    # end remote debugger startup
1357
1357
 
1472
1472
                    # only ask for a passphrase if there was a previous backup
1473
1473
                    if col_stats.all_backup_chains:
1474
1474
                        globals.gpg_profile.passphrase = get_passphrase(1, action)
1475
 
                    check_last_manifest(col_stats) # not needed for full backup
 
1475
                    check_last_manifest(col_stats)  # not needed for full backup
1476
1476
                incremental_backup(sig_chain)
1477
1477
    globals.backend.close()
1478
1478
    log.shutdown()