-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbaseutil.py
56 lines (47 loc) · 1.7 KB
/
baseutil.py
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
51
52
53
54
55
56
import platform
import sys
import sys
import json
from json import dump
import os
import re
from os.path import exists
from pathlib import Path
import logging
import shutil
print("python version " + platform.python_version())
from configparser import ConfigParser
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
config = ConfigParser()
if not exists(str(Path.home()) + '/.kbase/config'):
if exists("/scratch/shared/code/sharedconfig.cfg"):
shutil.copyfile("/scratch/shared/code/sharedconfig.cfg",str(Path.home()) + '/.kbase/config')
else:
print("You much create a config file in ~/.kbase/config before running this notebook. See instructions: https://docs.google.com/document/d/1fQ6iS_uaaZKbjWtw1MgzqilklttIibNO9XIIJWgxWKo/edit")
sys.exit(1)
config.read(str(Path.home()) + '/.kbase/config')
paths = config.get("DevEnv","syspaths").split(";")
codebase = config.get("DevEnv","codebase",fallback="")
for i,filepath in enumerate(paths):
if filepath[0:1] != "/":
paths[i] = codebase+"/"+filepath
sys.path = paths + sys.path
from chenry_utility_module.kbdevutils import KBDevUtils
class BaseUtil:
def __init__(self):
self.kbdevutil = None
self.msrecon = None
self.annoapi = None
def get_kbdevutil(self,name):
if not self.kbdevutil:
self.kbdevutil = KBDevUtils(name)
return self.kbdevutil
def get_msrecon(self):
if not self.msrecon:
self.msrecon = self.get_kbdevutil().msseedrecon()
return self.msrecon
def get_annoapi(self):
if not self.annoapi:
self.annoapi = self.get_kbdevutil().anno_client(native_python_api=True)
return self.annoapi