mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-22 14:11:27 +00:00
Merge pull request #4007 from ThomasWaldmann/hostname-fqdn-cleanups
call socket.gethostname only once
This commit is contained in:
commit
68c2635d3a
2 changed files with 4 additions and 4 deletions
|
@ -41,7 +41,7 @@
|
||||||
from .helpers import ellipsis_truncate, ProgressIndicatorPercent, log_multi
|
from .helpers import ellipsis_truncate, ProgressIndicatorPercent, log_multi
|
||||||
from .patterns import PathPrefixPattern, FnmatchPattern, IECommand
|
from .patterns import PathPrefixPattern, FnmatchPattern, IECommand
|
||||||
from .item import Item, ArchiveItem, ItemDiff
|
from .item import Item, ArchiveItem, ItemDiff
|
||||||
from .platform import acl_get, acl_set, set_flags, get_flags, swidth
|
from .platform import acl_get, acl_set, set_flags, get_flags, swidth, hostname
|
||||||
from .remote import cache_if_remote
|
from .remote import cache_if_remote
|
||||||
from .repository import Repository, LIST_SCAN_LIMIT
|
from .repository import Repository, LIST_SCAN_LIMIT
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ def save(self, name=None, comment=None, timestamp=None, additional_metadata=None
|
||||||
'comment': comment or '',
|
'comment': comment or '',
|
||||||
'items': self.items_buffer.chunks,
|
'items': self.items_buffer.chunks,
|
||||||
'cmdline': sys.argv,
|
'cmdline': sys.argv,
|
||||||
'hostname': socket.gethostname(),
|
'hostname': hostname,
|
||||||
'username': getuser(),
|
'username': getuser(),
|
||||||
'time': start.strftime(ISO_FORMAT),
|
'time': start.strftime(ISO_FORMAT),
|
||||||
'time_end': end.strftime(ISO_FORMAT),
|
'time_end': end.strftime(ISO_FORMAT),
|
||||||
|
|
|
@ -179,13 +179,13 @@ def format_line(format, data):
|
||||||
|
|
||||||
def replace_placeholders(text):
|
def replace_placeholders(text):
|
||||||
"""Replace placeholders in text with their values."""
|
"""Replace placeholders in text with their values."""
|
||||||
from ..platform import fqdn
|
from ..platform import fqdn, hostname
|
||||||
current_time = datetime.now(timezone.utc)
|
current_time = datetime.now(timezone.utc)
|
||||||
data = {
|
data = {
|
||||||
'pid': os.getpid(),
|
'pid': os.getpid(),
|
||||||
'fqdn': fqdn,
|
'fqdn': fqdn,
|
||||||
'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))),
|
'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))),
|
||||||
'hostname': socket.gethostname(),
|
'hostname': hostname,
|
||||||
'now': DatetimeWrapper(current_time.astimezone(None)),
|
'now': DatetimeWrapper(current_time.astimezone(None)),
|
||||||
'utcnow': DatetimeWrapper(current_time),
|
'utcnow': DatetimeWrapper(current_time),
|
||||||
'user': uid2user(os.getuid(), os.getuid()),
|
'user': uid2user(os.getuid(), os.getuid()),
|
||||||
|
|
Loading…
Reference in a new issue