27
27
LABSCRIPT_SUITE_PROFILE = None
28
28
29
29
30
+ def hostname ():
31
+ if sys .platform == 'darwin' :
32
+ return check_output (['scutil' , '--get' , 'LocalHostName' ]).decode ('utf8' ).strip ()
33
+ else :
34
+ return socket .gethostname ()
35
+
36
+
30
37
def default_labconfig_path ():
31
38
if LABSCRIPT_SUITE_PROFILE is None :
32
39
return None
33
- if sys .platform == 'darwin' :
34
- cmd = ['scutil' , '--get' , 'LocalHostName' ]
35
- hostname = check_output (cmd ).decode ('utf8' ).strip ()
36
- else :
37
- hostname = socket .gethostname ()
38
- labconfig = LABSCRIPT_SUITE_PROFILE / 'labconfig' / f'{ hostname } .ini'
39
- return labconfig
40
+ return LABSCRIPT_SUITE_PROFILE / 'labconfig' / f'{ hostname ()} .ini'
40
41
41
42
42
43
def add_userlib_and_pythonlib ():
@@ -46,18 +47,17 @@ def add_userlib_and_pythonlib():
46
47
labscript_utils, since we dont' want to import something like labscript_utils every
47
48
time the interpreter starts up"""
48
49
labconfig = default_labconfig_path ()
49
- if labconfig is None or not os .path .exists (labconfig ):
50
- return
51
- config = ConfigParser ()
52
- config .read (labconfig )
53
- for option in ['userlib' , 'pythonlib' ]:
54
- try :
55
- paths = config .get ('DEFAULT' , option ).split (',' )
56
- except (NoSectionError , NoOptionError ):
57
- paths = []
58
- for path in paths :
59
- if os .path .exists (path ):
60
- sys .path .append (path )
50
+ if labconfig is not None and labconfig .exists ():
51
+ config = ConfigParser ()
52
+ config .read (labconfig )
53
+ for option in ['userlib' , 'pythonlib' ]:
54
+ try :
55
+ paths = config .get ('DEFAULT' , option ).split (',' )
56
+ except (NoSectionError , NoOptionError ):
57
+ paths = []
58
+ for path in paths :
59
+ if os .path .exists (path ):
60
+ sys .path .append (path )
61
61
62
62
63
63
def add_development_directories ():
0 commit comments