Skip to content

Commit 80e7276

Browse files
author
Sphesihle Makhathini
committed
hide special charecters and lower funny usernames
1 parent 1b99d5e commit 80e7276

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

stimela/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import pkg_resources
55
import logging
6+
import re
67

78
try:
89
__version__ = pkg_resources.require("stimela")[0].version
@@ -13,6 +14,7 @@
1314
USER = os.environ["USER"]
1415
UID = os.getuid()
1516
GID = os.getgid()
17+
CAB_USERNAME = re.sub('[^0-9a-zA-Z]+', '_', USER).lower()
1618

1719
root = os.path.dirname(__file__)
1820

stimela/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from stimela import docker, singularity, udocker, podman, utils
88
from stimela.utils import logger
99
from stimela.cargo import cab
10-
import re
1110

1211
BASE = stimela.BASE
1312
CAB = stimela.CAB
@@ -17,7 +16,7 @@
1716
LOG_HOME = stimela.LOG_HOME
1817
LOG_FILE = stimela.LOG_FILE
1918
GLOBALS = stimela.GLOBALS
20-
CAB_USERNAME = re.sub('[^0-9a-zA-Z]+', '_', USER).lower()
19+
CAB_USERNAME = stimela.CAB_USERNAME
2120

2221
class MultilineFormatter(argparse.HelpFormatter):
2322
def _fill_text(self, text, width, indent):

stimela/recipe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
CAB_PATH = os.path.abspath(os.path.dirname(cab.__file__))
2323
BIN = os.path.abspath(os.path.dirname(sys.executable))
2424

25+
2526
CONT_IO = {
2627
"docker": {
2728
"input": "/input",
@@ -818,7 +819,7 @@ def __init__(self, name, data=None,
818819

819820
self.stimela_path = os.path.dirname(docker.__file__)
820821

821-
self.build_label = build_label or USER
822+
self.build_label = build_label or stimela.CAB_USERNAME
822823
self.ms_dir = ms_dir
823824
if not os.path.exists(self.ms_dir):
824825
self.log.info(

0 commit comments

Comments
 (0)