~mterry/duplicity/fix-gpg-options-crash-0.7

« back to all changes in this revision

Viewing changes to duplicity/commandline.py

  • Committer: Kenneth Loafman
  • Date: 2009-10-29 18:44:14 UTC
  • mfrom: (609.1.2 i18n-for-0.7)
  • Revision ID: kenneth@loafman.com-20091029184414-kbwu0fappcyweylj
Merge in lp:~duplicity-team/duplicity/i18n-for-0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
    Return expanded version of archdir joined with backname.
141
141
    """
142
142
    assert globals.backup_name is not None, \
143
 
        "expand_archive_dir() called prior to globals.backup_name being set"
 
143
        _("expand_archive_dir() called prior to globals.backup_name being set")
144
144
 
145
145
    return expand_fn(os.path.join(archdir, backname))
146
146
 
190
190
        possible = [c for c in commands if c.startswith(cmd)]
191
191
        # no unique match, that's an error
192
192
        if len(possible) > 1:
193
 
            command_line_error("command '%s' not unique, could be %s" % (cmd, possible))
 
193
            command_line_error(_("command '%s' not unique, could be %s") % (cmd, possible))
194
194
        # only one match, that's a keeper
195
195
        elif len(possible) == 1:
196
196
            cmd = possible[0]
217
217
        try:
218
218
            arg = arglist.pop(0)
219
219
        except:
220
 
            command_line_error("Missing time string for remove-older-than")
 
220
            command_line_error(_("Missing time string for remove-older-than"))
221
221
        globals.remove_time = dup_time.genstrtotime(arg)
222
222
        num_expect = 1
223
223
    elif cmd == "remove-all-but-n-full":
224
224
        try:
225
225
            arg = arglist.pop(0)
226
226
        except:
227
 
            command_line_error("Missing count for remove-all-but-n-full")
 
227
            command_line_error(_("Missing count for remove-all-but-n-full"))
228
228
        globals.keep_chains = int(arg)
229
229
        if not globals.keep_chains > 0:
230
 
            command_line_error("remove-all-but-n-full count must be > 0")
 
230
            command_line_error(_("remove-all-but-n-full count must be > 0"))
231
231
        num_expect = 1
232
232
    elif cmd == "verify":
233
233
        verify = True
303
303
        elif opt == "--log-fd":
304
304
            log_fd = get_int(arg, opt)
305
305
            if log_fd < 1:
306
 
                command_line_error("log-fd must be greater than zero.")
 
306
                command_line_error(_("log-fd must be greater than zero."))
307
307
            try:
308
308
                log.add_fd(log_fd)
309
309
            except:
310
 
                command_line_error("Cannot write to log-fd %s." % arg)
 
310
                command_line_error(_("Cannot write to log-fd %s.") % arg)
311
311
        elif opt == "--log-file":
312
312
            arg = expand_fn(arg)
313
313
            try:
314
314
                log.add_file(arg)
315
315
            except:
316
 
                command_line_error("Cannot write to log-file %s." % arg)
 
316
                command_line_error(_("Cannot write to log-file %s.") % arg)
317
317
        elif opt == "--name":
318
318
            globals.backup_name = arg
319
319
        elif opt == "--no-encryption":
354
354
            globals.timeout = get_int(arg, opt)
355
355
        elif opt == "--time-separator":
356
356
            if arg == '-':
357
 
                command_line_error("Dash ('-') not valid for time-separator.")
 
357
                command_line_error(_("Dash ('-') not valid for time-separator."))
358
358
            globals.time_separator = arg
359
359
            dup_time.curtimestr = dup_time.timetostring(dup_time.curtime)
360
360
            old_fn_deprecation(opt)
378
378
            elif arg.isdigit() and (len(arg) == 1):
379
379
                verb = get_int(arg, opt)
380
380
            else:
381
 
                command_line_error("\nVerbosity must be one of: digit [0-9], character [ewnid],\n"
382
 
                                   "or word ['error', 'warning', 'notice', 'info', 'debug'].\n"
383
 
                                   "The default is 4 (Notice).  It is strongly recommended\n"
384
 
                                   "that verbosity level is set at 2 (Warning) or higher.")
 
381
                command_line_error(_("""
 
382
Verbosity must be one of: digit [0-9], character [ewnid],
 
383
or word ['error', 'warning', 'notice', 'info', 'debug'].
 
384
The default is 4 (Notice).  It is strongly recommended
 
385
that verbosity level is set at 2 (Warning) or higher.
 
