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: Addressed comments Created Sept. 17, 2019, 12:22 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..f8166e2a54c563d8bb23bca1acaa1d88f46fc195 100644
--- a/cms/translations/xtm/cli.py
+++ b/cms/translations/xtm/cli.py
@@ -28,28 +28,30 @@ 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())
+ token = read_token()
+ with create_source(args.source_dir, cached=True) as fs:
+ api = XTMCloudAPI(token, get_api_url(args, fs))
+ args.projects_func(args, api, fs)
except Exception as err:
sys.exit(err)
- with create_source(args.source_dir, cached=True) as fs:
- args.projects_func(args, api, fs)
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',
@@ -157,7 +160,7 @@ def main():
args = parse_args()
if args.verbose:
- logging.basicConfig(level=logging.INFO)
+ logging.basicConfig(level=logging.INFO, stream=sys.stderr)
args.func(args)
« 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