-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new placeholder keys #1956
base: master
Are you sure you want to change the base?
Add new placeholder keys #1956
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import os | ||
import re | ||
import socket | ||
import subprocess | ||
import sys | ||
import unicodedata | ||
from datetime import datetime as dt | ||
|
@@ -416,14 +417,27 @@ def format_archive_name(profile, archive_name_tpl): | |
""" | ||
hostname = socket.gethostname() | ||
hostname = hostname.split(".")[0] | ||
fqdn = _getfqdn(hostname) | ||
borg_version = os.getenv("BORG_VERSION") | ||
if not borg_version: | ||
borg_version = subprocess.run(['borg', '--version'], stdout=subprocess.PIPE).stdout.decode('utf-8') | ||
borg_version = borg_version.split(' ')[1] | ||
borg_version_tuple = tuple(borg_version.split(".")) | ||
Comment on lines
+420
to
+425
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vorta already queries borg version information on startup. Why not use that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I get circular import error when importing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, be aware of circular imports. Helper functions and modules should only be used by higher level. So maybe |
||
available_vars = { | ||
'hostname': hostname, | ||
'fqdn': _getfqdn(hostname), | ||
'fqdn': fqdn, | ||
'reverse-fqdn': ".".join(reversed(fqdn.split("."))), | ||
'profile_id': profile.id, | ||
'profile_slug': profile.slug(), | ||
'now': dt.now(), | ||
'utc_now': dt.utcnow(), | ||
'utcnow': dt.utcnow(), | ||
'user': getpass.getuser(), | ||
'pid': os.getpid(), | ||
'borgversion': borg_version, | ||
'borgmajor': "%s" % borg_version_tuple[:1], | ||
'borgminor': "%s.%s" % borg_version_tuple[:2], | ||
'borgpatch': "%s.%s.%s" % borg_version_tuple[:3], | ||
} | ||
return archive_name_tpl.format(**available_vars) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are basically sidestepping everything we do to correctly detect the right
borg
binary. So while this may work in many cases, it will break in others. So as already mentioned before, it will be better to use the existingborg_compat
module.