Skip to content

Commit

Permalink
moved all messaging to en.py file. changed requisite files to pull me…
Browse files Browse the repository at this point in the history
…ssages from there.
  • Loading branch information
asampat3090 committed Apr 8, 2018
1 parent c73ccb0 commit fb697e9
Show file tree
Hide file tree
Showing 23 changed files with 547 additions and 538 deletions.
2 changes: 1 addition & 1 deletion datmo/cli/command/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def __init__(self, home, cli_helper):
self.project_controller = ProjectController(home=home)

def init(self, name, description):
self.cli_helper.echo(_('setup.init_project', {"name":name, "path": self.home}))
self.cli_helper.echo(_("info", "cli.project.init", {"name":name, "path": self.home}))
self.project_controller.init(name, description)
2 changes: 1 addition & 1 deletion datmo/cli/command/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, home, cli_helper):
})

def create(self, **kwargs):
self.cli_helper.echo(_('snapshot.create'))
self.cli_helper.echo(_("info", "cli.snapshot.create"))
self.snapshot_controller.create(**kwargs)

def delete(self, snapshot_id):
Expand Down
2 changes: 1 addition & 1 deletion datmo/cli/driver/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_command_class(self, command_name):
try:
command_class = importlib.import_module(command_path)
except ImportError as ex:
self.echo(_("cli.exception", ex.message))
self.echo(_("error", "cli.general", ex.message))
sys.exit()

all_members = inspect.getmembers(command_class)
Expand Down
6 changes: 3 additions & 3 deletions datmo/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ def main():
try:
command_instance = command_class(os.getcwd(), cli_helper)
except TypeError as ex:
cli_helper.echo(_("cli.exception", ex.message))
cli_helper.echo(_("error", "cli.general", ex.message))
sys.exit()

try:
command_instance.parse(sys.argv[1:])
except CLIArgumentException as ex:
cli_helper.echo(_("cli.exception", ex.message))
cli_helper.echo(_("error", "cli.general", ex.message))
sys.exit()

try:
command_instance.execute()
except Exception as ex:
cli_helper.echo(_("cli.exception", ex.message))
cli_helper.echo(_("error", "cli.general", ex.message))

if __name__ == "__main__":
main()
12 changes: 6 additions & 6 deletions datmo/controller/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from datmo.storage.local.driver.driver_type import DriverType
from datmo.util.i18n import get as _
from datmo.util import get_class_contructor
from datmo.util.project_settings import ProjectSettings
from datmo.util.exceptions import InvalidProjectPathException, \
Expand All @@ -21,11 +22,9 @@ def __init__(self, home, dal_driver=None):
self._is_initialized = False

if not os.path.isdir(self.home):
raise InvalidProjectPathException("exception.datmo.project", {
"home": home,
"exception": "Project path does not exist"
})

raise InvalidProjectPathException(_("error",
"controller.base.__init__",
home))
self.settings = ProjectSettings(self.home)
# TODO: is_initialized properties should be functions

Expand All @@ -48,7 +47,8 @@ def model(self):
@property
def current_session(self):
if not self.model:
raise DatmoModelNotInitializedException()
raise DatmoModelNotInitializedException(_("error",
"controller.base.current_session"))
if self._current_session == None:
session_id = self.settings.get('current_session_id')
self._current_session = self.dal.session.get_by_id(session_id) if session_id else None
Expand Down

0 comments on commit fb697e9

Please sign in to comment.