Move modules from dcos.api to dcos

This commit is contained in:
José Armando García Sancio
2015-04-29 21:44:53 -07:00
parent 2de5c353e3
commit 5a340cba96
33 changed files with 137 additions and 111 deletions

View File

@@ -6,7 +6,7 @@ import uuid
import dcoscli
import requests
import rollbar
from dcos.api import util
from dcos import util
from dcoscli.constants import (ROLLBAR_SERVER_POST_KEY,
SEGMENT_IO_CLI_ERROR_EVENT,
SEGMENT_IO_CLI_EVENT, SEGMENT_IO_WRITE_KEY_DEV,

View File

@@ -31,8 +31,8 @@ import docopt
import pkg_resources
import six
import toml
from dcos.api import (cmds, config, constants, emitting, errors, http,
jsonitem, options, subcommand, util)
from dcos import (cmds, config, constants, emitting, errors, http, jsonitem,
options, subcommand, util)
from dcoscli.analytics import segment_identify
emitter = emitting.FlatEmitter()
@@ -92,7 +92,7 @@ def compare_validations(toml_config_pre, toml_config_post):
def _cmds():
"""
:returns: all the supported commands
:rtype: list of dcos.api.cmds.Command
:rtype: list of dcos.cmds.Command
"""
return [
@@ -360,9 +360,9 @@ def _generate_choice_msg(name, value):
:param name: name of the property
:type name: str
:param value: dictionary for the value
:type value: dcos.api.config.Toml
:type value: dcos.config.Toml
:returns: an error message for top level properties
:rtype: dcos.api.errors.Error
:rtype: dcos.errors.Error
"""
message = ("Property {!r} doesn't fully specify a value - "
@@ -401,7 +401,7 @@ def _get_config_schema(command):
:param command: the subcommand name
:type command: str
:returns: the subcommand's configuration schema
:rtype: (dict, dcos.api.errors.Error)
:rtype: (dict, dcos.errors.Error)
"""
# core.* config variables are special. They're valid, but don't
@@ -448,7 +448,7 @@ def _parse_array_item(name, value):
:param value: the value to parse
:type value: str
:returns: the parsed value as an array with one element
:rtype: (list of any, dcos.api.errors.Error) where any is string, int,
:rtype: (list of any, dcos.errors.Error) where any is string, int,
float, bool, array or dict
"""

View File

@@ -12,7 +12,7 @@ Options:
import dcoscli
import docopt
import futures
from dcos.api import cmds, emitting, options, subcommand, util
from dcos import cmds, emitting, options, subcommand, util
emitter = emitting.FlatEmitter()
logger = util.get_logger(__name__)
@@ -40,7 +40,7 @@ def main():
def _cmds():
"""
:returns: All of the supported commands
:rtype: list of dcos.api.cmds.Command
:rtype: list of dcos.cmds.Command
"""
return [

View File

@@ -37,7 +37,7 @@ from subprocess import PIPE, Popen
import dcoscli
import docopt
from dcos.api import auth, constants, emitting, errors, http, subcommand, util
from dcos import auth, constants, emitting, errors, http, subcommand, util
from dcoscli import analytics
emitter = emitting.FlatEmitter()

View File

@@ -60,7 +60,7 @@ import time
import dcoscli
import docopt
import pkg_resources
from dcos.api import cmds, emitting, errors, jsonitem, marathon, options, util
from dcos import cmds, emitting, errors, jsonitem, marathon, options, util
logger = util.get_logger(__name__)
emitter = emitting.FlatEmitter()
@@ -88,7 +88,7 @@ def main():
def _cmds():
"""
:returns: all the supported commands
:rtype: dcos.api.cmds.Command
:rtype: dcos.cmds.Command
"""
return [
@@ -752,7 +752,7 @@ def _update_from_stdin(app_id, force):
def _calculate_version(client, app_id, version):
"""
:param client: Marathon client
:type client: dcos.api.marathon.Client
:type client: dcos.marathon.Client
:param app_id: The ID of the application
:type app_id: str
:param version: Relative or absolute version or None

View File

@@ -50,8 +50,8 @@ import json
import dcoscli
import docopt
import pkg_resources
from dcos.api import (cmds, emitting, errors, marathon, options, package,
subcommand, util)
from dcos import (cmds, emitting, errors, marathon, options, package,
subcommand, util)
logger = util.get_logger(__name__)
@@ -80,7 +80,7 @@ def main():
def _cmds():
"""
:returns: All of the supported commands
:rtype: dcos.api.cmds.Command
:rtype: dcos.cmds.Command
"""
return [

View File

@@ -4,7 +4,7 @@ from functools import wraps
import dcoscli.analytics
import requests
import rollbar
from dcos.api import constants, util
from dcos import constants, util
from dcoscli.analytics import _base_properties
from dcoscli.config.main import main as config_main
from dcoscli.constants import (ROLLBAR_SERVER_POST_KEY,

View File

@@ -1,7 +1,7 @@
import os
import webbrowser
from dcos.api import auth, constants, util
from dcos import auth, constants, util
from dcoscli.main import main
from mock import Mock, patch
@@ -15,7 +15,7 @@ def test_no_browser_auth():
def test_when_authenticated():
with patch('dcos.api.auth.force_auth'):
with patch('dcos.auth.force_auth'):
_mock_dcos_run([util.which('dcos')], True)
assert auth.force_auth.call_count == 0

View File

@@ -3,7 +3,7 @@ import os
import dcoscli.constants as cli_constants
import six
from dcos.api import constants
from dcos import constants
import pytest
from common import assert_command, exec_command

View File

@@ -1,6 +1,6 @@
import os
from dcos.api import constants
from dcos import constants
from common import assert_command, exec_command

View File

@@ -2,7 +2,7 @@ import json
import os
import six
from dcos.api import subcommand
from dcos import subcommand
from common import assert_command, exec_command

View File

View File

@@ -4,7 +4,7 @@ import uuid
import pkg_resources
import toml
from dcos.api import config, constants, emitting, errors, http, jsonitem, util
from dcos import config, constants, emitting, errors, http, jsonitem, util
from six import iteritems, moves
from oauth2client import client
@@ -23,7 +23,7 @@ def _authorize():
"""Create OAuth flow and authorize user
:return: Tuple of credentials dict end Error
:rtype: (dict, dcos.api.errors.Error)
:rtype: (dict, dcos.errors.Error)
"""
try:
flow = client.OAuth2WebServerFlow(

View File

@@ -1,6 +1,6 @@
import collections
from dcos.api import errors
from dcos import errors
Command = collections.namedtuple(
'Command',

View File

@@ -11,7 +11,7 @@ import sys
import pager
import pygments
import six
from dcos.api import constants, errors, util
from dcos import constants, errors, util
from pygments.formatters import Terminal256Formatter
from pygments.lexers import JsonLexer
@@ -67,7 +67,7 @@ def print_handler(event):
"""Default handler for printing event to stdout.
:param event: event to emit to stdout
:type event: str, dict, list, or dcos.api.errors.Error
:type event: str, dict, list, or dcos.errors.Error
"""
pager_command = os.environ.get(constants.DCOS_PAGER_COMMAND_ENV)
@@ -98,7 +98,7 @@ def _process_json(event, pager_command):
"""Conditionally highlights the supplied JSON value.
:param event: event to emit to stdout
:type event: str, dict, list, or dcos.api.errors.Error
:type event: str, dict, list, or dcos.errors.Error
:returns: String representation of the supplied JSON value,
possibly syntax-highlighted.
:rtype: str

View File

@@ -1,6 +1,6 @@
import requests
from dcos.api import util
from dcos.api.errors import DefaultError, Error
from dcos import util
from dcos.errors import DefaultError, Error
logger = util.get_logger(__name__)

View File

@@ -1,7 +1,7 @@
import collections
import json
from dcos.api import errors
from dcos import errors
def parse_json_item(json_item, schema):

View File

@@ -1,7 +1,7 @@
import json
from dcos.api import http, util
from dcos.api.errors import DefaultError, Error
from dcos import http, util
from dcos.errors import DefaultError, Error
try:
from urllib import quote
@@ -17,7 +17,7 @@ def create_client(config=None):
:param config: configuration dictionary
:type config: config.Toml
:returns: Marathon client
:rtype: dcos.api.marathon.Client
:rtype: dcos.marathon.Client
"""
if config is None:
config = util.get_config()
@@ -435,7 +435,7 @@ class Client(object):
:param app_id: the id of the application to restart
:type app_id: str
:returns: a list of tasks
:rtype: (list of dict, dcos.api.errors.Error)
:rtype: (list of dict, dcos.errors.Error)
"""
url = self._create_url('v2/tasks')
@@ -461,7 +461,7 @@ class Client(object):
:param task_id: the id of the task
:type task_id: str
:returns: a tasks
:rtype: (dict, dcos.api.errors.Error)
:rtype: (dict, dcos.errors.Error)
"""
url = self._create_url('v2/tasks')

View File

@@ -14,7 +14,7 @@ import git
import portalocker
import pystache
import six
from dcos.api import constants, emitting, errors, marathon, subcommand, util
from dcos import constants, emitting, errors, marathon, subcommand, util
from six.moves import urllib
@@ -452,7 +452,7 @@ def search(query, cfg):
:param query: The search term
:type query: str
:param cfg: Configuration dictionary
:type cfg: dcos.api.config.Toml
:type cfg: dcos.config.Toml
:rtype: (list of IndexEntries, Error)
"""
@@ -567,7 +567,7 @@ def resolve_package(package_name, config):
:param package_name: The name of the package to resolve
:type package_name: str
:param config: Configuration dictionary
:type config: dcos.api.config.Toml
:type config: dcos.config.Toml
:returns: The named package, if found
:rtype: (Package, Error)
"""
@@ -588,7 +588,7 @@ def registries(config):
"""Returns configured cached package registries.
:param config: Configuration dictionary
:type config: dcos.api.config.Toml
:type config: dcos.config.Toml
:returns: The list of registries, in resolution order
:rtype: ([Registry], Error)
"""
@@ -605,7 +605,7 @@ def list_sources(config):
"""List configured package sources.
:param config: Configuration dictionary
:type config: dcos.api.config.Toml
:type config: dcos.config.Toml
:returns: The list of sources, in resolution order
:rtype: (list of Source, Error)
"""
@@ -677,7 +677,7 @@ def update_sources(config, validate=False):
"""Overwrites the local package cache with the latest source data.
:param config: Configuration dictionary
:type config: dcos.api.config.Toml
:type config: dcos.config.Toml
:returns: Error, if any.
:rtype: list of Error
"""
@@ -783,7 +783,7 @@ class Source:
"""Returns the file system path to this source's local cache.
:param config: Configuration dictionary
:type config: dcos.api.config.Toml
:type config: dcos.config.Toml
:returns: Path to this source's local cache on disk
:rtype: str or None
"""
@@ -1145,7 +1145,7 @@ class Package():
:param user_options: package parameters
:type user_options: dict
:returns: a dictionary with the user supplied options
:rtype: (dict, dcos.api.errors.Error)
:rtype: (dict, dcos.errors.Error)
"""
if user_options is None:

View File

@@ -5,7 +5,7 @@ import os
import shutil
import subprocess
from dcos.api import constants, errors, util
from dcos import constants, errors, util
logger = util.get_logger(__name__)
@@ -18,7 +18,7 @@ def command_executables(subcommand, dcos_path):
:param dcos_path: path to the dcos cli directory
:type dcos_path: str
:returns: the dcos program path
:rtype: (str, dcos.api.errors.Error)
:rtype: (str, dcos.errors.Error)
"""
executables = [
@@ -235,7 +235,7 @@ def _install_env(pkg, version, options):
:param options: package parameters
:type options: dict
:returns: an error if the subcommand failed; None otherwise
:rtype: dcos.api.errors.Error
:rtype: dcos.errors.Error
"""
pkg_dir = package_dir(pkg.name())
@@ -268,7 +268,7 @@ def install(pkg, version, options):
:param options: package parameters
:type options: dict
:returns: an error if the subcommand failed; None otherwise
:rtype: dcos.api.errors.Error
:rtype: dcos.errors.Error
"""
pkg_dir = package_dir(pkg.name())
@@ -338,7 +338,7 @@ def install_with_pip(
:param requirements: the list of pip requirements
:type requirements: list of str
:returns: an Error if it failed to install the package; None otherwise
:rtype: dcos.api.errors.Error
:rtype: dcos.errors.Error
"""
bin_directory = os.path.join(util.dcos_path(), BIN_DIRECTORY)
@@ -408,7 +408,7 @@ def _generic_error(package_name):
:param package: package name
:type: str
:returns: generic error when installing package
:rtype: dcos.api.errors.Error
:rtype: dcos.errors.Error
"""
return errors.DefaultError(

View File

@@ -11,7 +11,7 @@ import tempfile
import jsonschema
import pystache
import six
from dcos.api import config, constants, errors
from dcos import config, constants, errors
@contextlib.contextmanager
@@ -141,7 +141,7 @@ def configure_logger_from_environ():
:returns: An Error if we were unable to configure logging from the
environment; None otherwise
:rtype: dcos.api.errors.DefaultError
:rtype: dcos.errors.DefaultError
"""
return configure_logger(os.environ.get(constants.DCOS_LOG_LEVEL_ENV))
@@ -153,7 +153,7 @@ def configure_logger(log_level):
:param log_level: Log level for configuring logging
:type log_level: str
:returns: An Error if we were unable to configure logging; None otherwise
:rtype: dcos.api.errors.DefaultError
:rtype: dcos.errors.DefaultError
"""
if log_level is None:
logging.disable(logging.CRITICAL)

View File

@@ -1,86 +1,112 @@
API Documentation
=================
The :mod:`dcos.api.cmds` Module
---------------------------------
The :mod:`dcos.auth` Module
---------------------------
.. automodule:: dcos.api.cmds
.. automodule:: dcos.auth
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.api.config` Module
---------------------------------
The :mod:`dcos.cmds` Module
---------------------------
.. automodule:: dcos.api.config
.. automodule:: dcos.cmds
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.api.constants` Module
------------------------------------
The :mod:`dcos.config` Module
-----------------------------
.. automodule:: dcos.api.constants
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.api.emitting` Module
------------------------------------
.. automodule:: dcos.api.emitting
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.api.errors` Module
------------------------------------
.. automodule:: dcos.api.errors
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.api.jsonitem` Module
------------------------------------
.. automodule:: dcos.api.jsonitem
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.api.marathon` Module
------------------------------------
.. automodule:: dcos.api.marathon
.. automodule:: dcos.config
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.api.options` Module
------------------------------------
The :mod:`dcos.constants` Module
--------------------------------
.. automodule:: dcos.api.options
.. automodule:: dcos.constants
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.api.package` Module
------------------------------------
The :mod:`dcos.emitting` Module
-------------------------------
.. automodule:: dcos.api.package
.. automodule:: dcos.emitting
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.errors` Module
-----------------------------
.. automodule:: dcos.errors
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.http` Module
-----------------------------
.. automodule:: dcos.http
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.jsonitem` Module
-------------------------------
.. automodule:: dcos.jsonitem
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.marathon` Module
-------------------------------
.. automodule:: dcos.marathon
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.api.util` Module
------------------------------------
The :mod:`dcos.options` Module
------------------------------
.. automodule:: dcos.api.util
.. automodule:: dcos.options
:members:
:undoc-members:
:show-inheritance:
The :mod:`dcos.package` Module
------------------------------
.. automodule:: dcos.package
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.subcommand` Module
------------------------------
.. automodule:: dcos.subcommand
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
The :mod:`dcos.util` Module
---------------------------
.. automodule:: dcos.util
:members:
:undoc-members:
:show-inheritance:

View File

@@ -1,4 +1,4 @@
from dcos.api import cmds, errors
from dcos import cmds, errors
import pytest

View File

@@ -1,4 +1,4 @@
from dcos.api import config
from dcos import config
import pytest

View File

@@ -1,4 +1,4 @@
from dcos.api import errors, jsonitem
from dcos import errors, jsonitem
import pytest

View File

@@ -1,4 +1,4 @@
from dcos.api import options
from dcos import options
def test_extend_usage_docopt():

View File

@@ -1,6 +1,6 @@
import collections
from dcos.api import package
from dcos import package
import pytest

View File

@@ -1,4 +1,4 @@
from dcos.api import subcommand
from dcos import subcommand
def test_noun():

View File

@@ -1,4 +1,4 @@
from dcos.api import util
from dcos import util
def test_render_mustache_json():