386
""")
385
387
            log.setverbosity(verb)
386
388
        elif opt == "--volsize":
387
389
            globals.volsize = get_int(arg, opt)*1024*1024
395
397
            if par2_utils.is_par2_supported():
396
398
                globals.par2 = True;
397
399
            else:
398
 
                command_line_error("Par2 support was requested but par2 executable cannot be found.\n" 
399
 
                                   "Please make the par2 executable availabe in your PATH environment.")
 
400
                command_line_error(_("Par2 support was requested but par2 executable cannot be found.\n" 
 
401
                                     "Please make the par2 executable availabe in your PATH environment."))
400
402
        else:
401
 
            command_line_error("Unknown option %s" % opt)
 
403
            command_line_error(_("Unknown option %s") % opt)
402
404
 
403
405
    # if we change the time format then we need a new curtime
404
406
    if globals.old_filenames:
405
407
        dup_time.curtimestr = dup_time.timetostring(dup_time.curtime)
406
408
 
407
409
    if len(args) != num_expect:
408
 
        command_line_error("Expected %d args, got %d" % (num_expect, len(args)))
 
410
        command_line_error(_("Expected %d args, got %d") % (num_expect, len(args)))
409
411
 
410
412
    # expand pathname args, but not URL
411
413
    for loc in range(len(args)):
417
419
    # checks here in order to make enough sense of args to identify
418
420
    # the backend URL/lpath for args_to_path_backend().
419
421
    if len(args) < 1:
420
 
        command_line_error("Too few arguments")
 
422
        command_line_error(_("Too few arguments"))
421
423
    elif len(args) == 1:
422
424
        backend_url = args[0]
423
425
    elif len(args) == 2:
424
426
        lpath, backend_url = args_to_path_backend(args[0], args[1])
425
427
    else:
426
 
        command_line_error("Too many arguments")
 
428
        command_line_error(_("Too many arguments"))
427
429
 
428
430
    if globals.backup_name is None:
429
431
        globals.backup_name = generate_default_backup_name(backend_url)
700
702
    try:
701
703
        return int(int_string)
702
704
    except ValueError:
703
 
        command_line_error("Received '%s' for %s, need integer" %
 
705
        command_line_error(_("Received '%s' for %s, need integer") %
704
706
                                          (int_string, description.lstrip('-')))
705
707
 
706
708
def set_archive_dir(dirstring):
744
746
 
745
747
    if not arg1_is_backend and not arg2_is_backend:
746
748
        command_line_error(
747
 
"""One of the arguments must be an URL.  Examples of URL strings are
 
749
_("""One of the arguments must be an URL.  Examples of URL strings are
748
750
"scp://user@host.net:1234/path" and "file:///usr/local".  See the man
749
 
page for more information.""")
 
751
page for more information."""))
750
752
    if arg1_is_backend and arg2_is_backend:
751
 
        command_line_error("Two URLs specified.  "
752
 
                           "One argument should be a path.")
 
753
        command_line_error(_("Two URLs specified.  "
 
754
                             "One argument should be a path."))
753
755
    if arg1_is_backend:
754
756
        return (arg2, arg1)
755
757
    elif arg2_is_backend:
756
758
        return (arg1, arg2)
757
759
    else:
758
 
        raise AssertionError('should not be reached')
 
760
        raise AssertionError(_("this code should not be reachable"))
759
761
 
760
762
def set_backend(arg1, arg2):
761
763
    """Figure out which arg is url, set backend
813
815
                         globals.remove_time is not None])
814
816
    elif action == "restore" or action == "verify":
815
817
        if full_backup:
816
 
            command_line_error("--full option cannot be used when "
817
 
                               "restoring or verifying")
 
818
            command_line_error(_("--full option cannot be used when "
 
819
                                 "restoring or verifying"))
818
820
        elif globals.incremental:
819
 
            command_line_error("--incremental option cannot be used when "
820
 
                               "restoring or verifying")
 
821
            command_line_error(_("--incremental option cannot be used when "
 
822
                                 "restoring or verifying"))
821
823
        if select_opts and action == "restore":
822
 
            command_line_error("Selection options --exclude/--include\n"
823
 
                               "currently work only when backing up, "
824
 
                               "not restoring.")
 
824
            command_line_error(_("Selection options --exclude/--include\n"
 
825
                                 "currently work only when backing up, "
 
826
                                 "not restoring."))
825
827
    else:
826
828
        assert action == "inc" or action == "full"
827
829
        if verify:
828
 
            command_line_error("--verify option cannot be used "
829
 
                                      "when backing up")
 
830
            command_line_error(_("--verify option cannot be used "
 
831
                                 "when backing up"))
830
832
        if globals.restore_dir:
831
 
            command_line_error("restore option incompatible with %s backup"
832
 
                               % (action,))
833
 
 
 
833
            if action == "inc":
 
834
                command_line_error(_("restore option incompatible with "
 
835
                                     "incremental backup"))
 
836
            else:
 
837
                command_line_error(_("restore option incompatible with "
 
838
                                     "full backup"))
834
839
 
835
840
def ProcessCommandLine(cmdline_list):
836
841
    """Process command line, set globals, return action
848
853
 
849
854
    # parse_cmdline_options already verified that we got exactly 1 or 2
850
855
    # non-options arguments
851
 
    assert len(args) >= 1 and len(args) <= 2, "arg count should have been checked already"
 
856
    assert len(args) >= 1 and len(args) <= 2,
 
857
        _("arg count should have been checked already")
852
858
 
853
859
    if len(args) == 1:
854
860
        if list_current:
862
868
        elif globals.keep_chains is not None:
863
869
            action = "remove-all-but-n-full"
864
870
        else:
865
 
            command_line_error("Too few arguments")
 
871
            command_line_error(_("Too few arguments"))
866
872
        globals.backend = backend.get_backend(args[0])
867
873
        if not globals.backend:
868
874
            log.FatalError(_("""Bad URL '%s'.
887
893
        if action in ['full', 'inc', 'verify']:
888
894
            set_selection()
889
895
    elif len(args) > 2:
890
 
        raise AssertionError("this code should not be reachable")
 
896
        raise AssertionError(_("this code should not be reachable"))
891
897
 
892
898
    check_consistency(action)
893
899
    log.Info(_("Main action: ") + action)