return a borg serve command line
(self, args, testing)
| 679 | return bin_to_hex(self.id) |
| 680 | |
| 681 | def borg_cmd(self, args, testing): |
| 682 | """return a borg serve command line""" |
| 683 | # give some args/options to 'borg serve' process as they were given to us |
| 684 | opts = [] |
| 685 | if args is not None: |
| 686 | root_logger = logging.getLogger() |
| 687 | if root_logger.isEnabledFor(logging.DEBUG): |
| 688 | opts.append("--debug") |
| 689 | elif root_logger.isEnabledFor(logging.INFO): |
| 690 | opts.append("--info") |
| 691 | elif root_logger.isEnabledFor(logging.WARNING): |
| 692 | pass # warning is default |
| 693 | elif root_logger.isEnabledFor(logging.ERROR): |
| 694 | opts.append("--error") |
| 695 | elif root_logger.isEnabledFor(logging.CRITICAL): |
| 696 | opts.append("--critical") |
| 697 | else: |
| 698 | raise ValueError("log level missing, fix this code") |
| 699 | |
| 700 | # Tell the remote server about debug topics it may need to consider. |
| 701 | # Note that debug topics are usable for "spew" or "trace" logs which would |
| 702 | # be too plentiful to transfer for normal use, so the server doesn't send |
| 703 | # them unless explicitly enabled. |
| 704 | # |
| 705 | # Needless to say, if you do --debug-topic=repository.compaction, for example, |
| 706 | # with a 1.0.x server it won't work, because the server does not recognize the |
| 707 | # option. |
| 708 | # |
| 709 | # This is not considered a problem, since this is a debugging feature that |
| 710 | # should not be used for regular use. |
| 711 | for topic in args.debug_topics: |
| 712 | if "." not in topic: |
| 713 | topic = "borg.debug." + topic |
| 714 | if "repository" in topic: |
| 715 | opts.append("--debug-topic=%s" % topic) |
| 716 | env_vars = [] |
| 717 | if testing: |
| 718 | return env_vars + [sys.executable, "-m", "borg", "serve"] + opts + self.extra_test_args |
| 719 | else: # pragma: no cover |
| 720 | remote_path = args.remote_path or os.environ.get("BORG_REMOTE_PATH", "borg") |
| 721 | remote_path = replace_placeholders(remote_path) |
| 722 | return env_vars + [remote_path, "serve"] + opts |
| 723 | |
| 724 | def ssh_cmd(self, location): |
| 725 | """return a ssh command line that can be prefixed to a borg command line""" |