MCPcopy
hub / github.com/borgbackup/borg / borg_cmd

Method borg_cmd

src/borg/remote.py:681–722  ·  view source on GitHub ↗

return a borg serve command line

(self, args, testing)

Source from the content-addressed store, hash-verified

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"""

Callers 3

__init__Method · 0.95
test_remote_borg_cmdFunction · 0.45
test_remote_borg_cmdFunction · 0.45

Calls 1

getMethod · 0.45

Tested by 2

test_remote_borg_cmdFunction · 0.36
test_remote_borg_cmdFunction · 0.36