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: Merged with changes from 7039 Created Sept. 17, 2019, 1:37 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 c3f7ea602b310bd25baa59b9e280f53580dca38d..c449f284652ae9b12e5977d3ef1d02baa8c4b4f0 100644
--- a/cms/translations/xtm/cli.py
+++ b/cms/translations/xtm/cli.py
@@ -28,17 +28,18 @@ 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):
@@ -49,7 +50,8 @@ def generate_token(args):
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