1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-25 07:23:28 +00:00

call socket.gethostname only once

(cherry picked from commit d2e2f1b89d)
This commit is contained in:
Thomas Waldmann 2018-08-04 17:40:04 +02:00
parent 48ed187279
commit 382e37feb7
2 changed files with 4 additions and 4 deletions

View file

@ -40,7 +40,7 @@
from .helpers import ellipsis_truncate, ProgressIndicatorPercent, log_multi
from .patterns import PathPrefixPattern, FnmatchPattern, IECommand
from .item import Item, ArchiveItem
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 .repository import Repository, LIST_SCAN_LIMIT
@ -468,7 +468,7 @@ def save(self, name=None, comment=None, timestamp=None, additional_metadata=None
'comment': comment or '',
'items': self.items_buffer.chunks,
'cmdline': sys.argv,
'hostname': socket.gethostname(),
'hostname': hostname,
'username': getuser(),
'time': start.strftime(ISO_FORMAT),
'time_end': end.strftime(ISO_FORMAT),

View file

@ -664,13 +664,13 @@ def format_line(format, data):
def replace_placeholders(text):
"""Replace placeholders in text with their values."""
from .platform import fqdn
from .platform import fqdn, hostname
current_time = datetime.now(timezone.utc)
data = {
'pid': os.getpid(),
'fqdn': fqdn,
'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))),
'hostname': socket.gethostname(),
'hostname': hostname,
'now': DatetimeWrapper(current_time.astimezone(None)),
'utcnow': DatetimeWrapper(current_time),
'user': uid2user(os.getuid(), os.getuid()),