Commit e9b0cc71 by David Baumgold

from __future__ import print_function

and print errors and warnings to sys.stderr
parent 6f38ea43
from __future__ import print_function
import sys import sys
from paver.easy import * from paver.easy import *
...@@ -31,13 +32,21 @@ def doc_path(options, allow_default=True): ...@@ -31,13 +32,21 @@ def doc_path(options, allow_default=True):
path = DOC_PATHS.get(doc_type) path = DOC_PATHS.get(doc_type)
if doc_type == 'default' and not allow_default: if doc_type == 'default' and not allow_default:
print "You must specify a documentation type using '--type'. Valid options are: {options}".format( print(
options=valid_doc_types()) "You must specify a documentation type using '--type'. "
"Valid options are: {options}".format(
options=valid_doc_types()
)
)
sys.exit(1) sys.exit(1)
if path is None: if path is None:
print "Invalid documentation type '{doc_type}'. Valid options are: {options}".format( print(
doc_type=doc_type, options=valid_doc_types()) "Invalid documentation type '{doc_type}'. "
"Valid options are: {options}".format(
doc_type=doc_type, options=valid_doc_types()
)
)
sys.exit(1) sys.exit(1)
else: else:
......
...@@ -89,7 +89,7 @@ def prereq_cache(cache_name, paths, install_func): ...@@ -89,7 +89,7 @@ def prereq_cache(cache_name, paths, install_func):
cache_file.write(new_hash) cache_file.write(new_hash)
else: else:
print '{cache} unchanged, skipping...'.format(cache=cache_name) print('{cache} unchanged, skipping...'.format(cache=cache_name))
def install_ruby_prereqs(): def install_ruby_prereqs():
......
""" """
Run and manage servers for local development. Run and manage servers for local development.
""" """
from __future__ import print_function
import sys
import argparse import argparse
from paver.easy import * from paver.easy import *
from .utils.cmd import django_cmd from .utils.cmd import django_cmd
...@@ -21,7 +22,7 @@ def run_server(system, settings=None, port=None, skip_assets=False): ...@@ -21,7 +22,7 @@ def run_server(system, settings=None, port=None, skip_assets=False):
If `skip_assets` is True, skip the asset compilation step. If `skip_assets` is True, skip the asset compilation step.
""" """
if system not in ['lms', 'studio']: if system not in ['lms', 'studio']:
print "System must be either lms or studio" print("System must be either lms or studio", file=sys.stderr)
exit(1) exit(1)
if not skip_assets: if not skip_assets:
......
""" """
Helper functions for loading environment settings. Helper functions for loading environment settings.
""" """
from __future__ import print_function
import os import os
import sys import sys
import json import json
...@@ -34,7 +35,11 @@ class Env(object): ...@@ -34,7 +35,11 @@ class Env(object):
# If the file does not exist, issue a warning and return an empty dict # If the file does not exist, issue a warning and return an empty dict
if not os.path.isfile(env_path): if not os.path.isfile(env_path):
print "Warning: could not find environment JSON file at '{path}'".format(path=env_path) print(
"Warning: could not find environment JSON file "
"at '{path}'".format(path=env_path),
file=sys.stderr,
)
return dict() return dict()
# Otherwise, load the file as JSON and return the resulting dict # Otherwise, load the file as JSON and return the resulting dict
...@@ -43,7 +48,11 @@ class Env(object): ...@@ -43,7 +48,11 @@ class Env(object):
return json.load(env_file) return json.load(env_file)
except ValueError: except ValueError:
print "Error: Could not parse JSON in {path}".format(path=env_path) print(
"Error: Could not parse JSON "
"in {path}".format(path=env_path),
file=sys.stderr,
)
sys.exit(1) sys.exit(1)
@lazy @lazy
......
""" """
Helper functions for managing processes. Helper functions for managing processes.
""" """
from __future__ import print_function
import sys import sys
import os import os
import subprocess import subprocess
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment