├── .gitignore ├── .travis.yml ├── LICENSE ├── README.rst ├── demo.gif ├── demoshell ├── __main__.py └── main.py ├── requirements.txt ├── setup.cfg ├── setup.py ├── test ├── slowtest.sh └── subproc2.py ├── tools └── travis.sh └── tox.ini /.gitignore: -------------------------------------------------------------------------------- 1 | *.egg-info 2 | /AUTHORS 3 | /ChangeLog 4 | /dist 5 | .tox 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | # python: 4 | # - "3.5" 5 | # - "3.6" 6 | # - "nightly" 7 | 8 | # Test the nightly build of cpython, but ignore any failures. 9 | # Add separate test environments for the docs and flake8 linter. 10 | matrix: 11 | allow_failures: 12 | - python: "nightly" 13 | include: 14 | # - env: BUILD=docs 15 | - env: BUILD=linter 16 | 17 | # travis pre-installs some packages that may conflict with our test 18 | # dependencies, so remove them before we set ourselves up. Also 19 | # install pbr to avoid any setup_requires funkiness with 20 | # pip/setuptools. 21 | before_install: 22 | - pip uninstall -y nose mock 23 | - pip install pbr 24 | 25 | install: pip install .[test] .[docs] 26 | 27 | script: 28 | - ./tools/travis.sh -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | --- License for python-keystoneclient versions prior to 2.1 --- 178 | 179 | All rights reserved. 180 | 181 | Redistribution and use in source and binary forms, with or without 182 | modification, are permitted provided that the following conditions are met: 183 | 184 | 1. Redistributions of source code must retain the above copyright notice, 185 | this list of conditions and the following disclaimer. 186 | 187 | 2. Redistributions in binary form must reproduce the above copyright 188 | notice, this list of conditions and the following disclaimer in the 189 | documentation and/or other materials provided with the distribution. 190 | 191 | 3. Neither the name of this project nor the names of its contributors may 192 | be used to endorse or promote products derived from this software without 193 | specific prior written permission. 194 | 195 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 196 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 197 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 198 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 199 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 200 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 201 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 202 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 203 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 204 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 205 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Demo Shell 3 | ============ 4 | 5 | ``demoshell`` is a simplified shell for live demonstrations. It always 6 | shows the command prompt at the top of the screen and pushes command 7 | output down instead of letting iscroll up. 8 | 9 | Huh? 10 | ==== 11 | 12 | POSIX shells print their output in such a way that it scrolls up and 13 | off the top of the screen because they are using tty semantics, which 14 | are based on hardware that used to literally print everything on a 15 | roll of paper that moved up through the machine and over the top. 16 | 17 | It's the 21st century. We don't use paper-based terminals any 18 | more. While continuing to pretend we do is fine for day-to-day work, 19 | when we are giving live presentations it is not ideal because the most 20 | interesting thing you are doing is probably at the bottom of your 21 | screen during a live demo. That is the hardest part of the screen for 22 | people at the back of the room to see, because it is often blocked by 23 | other people's heads. 24 | 25 | ``demoshell`` avoids this problem by always keeping the command prompt 26 | at the top of the screen and showing the output of commands below, 27 | pushing older commands off of the bottom of the screen to make space 28 | for newer text. 29 | 30 | .. image:: demo.gif 31 | 32 | Using demoshell 33 | =============== 34 | 35 | Install the shell with ``pip3`` (it works best under Python 3):: 36 | 37 | $ pip3 install demoshell 38 | 39 | Run ``demoshell``:: 40 | 41 | $ demoshell 42 | 43 | Run any shell command at the prompt:: 44 | 45 | $ ls 46 | 47 | ls 48 | AUTHORS 49 | ChangeLog 50 | LICENSE 51 | README.rst 52 | demoshell 53 | demoshell.egg-info 54 | dist 55 | requirements.txt 56 | setup.cfg 57 | setup.py 58 | test 59 | 60 | Use ``exit`` or ``Ctrl-D`` to leave the shell. 61 | 62 | Use ``clear`` to clear the screen. 63 | 64 | Config File for DemoShell are in following location: 65 | 66 | If running on Mac OS: 67 | ~/Library/Application Support/DemoShell/demoshell.ini 68 | 69 | If running on Linux: 70 | ~/.local/share/DemoShell/demoshell.ini 71 | 72 | If running on Windows: 73 | C:\Documents and Settings\\Application Data\Local Settings\Doug Hellman\DemoShell\demoshell.ini 74 | OR: 75 | C:\Documents and Settings\\Application Data\Doug Hellman\DemoShell\demoshell.ini 76 | 77 | To add Aliases: 78 | Open config file in a text editor 79 | Edit "Aliases" section as per example below. 80 | alias = alias command. It may look something like below. 81 | 82 | [Aliases] 83 | ll = ls -la 84 | 85 | Resources 86 | ========= 87 | 88 | * GitHub: https://github.com/dhellmann/demoshell 89 | * Bugs: https://github.com/dhellmann/demoshell/issues 90 | * Documentation: *Help wanted!* 91 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhellmann/demoshell/6069af1e528b82db1bd215af75dbff5ceb525f5d/demo.gif -------------------------------------------------------------------------------- /demoshell/__main__.py: -------------------------------------------------------------------------------- 1 | from . import main 2 | 3 | 4 | __name__ == '__main__' and main.main() 5 | -------------------------------------------------------------------------------- /demoshell/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # TODO: record history and map arrow keys to navigating it 4 | # TODO: configuration file to load palette, shell, etc. 5 | # TODO: what to do about ctrl-l for clearing the screen 6 | # TODO: ctrl-c handling 7 | # TODO: fix output mingling between commands by using different widgets? 8 | # TODO: allow the config file to define new builtins 9 | # TODO: allow the config file to define aliases to handle the "ll" case 10 | # TODO: figure out how to map ctrl-l to clear 11 | 12 | import functools 13 | import subprocess 14 | import urwid 15 | import os 16 | import appdirs 17 | import configparser 18 | 19 | # Remove default map of ctrl + l 20 | del urwid.command_map['ctrl l'] 21 | 22 | 23 | class DemoShell: 24 | 25 | palette = [ 26 | ('spacer', 'white', 'white'), 27 | ('stdout', 'black', 'white'), 28 | ('stderr', 'light red', 'white'), 29 | ('command', 'black', 'light gray'), 30 | ('error', 'light red', 'black'), 31 | ] 32 | 33 | def __init__(self): 34 | self.last_command = None 35 | self.output_widget = urwid.Text(markup='') 36 | self.prompt_widget = urwid.Edit("$ ") 37 | self.frame_widget = urwid.Frame( 38 | header=self.prompt_widget, 39 | body=urwid.Filler(self.output_widget, valign='top'), 40 | focus_part='header', 41 | ) 42 | self._builtins = { 43 | 'exit': self._exit, 44 | 'clear': self._clear, 45 | } 46 | 47 | self._aliases = {} 48 | self._load_config() 49 | 50 | def run(self): 51 | self.loop = urwid.MainLoop( 52 | self.frame_widget, 53 | unhandled_input=self.on_enter, 54 | palette=self.palette, 55 | ) 56 | try: 57 | old = self.loop.screen.tty_signal_keys( 58 | 'undefined', 'undefined', 'undefined', 59 | 'undefined', 'undefined') 60 | self.loop.run() 61 | finally: 62 | self.loop.screen.tty_signal_keys(*old) 63 | 64 | def _exit(self): 65 | raise urwid.ExitMainLoop() 66 | 67 | def on_enter(self, key): 68 | if key == 'enter': 69 | cmd = self.prompt_widget.text 70 | cmd = cmd.lstrip('$ ') 71 | if cmd == '': 72 | self.extend_text('error', '') 73 | 74 | if cmd in self._aliases: 75 | # Insert code to print the alias here. 76 | cmd = self._aliases[cmd] 77 | 78 | if cmd in self._builtins: 79 | self._builtins[cmd]() 80 | elif cmd: 81 | self._run_external_command(cmd) 82 | self.prompt_widget.set_edit_text('') 83 | 84 | elif key == 'ctrl l': 85 | self._clear() 86 | 87 | elif key == 'ctrl c': 88 | if (not self.last_command) or isinstance( 89 | self.last_command.poll(), int): 90 | pass 91 | else: 92 | self.last_command.terminate() 93 | 94 | elif key == 'ctrl d': 95 | self._exit() 96 | 97 | elif key in ('left', 'right', 'backspace'): 98 | # Trying to move past the edges of the input text when 99 | # editing. Ignore. 100 | pass 101 | 102 | elif isinstance(key, tuple) and key[0].startswith('mouse '): 103 | pass 104 | 105 | else: 106 | self.extend_text( 107 | 'error', 108 | 'Unknown keypress {!r}'.format(key), 109 | ) 110 | 111 | def _run_external_command(self, cmd): 112 | self.extend_text('command', cmd + '\n') 113 | stdout_fd = self.loop.watch_pipe( 114 | functools.partial( 115 | self.received_output, 116 | style='stdout', 117 | ) 118 | ) 119 | stderr_fd = self.loop.watch_pipe( 120 | functools.partial( 121 | self.received_output, 122 | style='stderr', 123 | ) 124 | ) 125 | self.last_command = subprocess.Popen( 126 | cmd, 127 | stdout=stdout_fd, 128 | stderr=stderr_fd, 129 | close_fds=True, 130 | shell=True, 131 | executable='/bin/bash', 132 | ) 133 | 134 | def _clear(self): 135 | self.output_widget.set_text('') 136 | 137 | def extend_text(self, style, text): 138 | existing = self.output_widget.get_text() 139 | parts = [] 140 | start = 0 141 | existing_text = existing[0] 142 | for attr, count in existing[1]: 143 | parts.append((attr, existing_text[start:start + count])) 144 | start += count 145 | if style == 'command': 146 | # insert a new command entry and an empty stdout entry, in 147 | # reverse order because we're pushing them onto the front of 148 | # the list 149 | parts.insert(0, ('stdout', '')) 150 | parts.insert(0, ('stderr', '')) 151 | parts.insert(0, (style, text)) 152 | parts.insert(0, ('spacer', '\n')) 153 | elif style == 'error': 154 | parts.insert(0, (style, text.rstrip() + '\n')) 155 | elif style in ('stdout', 'stderr'): 156 | # Append to the most recently added block of the right style. 157 | loc = None 158 | for i, p in enumerate(parts): 159 | if p[0] == style: 160 | loc = i 161 | break 162 | else: 163 | raise RuntimeError('did not find stdout block') 164 | new_text = parts[loc][1] + text 165 | parts[loc] = (parts[loc][0], new_text) 166 | else: 167 | raise ValueError('unknown style {} used for {!r}'.format( 168 | style, text)) 169 | self.output_widget.set_text(parts) 170 | 171 | def received_output(self, data, style): 172 | self.extend_text(style, data.decode('utf-8')) 173 | 174 | def _load_config(self): 175 | appname = "demoshell" 176 | data_dir = appdirs.user_data_dir(appname) 177 | config_filename = os.path.join(data_dir, "demoshell.ini") 178 | 179 | self.config = configparser.ConfigParser() 180 | files_read = self.config.read(config_filename) 181 | 182 | if not files_read: 183 | self.config.add_section('Aliases') 184 | 185 | if not os.path.isdir(data_dir): 186 | os.makedirs(data_dir) 187 | 188 | with open(config_filename, 'w+') as config_file: 189 | self.config.write(config_file) 190 | 191 | # Copy the aliases into a data structure to make them easier 192 | # to access. 193 | self._aliases = dict(self.config['Aliases'].items()) 194 | 195 | 196 | def main(): 197 | DemoShell().run() 198 | 199 | 200 | if __name__ == '__main__': 201 | main() 202 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | urwid>=2.0.1 2 | appdirs>=1.4.3 3 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = demoshell 3 | summary = Simplified Shell for Live Demos 4 | description-file = 5 | README.rst 6 | author = Doug Hellmann 7 | author-email = doug@doughellmann.com 8 | home-page = https://pypi.python.org/pypi/demoshell 9 | classifier = 10 | Development Status :: 3 - Alpha 11 | Environment :: Console 12 | Intended Audience :: Developers 13 | Intended Audience :: Education 14 | Intended Audience :: End Users/Desktop 15 | Intended Audience :: Information Technology 16 | Intended Audience :: Science/Research 17 | License :: OSI Approved :: Apache Software License 18 | Programming Language :: Python 19 | Programming Language :: Python :: 3 20 | 21 | [files] 22 | packages = demoshell 23 | 24 | [entry_points] 25 | console_scripts = 26 | demoshell = demoshell.main:main 27 | 28 | [extras] 29 | test = 30 | flake8 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | # implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import setuptools 18 | 19 | setuptools.setup( 20 | setup_requires=['pbr'], 21 | pbr=True) 22 | -------------------------------------------------------------------------------- /test/slowtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | python subproc2.py 362923067964327863989661926737477737673859044111968554257667 4 | -------------------------------------------------------------------------------- /test/subproc2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # this is part of the subproc.py example 3 | 4 | from __future__ import print_function 5 | 6 | import sys 7 | 8 | try: 9 | range = xrange 10 | except NameError: 11 | pass 12 | 13 | num = int(sys.argv[1]) 14 | for c in range(1, 10000000): 15 | if num % c == 0: 16 | print("factor:", c) 17 | -------------------------------------------------------------------------------- /tools/travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run the build mode specified by the BUILD variable, defined in 4 | # .travis.yml. When the variable is unset, assume we should run the 5 | # standard test suite. 6 | 7 | rootdir=$(dirname $(dirname $0)) 8 | 9 | # Show the commands being run. 10 | set -x 11 | 12 | # Exit on any error. 13 | set -e 14 | 15 | case "$BUILD" in 16 | docs) 17 | python setup.py build_sphinx;; 18 | linter) 19 | flake8;; 20 | *) 21 | pytest -v \ 22 | --cov=imapautofiler \ 23 | --cov-report term-missing \ 24 | --cov-config $rootdir/.coveragerc \ 25 | $@;; 26 | esac 27 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | distribute = False 3 | envlist = linter,py35,py36 4 | 5 | [testenv] 6 | deps = .[test] 7 | setenv = VIRTUAL_ENV={envdir} 8 | commands = 9 | {toxinidir}/tools/travis.sh '{posargs}' 10 | 11 | [testenv:linter] 12 | basepython = python3.6 13 | setenv = BUILD=linter 14 | 15 | [flake8] 16 | show-source = True 17 | exclude = .tox,dist,doc,*.egg,build 18 | 19 | [testenv:docs] 20 | setenv = BUILD=linter 21 | deps = 22 | .[docs] 23 | 24 | [testenv:testdata] 25 | deps = 26 | .[test] 27 | commands = 28 | {toxinidir}/tools/maildir_test_data.py {posargs} 29 | --------------------------------------------------------------------------------