Skip to content

Commit

Permalink
Add the username to MachineInfo and its config
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Oct 14, 2021
1 parent 7b66cdc commit fe2b151
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mache/machine_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from importlib.resources import path
import configparser
import os
import pwd

from mache.discover import discover_machine

Expand Down Expand Up @@ -51,6 +52,11 @@ class MachineInfo:
web_portal_url : str
The base URL for the web portal
username : str
The name of the current user, for use in web-portal directories. This
value is also added to the ``web_portal`` and ``username`` option of
the ``config`` attribute.
"""

def __init__(self, machine=None):
Expand Down Expand Up @@ -85,6 +91,12 @@ def __init__(self, machine=None):
self.diagnostics_base = None
self._get_diagnostics_info()

self.web_portal_base = None
self.web_portal_url = None

self.username = pwd.getpwuid(os.getuid()).pw_name
self.config.set('web_portal', 'username', self.username)

def __str__(self):
"""
Convert the info to a format that is good for printing
Expand Down

0 comments on commit fe2b151

Please sign in to comment.