Skip to content

Commit

Permalink
Refactor kalite.kalitectl to kalite.cli and invoke kalite.__main__ fr…
Browse files Browse the repository at this point in the history
…om bin/kalite
  • Loading branch information
Benjamin Bach committed Sep 30, 2016
1 parent 54aacdd commit 239293c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 53 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# MANIFEST.in is generated with basic
# layout of MANIFEST.in.dist

include kalitectl.py
include LICENSE
include README.rst
include setup.cfg
Expand Down
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,7 @@ test-all:
# tox

coverage:
coverage run --source kalite kalitectl.py test
coverage report -m

coverage-bdd:
coverage run --source kalite kalitectl.py test --bdd-only
coverage report -m

coverage-nobdd:
coverage run --source kalite kalitectl.py test --no-bdd
coverage run --source kalite bin/kalite test
coverage report -m

docs:
Expand Down
6 changes: 3 additions & 3 deletions bin/kalite
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if python_executable:

# Open up a process and proxy both the process' stdout and stderr
p = subprocess.Popen(
[python_executable, "-m", "kalite.kalitectl"] + args,
[python_executable, "-m", "kalite"] + args,
env=env,
)

Expand All @@ -155,5 +155,5 @@ if python_executable:
# best option....
else:

from kalite import kalitectl
kalitectl.cli()
from kalite import cli
cli.main()
2 changes: 1 addition & 1 deletion docs/developer_docs/behave_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Running the integration tests

To get the dependencies run ```pip install -r dev_requirements.txt```. This should install the correct version of behave. Selenium is also required but is currently included in our python-packages directory.

To run the tests simply run ```python kalitectl.py manage test``` just like you used to. This will automatically search out tests using both the unit test framework and the behave framework. You can specify apps, but right now there's no way to just run integration tests.
To run the tests simply run ```bin/kalite manage test``` just like you used to. This will automatically search out tests using both the unit test framework and the behave framework. You can specify apps, but right now there's no way to just run integration tests.

Running a specific test
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
47 changes: 28 additions & 19 deletions docs/installguide/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ This is a draft of what will be released. Notes are not fully accurate or final.
Deprecations / removals
^^^^^^^^^^^^^^^^^^^^^^^

.. note::
These deprecations are harmless if you installed KA Lite using an installer
and only relevant in these cases:
* You run a specialized setup or deployment
* Your deployment is 1½+ years old
* You're a KA Lite developer

* (List of removed commands)
* The bundled ``requests`` library is now version 2.1.1 :url-issue:`5263`
* All files distributed as "data files" in ``/usr/share/kalite`` (or similar location) has been removed. It is all located as "package data", meaning that several upgrade issues are fixed moving forwards.
* The parts of `kalite.testing` application that were related to benchmarks. These commands have been unmaintained and are outdated. Now the application's sole focus is utilities for CI.
* The whole `kalite.basetests` application has been removed. It was used to do nonsensical tests of the host system, not actual unit or functional testing.
* `kalite.updates.management.commands.classes` moved so it doesn't show up as a command `classes`.
* `python-packages/fle_utils/build`, unused build utility from 2013.
* The parts of ``kalite.testing`` application that were related to benchmarks. These commands have been unmaintained and are outdated. Now the application's sole focus is utilities for CI.
* The whole ``kalite.basetests`` application has been removed. It was used to do nonsensical tests of the host system, not actual unit or functional testing.
* ``kalite.updates.management.commands.classes`` moved so it doesn't show up as a command ``classes``.
* ``python-packages/fle_utils/build``, unused build utility from 2013.
* The ``manage.py`` script has been removed from the source tree (use ``bin/kalite manage <command>`` instead.)
* When running KA Lite straight from source, we used some very legacy convetions for data locations. But you can achieve the same effect by specifying a non-default locations using the ``KALITE_HOME`` environment variable. Example: ``KALITE_HOME=/path/to/.kalite kalite start``.

Command cleanup
^^^^^^^^^^^^^^^
Expand All @@ -26,21 +35,21 @@ In 0.17, we cleaned up a lot of unused/broken/deprecated commands,
In case you are using any of them (we hope not), you will have to pay attention
that the following management commands have been removed:

* `kalite manage gitmigrate`
* `kalite manage katest`
* `kalite manage initdconfig`
* `kalite manage nginxconfig`
* `kalite manage apacheconfig`
* `kalite manage todolist`
* `kalite manage i18nize_templates`
* `kalite manage benchmark`
* `kalite manage createmodel`
* `kalite manage modifymodel`
* `kalite manage readmodel`
* `kalite manage runcode`
* `kalite manage unpack_asessment_zip`
* `kalite manage create_dummy_language_pack`
* `kalite manage generate_blacklist`
* ``kalite manage gitmigrate``
* ``kalite manage katest``
* ``kalite manage initdconfig``
* ``kalite manage nginxconfig``
* ``kalite manage apacheconfig``
* ``kalite manage todolist``
* ``kalite manage i18nize_templates``
* ``kalite manage benchmark``
* ``kalite manage createmodel``
* ``kalite manage modifymodel``
* ``kalite manage readmodel``
* ``kalite manage runcode``
* ``kalite manage unpack_asessment_zip``
* ``kalite manage create_dummy_language_pack``
* ``kalite manage generate_blacklist``

Bug fixes
^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
USER_ROLES = ["guest", "coach", "admin", "learner"]
SS_DUMP_DIR = ".screenshot_dump"
OUTPUT_PATH = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), SS_DUMP_DIR))
KALITECTL_PATH = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "kalitectl.py"))
KALITECTL_PATH = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "bin", "kalite"))
# Formatted from subprocess.Popen
# Trying to import call_command to execute a Django mgmt command gets you
# into a weird import hell, probably because of import_all_child_modules...
Expand Down
7 changes: 7 additions & 0 deletions kalite/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import absolute_import

from .cli import main

if __name__ == "__main__":

main()
8 changes: 4 additions & 4 deletions kalite/kalitectl.py → kalite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def __init__(self, command, *args, **kwargs):
def run(self):
utility = ManagementUtility([os.path.basename(sys.argv[0]), self.command] + self.args)
# This ensures that 'kalite' is printed in help menus instead of
# 'kalitectl.py' (a part from the top most text in `kalite manage help`
# 'kalite' or 'kalite.__main__' (a part from the top most text in `kalite manage help`
utility.prog_name = 'kalite manage'
utility.execute()

Expand All @@ -413,7 +413,7 @@ def manage(command, args=None, as_thread=False):

utility = ManagementUtility([os.path.basename(sys.argv[0]), command] + args)
# This ensures that 'kalite' is printed in help menus instead of
# 'kalitectl.py' (a part from the top most text in `kalite manage help`
# 'kalite' or 'kalite.__main__' (a part from the top most text in `kalite manage help`
utility.prog_name = 'kalite manage'
utility.execute()
else:
Expand Down Expand Up @@ -911,7 +911,7 @@ def docopt(doc, argv=None, help=True, version=None, options_first=False): # @Re
raise DocoptExit()


def cli():
def main():

# Since positional arguments should always come first, we can safely
# replace " " with "=" to make options "--xy z" same as "--xy=z".
Expand Down Expand Up @@ -964,4 +964,4 @@ def cli():

if __name__ == "__main__":

cli()
main()
2 changes: 1 addition & 1 deletion kalite/distributed/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Functions, for support
########################

# This defaults to 8008, which is also the default of kalitectl.py which should
# This defaults to 8008, which is also the default of kalite.__main__ which should
# always set KALITE_LISTEN_PORT
HTTP_PORT = os.environ.get('KALITE_LISTEN_PORT', 8008)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Command(BaseCommand):
args = ""
help = _("Used by kalitectl.py to run a blocking management command")
help = _("Invoked by kalite CLI to run a blocking management command")

option_list = BaseCommand.option_list + ()

Expand Down
8 changes: 1 addition & 7 deletions kalite/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,7 @@
default_source_path = '.'

# Indicates that we are in a git repo
IS_SOURCE = (
os.path.exists(os.path.join(default_source_path, '.KALITE_SOURCE_DIR')) and
(
'kalitectl.py' not in sys.argv[0] or
os.path.realpath(sys.argv[0]) == os.path.realpath(os.path.join(default_source_path, 'kalitectl.py'))
)
)
IS_SOURCE = os.path.exists(os.path.join(default_source_path, '.KALITE_SOURCE_DIR'))
SOURCE_DIR = None

DB_TEMPLATE_DIR = os.path.join(
Expand Down
6 changes: 0 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,6 @@ def filter_illegal_extensions(f):
gen_data_files(os.path.join('docs', '_build', 'html'), optional=True)
)

# For now, just disguise the kalitectl.py script here as it's only to be accessed
# with the bin/kalite proxy.
data_files += [(
kalite.ROOT_DATA_PATH, [os.path.join(where_am_i, 'kalitectl.py')]
)]


################
# Windows code #
Expand Down

0 comments on commit 239293c

Please sign in to comment.