-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcsetup.py
More file actions
50 lines (46 loc) · 1.62 KB
/
csetup.py
File metadata and controls
50 lines (46 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
""" setup rundir, pythonpaths. Mostly for CLIP. """
import os, sys
def getDBPath ( dbpath, rundir ):
""" obtain the database path, resolve <rundir> """
if "<rundir>" in dbpath:
dbpath = dbpath.replace("<rundir>",rundir+"/")
dbpath = dbpath.replace("//","/")
return dbpath
def setup( rundir = None, codedir = None ):
"""
:param rundir: if not None, override the rundir defined per default
:param codedir: if not None, override the codedir defined per default
"""
# codedir = "/mnt/hephy/pheno/ww/git/"
if codedir == None:
codedir = "/scratch-cbe/users/wolfgan.waltenberger/git/"
sys.path.insert(0, f"{codedir}/smodels/" )
sys.path.insert(0, f"{codedir}/protomodels/" )
if rundir != None:
if not "/" in rundir[:-1]:
rundir = f"/scratch-cbe/users/wolfgan.waltenberger/{rundir}"
if not rundir.endswith("/"):
rundir += "/"
os.chdir ( rundir )
return rundir
home = os.environ["HOME"]
if os.path.exists ( "./rundir.conf" ):
with open ( "./rundir.conf" ) as f:
rundir = f.read().strip()
rundir = rundir.replace ( "~", home )
os.chdir ( rundir )
return rundir
if os.path.exists ( f"{home}/rundir.conf" ):
with open ( f"{home}/rundir.conf" ) as f:
rundir = f.read().strip()
rundir = rundir.replace ( "~", home )
os.chdir ( rundir )
return rundir
cwd = __file__
#cwd = os.getcwd()
p1 = cwd.find("protomodels")
if p1 > 0:
cwd = cwd[:p1+11]
## print ( "cwd", cwd )
return cwd