Skip to content

Commit

Permalink
Function to censor hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Sep 20, 2023
1 parent 625210f commit 8813aab
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
DEFAULT_DATETIME = TZ.localize(datetime(2012, 3, 3, 10, 10, 10, 0))


def _censor_hostname(hostname: str) -> str:
"""Hide part of the hostname for safety reasons"""
var = hostname.split("-")
return (
f"{var[0]}-{var[1]}-.."
if hostname.startswith("dqm")
else "..".join([var[0], var[-1]])
)


class DQM2MirrorDB:
"""
DB Schema description.
Expand Down Expand Up @@ -425,9 +435,7 @@ def format_run_data(self, data):
) = data
client = self.get_short_client_name(client)
# Hide part of the hostname for safety reasons
var = hostname.split("-")
hostname = "..".join([var[0], var[-1]])

hostname = _censor_hostname(hostname)
# Timestamp is of type datetime, and is tz-aware,
# as it's coming straight from the DB.
td = TZ.localize(datetime.now()) - timestamp
Expand Down Expand Up @@ -486,9 +494,7 @@ def format_table_entry(self, data: dict):
_,
) = data
client = self.get_short_client_name(client)
# Hide part of the hostname for safety reasons
var = hostname.split("-")
hostname = "..".join([var[0], var[-1]])
hostname = _censor_hostname(hostname)
runkey = runkey[len("runkey=") :]

cmssw_path = ""
Expand Down

0 comments on commit 8813aab

Please sign in to comment.