Skip to content

Commit 73e114f

Browse files
authored
Merge pull request #56 from rediscovery-io/fix-load-config
Fix load config file
2 parents e07d4a6 + e0b5286 commit 73e114f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

remo/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def connect(server: str = '', email: str = '', password: str = '', viewer: str =
1919
"""
2020

2121
if remo_home:
22-
from .config import set_REMO_HOME
23-
set_REMO_HOME(remo_home)
22+
from .config import set_remo_home
23+
set_remo_home(remo_home)
2424

2525
if not (server and email and password):
2626
from .config import Config

remo/config.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
REMO_HOME_ENV = 'REMO_HOME'
66

77

8-
def REMO_HOME():
8+
def get_remo_home():
99
return os.getenv(REMO_HOME_ENV, str(Path.home().joinpath('.remo')))
1010

1111

12-
def set_REMO_HOME(path: str):
12+
def set_remo_home(path: str):
1313
if not os.path.exists(path):
1414
os.makedirs(path)
1515
os.environ[REMO_HOME_ENV] = path
@@ -38,9 +38,12 @@ def server_url(self):
3838
return '{}:{}'.format(self.server, self.port)
3939

4040
@staticmethod
41-
def load(config_path: str = str(os.path.join(REMO_HOME(), 'remo.json'))):
41+
def load(config_path: str = None):
42+
if not config_path:
43+
config_path = str(os.path.join(get_remo_home(), 'remo.json'))
44+
4245
if not os.path.exists(config_path):
43-
return None
46+
raise Exception(f'Config file not found, file {config_path} not exists')
4447

4548
with open(config_path) as cfg_file:
4649
config = json.load(cfg_file)

remo/viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import webbrowser
77
import uuid
88

9-
from remo.config import REMO_HOME
9+
from remo.config import get_remo_home
1010

1111

1212
class AbstractViewer(metaclass=ABCMeta):
@@ -86,7 +86,7 @@ def build_cmd(executable, **kwargs):
8686
return '{} {}'.format(executable, ' '.join('--{}={}'.format(k, v) for k, v in kwargs.items() if v))
8787

8888
def get_remo_path(self):
89-
return str(os.path.join(REMO_HOME(), self.exe_path.get(platform.system())))
89+
return str(os.path.join(get_remo_home(), self.exe_path.get(platform.system())))
9090

9191

9292
def factory(name: str):

0 commit comments

Comments
 (0)