Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/translations/xtm/cli.py

Issue 29968558: Issue 7037 - [XTM Integration] Make REST API url customizable
Patch Set: Created Dec. 27, 2018, 2:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cms/translations/xtm/constants.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/translations/xtm/cli.py
diff --git a/cms/translations/xtm/cli.py b/cms/translations/xtm/cli.py
index 9bade4323d56be2a85360ea696297c07c45b50ca..32cfe6bcc2ab2ad2e6fd012e1d0c2a6fc3632310 100644
--- a/cms/translations/xtm/cli.py
+++ b/cms/translations/xtm/cli.py
@@ -28,16 +28,17 @@ import cms.translations.xtm.constants as const
from cms.translations.xtm.projects_handler import (
create_project, upload_files, download_files,
)
-from cms.translations.xtm.utils import input_fn, read_token
+from cms.translations.xtm.utils import input_fn, read_token, get_api_url
from cms.sources import create_source
def handle_projects(args):
- try:
- api = XTMCloudAPI(read_token())
- except Exception as err:
- sys.exit(err)
+ token = read_token()
Vasily Kuznetsov 2019/01/10 17:45:23 Wouldn't it be better to keep this inside of try/e
Tudor Avram 2019/09/17 12:25:02 Done.
with create_source(args.source_dir, cached=True) as fs:
+ try:
+ api = XTMCloudAPI(token, get_api_url(args, fs))
+ except Exception as err:
+ sys.exit(err)
args.projects_func(args, api, fs)
@@ -45,11 +46,12 @@ def generate_token(args):
"""Generate an API token from username and password."""
username = input_fn('Username: ')
user_id = input_fn('User ID: ')
- password = getpass.getpass(prompt='Pasword: ')
+ password = getpass.getpass(prompt='Password: ')
logging.info(const.InfoMessages.GENERATING_TOKEN.format(username, user_id))
try:
- token = get_token(username, password, int(user_id))
+ token = get_token(username, password, int(user_id),
+ get_api_url(args, None))
logging.info(const.InfoMessages.TOKEN_GENERATED.format(token))
cmd = const.Token.SAVE_COMMAND.format(const.Token.ENV_VAR, token)
@@ -67,6 +69,7 @@ def parse_args():
# Universal arguments
parser.add_argument('-v', '--verbose', action='store_true',
help=const.ArgumentsHelp.VERBOSE)
+ parser.add_argument('--api-url', help=const.ArgumentsHelp.API_URL)
# Subparser for generating token
token_parser = subparsers.add_parser('login',
« no previous file with comments | « no previous file | cms/translations/xtm/constants.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld