pax_global_header00006660000000000000000000000064132376641520014523gustar00rootroot0000000000000052 comment=0e6c310eeaee67c31856dc1ca503479f1ea141ac .dockerignore000066400000000000000000000000201323766415200135330ustar00rootroot00000000000000dist/* **/*.pyc .gitignore000066400000000000000000000001041323766415200130520ustar00rootroot00000000000000/dist tmp *.pyc *.tar.gz *.tar.bz2 *.tar.xz *.zip *.egg-info /build .travis.yml000066400000000000000000000003041323766415200131750ustar00rootroot00000000000000sudo: false language: python python: - "3.4" - "3.5" - "3.6" - "3.7-dev" before_install: - pip install pep8 script: - find . -name \*.py -exec pep8 --ignore=E501 {} + - make test CHANGELOG.md000066400000000000000000000135341323766415200127060ustar00rootroot00000000000000# asciinema changelog ## 2.0 (2018-02-10) This major release brings many new features, improvements and bugfixes. The most notable ones: * new [asciicast v2 file format](doc/asciicast-v2.md) * recording and playback of arbitrarily long session with minimal memory usage * ability to live-stream via UNIX pipe: `asciinema rec unix.pipe` + `asciinema play unix.pipe` in second terminal tab/window * optional stdin recording (`asciinema rec --stdin`) * appending to existing recording (`asciinema rec --append `) * raw recording mode, storing only stdout bytes (`asciinema rec --raw `) * environment variable white-listing (`asciinema rec --env="VAR1,VAR2..."`) * toggling pause in `asciinema play` by Space * stepping through a recording one frame at a time with . (when playback paused) * new `asciinema cat ` command to dump full output of the recording * playback from new IPFS URL scheme: `dweb:/ipfs/` (replaces `fs:/`) * lots of other bugfixes and improvements * dropped official support for Python 3.3 (although it still works on 3.3) ## 1.4.0 (2017-04-11) * Dropped distutils fallback in setup.py - setuptools required now (thanks Jakub "@jakubjedelsky" Jedelsky!) * Dropped official support for Python 3.2 (although it still works on 3.2) * New `--speed` option for `asciinema play` (thanks Bastiaan "@bastiaanb" Bakker!) * Ability to set API token via `ASCIINEMA_API_TOKEN` env variable (thanks Samantha "@samdmarshall" Marshall!) * Improved shutdown on more signals: CHLD, HUP, TERM, QUIT (thanks Richard "@typerlc"!) * Fixed stdin handling during playback via `asciinema play` ## 1.3.0 (2016-07-13) This release brings back the original Python implementation of asciinema. It's based on 0.9.8 codebase and adds all features and bug fixes that have been implemented in asciinema's Go version between 0.9.8 and 1.2.0. Other notable changes: * Zero dependencies! (other than Python 3) * Fixed crash when resizing terminal window during recording (#167) * Fixed upload from IPv6 hosts (#94) * Improved UTF-8 charset detection (#160) * `-q/--quiet` option can be saved in config file now * Final "logout" (produced by csh) is now removed from recorded stdout * `rec` command now tries to write to target path before starting recording ## 1.2.0 (2016-02-22) * Added playback from stdin: `cat demo.json | asciinema play -` * Added playback from IPFS: `asciinema play ipfs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V` * Added playback from asciicast page URL: `asciinema play https://asciinema.org/a/22124` * `-q/--quiet` option added to `rec` command * Fixed handling of partial UTF-8 sequences in recorded stdout * Final "exit" is now removed from recorded stdout * Longer operations like uploading/downloading show "spinner" ## 1.1.1 (2015-06-21) * Fixed putting terminal in raw mode (fixes ctrl-o in nano) ## 1.1.0 (2015-05-25) * `--max-wait` option is now also available for `play` command * Added support for compilation on FreeBSD * Improved locale/charset detection * Improved upload error messages * New config file location (with backwards compatibility) ## 1.0.0 (2015-03-12) * `--max-wait` and `--yes` options can be saved in config file * Support for displaying warning messages returned from API * Also, see changes for 1.0.0 release candidates below ## 1.0.0.rc2 (2015-03-08) * All dependencies are vendored now in Godeps dir * Help message includes all commands with their possible options * `-y` and `-t` options have longer alternatives: `--yes`, `--title` * `--max-wait` option has shorter alternative: `-w` * Import paths changed to `github.com/asciinema/asciinema` due to repository renaming * `-y` also suppresess "please resize terminal" prompt ## 1.0.0.rc1 (2015-03-02) * New [asciicast file format](doc/asciicast-v1.md) * `rec` command can now record to file * New commands: `play ` and `upload ` * UTF-8 native locale is now required * Added handling of status 413 and 422 by printing user friendly message ## 0.9.9 (2014-12-17) * Rewritten in Go * License changed to GPLv3 * `--max-wait` option added to `rec` command * Recorded process has `ASCIINEMA_REC` env variable set (useful for "rec" indicator in shell's `$PROMPT/$RPROMPT`) * No more terminal resetting (via `reset` command) before and after recording * Informative messages are coloured to be distinguishable from normal output * Improved error messages ## 0.9.8 (2014-02-09) * Rename user_token to api_token * Improvements to test suite * Send User-Agent including client version number, python version and platform * Handle 503 status as server maintenance * Handle 404 response as a request for client upgrade ## 0.9.7 (2013-10-07) * Depend on requests==1.1.0, not 2.0 ## 0.9.6 (2013-10-06) * Remove install script * Introduce proper python package: https://pypi.python.org/pypi/asciinema * Make the code compatible with both python 2 and 3 * Use requests lib instead of urrlib(2) ## 0.9.5 (2013-10-04) * Fixed measurement of total recording time * Improvements to install script * Introduction of Homebrew formula ## 0.9.4 (2013-10-03) * Use python2.7 in shebang ## 0.9.3 (2013-10-03) * Re-enable resetting of a terminal before and after recording * Add Arch Linux source package ## 0.9.2 (2013-10-02) * Use os.uname over running the uname command * Add basic integration tests * Make PtyRecorder test stable again * Move install script out of bin dir ## 0.9.1 (2013-10-01) * Split monolithic script into separate classes/files * Remove upload queue * Use python2 in generated binary's shebang * Delay config file creation until user_token is requested * Introduce command classes for handling cli commands * Split the recorder into classes with well defined responsibilities * Drop curl dependency, use urllib(2) for http requests ## 0.9.0 (2013-09-24) * Project rename from "ascii.io" to "asciinema" ## ... limbo? ... ## 0.1 (2012-03-11) * Initial release CODE_OF_CONDUCT.md000066400000000000000000000062351323766415200136740ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@asciinema.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ CONTRIBUTING.md000066400000000000000000000072601323766415200133250ustar00rootroot00000000000000# Contributing to asciinema First, if you're opening a Github issue make sure it goes to the correct repository: * [asciinema/asciinema](https://github.com/asciinema/asciinema/issues) - command-line recorder * [asciinema/asciinema-server](https://github.com/asciinema/asciinema-server/issues) - public website hosting recordings * [asciinema/asciinema-player](https://github.com/asciinema/asciinema-player/issues) - player ## Reporting bugs Open an issue in Github issue tracker. Tell us what's the problem and include steps to reproduce it (reliably). Including your OS/browser/terminal name and version in the report would be great. ## Submitting patches with bug fixes If you found a bug and made a patch for it: * make sure all tests pass * send us a pull request, including a description of the fix (referencing an existing issue if there's one) ## Requesting new features We welcome all ideas. If you believe most asciinema users would benefit from implementing your idea then feel free to open a Github issue. However, as this is an open-source project maintained by a small team of volunteers we simply can't implement all of them due to limited resources. Please keep that in mind. ## Proposing features/changes (pull requests) If you want to propose code change, either introducing a new feature or improving an existing one, please first discuss this with asciinema team. You can simply open a separate issue for a discussion or join #asciinema IRC channel on freenode. ## Asking for help Github issue tracker is not a support forum. If you need help then either join #asciinema IRC channel on freenode or drop us an email at support@asciinema.org. ## Reporting security issues If you found a security issue in asciinema please contact us at support@asciinema.org. For the benefit of all asciinema users please **do not** publish details of the vulnerability in a Github issue. The PGP key below (1eb33a8760dec34b) can be used when sending encrypted email to or verifying responses from support@asciinema.org. ``` -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2 mQENBFRH/yQBCADwC8fadhrTTqCFEcQ8ex82FE24b2frRC3fvkFeKsY+v2lniYmZ wJ+qsd3cEv5uctCl+lQjrqhJrBx5DnZpCMw85vNuOhz/wjzn7efTISUF+HlnhiZd tN3FPbk4uu+1JiiZ7SEvH+I4JjM46Vx6wPZ9en79u8VPMLJ24F81Rar62oiMuL29 PGV7CdG+ErUHEQfN1qLaZNQqkPCQSAouxooNqXKjs/mmz2651FrP8TKVr2f6B/2O YJ++H9SoIp7Ly+/fEjgmdaZnGqfxnBC+Pm82tZguprWeh8pdiu9ieJswr4S9tRms h2+eht8PWwkaOOhcFdZLnJFoXHOPzHilQVutABEBAAG0KUFzY2lpbmVtYSBTdXBw b3J0IDxzdXBwb3J0QGFzY2lpbmVtYS5vcmc+iQE4BBMBAgAiBQJUR/8kAhsDBgsJ CAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAeszqHYN7DSyCeCADS9Jk7Ibl2f+2K eZ4XmYU0UxU55EtHZBd34yF+FGbl4doQhnKcRqT5lKLfYk4x3LzzPAHNSbRS05/K fw8l72GLHY01U/3slAixphIR8LwVyqPxwelTqLzkDvcK1TTTFnOM/XUT1ymNUS7i 6Bs889I4I8bPrnt1XK+W35/SqZbBAWotdidCbI/oKQgffCbVsH/Im5pnXTapvf/l sRUpB2fp7vD5+ycKDcB5CqbtnsPU9vCPL11GG3ijwQBgnPc0fKanUHb3IMElQ0ju 8IYTZjpPe7bIV3V3nYZvdO41IYLCHhRpvNt4BO2amQoGyqTqGHr/rCY1aEToDG2c cOdsEOmuuQENBFRH/yQBCACsR59NPSwGoK4zGgzDjuY7yLab2Tq1Jg1c038lA23G t3H9aOpVbeYGvDPYLHi2y1cCNv19nzs5/k/LAflhTcgPjipTHQ2ojDG+MNfO4qyH 3JFhm1WUw6zxFjBXfsZhoCKTNHZkzH+d0jeutbBq/Rd77sLjN/VVTLfzJCZhyhKD VEyO6DYaANZn1B/xx84WdxqqiQsLELOCQVUCG7HzbQAmx7lYYIUAwUoFTrBeBd+d sN7htw3j7le99EiccqMXceZd2W9cAlRfXcjHtvbtkbJTcsvANSUSU10q5uuT3f6l NftTLWOGZnu/rFU/ow5ipKft0ygfJKpMHD+AoLkiRIajABEBAAGJAR8EGAECAAkF AlRH/yQCGwwACgkQHrM6h2Dew0tG1wgAqOkkSznwF+6muK88GgrgasqnIq2t2VkN fTEKmykgSuMxiN4bsNLc4FQECZqIcL7zGuD6fFnsnO6Hg36R4rYGFSEsjjN7rXj0 QLnrJJLZV0oA6Q77fUqdB0he7uJm+nlQjUv8HNJwp1oIyhhHz/r1kTHUlX+bEMO3 Khc96UnE7nzwPBCbUvKuHJQY6K2ms1wgr9ELXjF1KVU9QtBtG2/XWRGDHDwQKxnW +2pRVtn2xNJ9rBipGG86ZU88vurYjgPZrXaex3M1QGD/8+9Wlp/TR7YUzjiZbtwc 6mpG4SUlwZheX9RbTRdjnLr7Qy+CddOWvGxebgk23/U90KrDyHDHig== =2M/2 -----END PGP PUBLIC KEY BLOCK----- ``` Dockerfile000066400000000000000000000007711323766415200130660ustar00rootroot00000000000000FROM ubuntu:16.04 RUN apt-get update && apt-get install -y \ ca-certificates \ locales \ python3 \ python3-setuptools RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 RUN mkdir /usr/src/app COPY setup.cfg /usr/src/app COPY setup.py /usr/src/app COPY README.md /usr/src/app COPY asciinema /usr/src/app/asciinema WORKDIR /usr/src/app RUN python3 setup.py install ENV LANG en_US.utf8 ENV SHELL /bin/bash ENV USER docker WORKDIR /root CMD ["asciinema", "rec"] LICENSE000066400000000000000000001045131323766415200121000ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . Makefile000066400000000000000000000011251323766415200125260ustar00rootroot00000000000000NAME=asciinema VERSION=`python3 -c "import asciinema; print(asciinema.__version__)"` test: test-unit test-integration test-unit: nosetests test-integration: tests/integration.sh release: test tag push release-test: test push-test tag: git tag | grep "v$(VERSION)" && echo "Tag v$(VERSION) exists" && exit 1 || true git tag -s -m "Releasing $(VERSION)" v$(VERSION) git push --tags push: python3 setup.py sdist upload -r pypi push-test: python3 setup.py sdist upload -r pypitest release: test tag push .PHONY: test test-unit test-integration release release-test tag push push-test README.md000066400000000000000000000310171323766415200123500ustar00rootroot00000000000000# asciinema [![Build Status](https://travis-ci.org/asciinema/asciinema.svg?branch=master)](https://travis-ci.org/asciinema/asciinema) [![PyPI](https://img.shields.io/pypi/v/asciinema.svg)](https://pypi.org/project/asciinema/) [![license](http://img.shields.io/badge/license-GNU-blue.svg)](https://raw.githubusercontent.com/asciinema/asciinema/master/LICENSE) Terminal session recorder and the best companion of [asciinema.org](https://asciinema.org). [![demo](https://asciinema.org/a/113463.png)](https://asciinema.org/a/113463?autoplay=1) ## Quick intro asciinema lets you easily record terminal sessions and replay them in a terminal as well as in a web browser. Install latest version ([other installation options](#installation)): sudo pip3 install asciinema Record your first session: asciinema rec first.cast Now replay it with double speed: asciinema play -s 2 first.cast Or with normal speed but with idle time limited to 2 seconds: asciinema play -i 2 first.cast You can pass `-i 2` to `asciinema rec` as well, to set it permanently on a recording. Idle time limiting makes the recordings much more interesting to watch, try it. If you want to watch and share it on the web, upload it: asciinema upload first.cast The above uploads it to [asciinema.org](https://asciinema.org), which is a default [asciinema-server](https://github.com/asciinema/asciinema-server) instance, and prints a secret link you can use to watch your recording in a web browser. You can record and upload in one step by omitting the filename: asciinema rec You'll be asked to confirm the upload when the recording is done, so nothing is sent anywhere without your consent. These were the basics, but there's much more you can do. The following sections cover installation, usage and hosting of the recordings in more detail. ## Installation ### Python package asciinema is available on [PyPI](https://pypi.python.org/pypi/asciinema) and can be installed with pip (Python 3 with setuptools required): sudo pip3 install asciinema This is the recommended way of installation, which gives you the latest released version. ### Native packages asciinema is included in repositories of most popular package managers on Mac OS X, Linux and FreeBSD. Look for package named `asciinema`. See the [list of available packages](https://asciinema.org/docs/installation). ### Snap supported Linux distros If you run [Ubuntu or other snap supported Linux distribution](https://snapcraft.io/docs/core/install) you can install asciinema with: snap install asciinema --classic The snap contains all necessary dependencies required to run asciinema, and will get automatically updated when a new version is pushed to the store. ### Docker image asciinema Docker image is based on Ubuntu 16.04 and has the latest version of asciinema recorder pre-installed. docker pull asciinema/asciinema When running it don't forget to allocate a pseudo-TTY (`-t`), keep STDIN open (`-i`) and mount config directory volume (`-v`): docker run --rm -ti -v "$HOME/.config/asciinema":/root/.config/asciinema asciinema/asciinema Default command run in a container is `asciinema rec`. There's not much software installed in this image though. In most cases you may want to install extra programs before recording. One option is to derive new image from this one (start your custom Dockerfile with `FROM asciinema/asciinema`). Another option is to start the container with `/bin/bash` as the command, install extra packages and manually start `asciinema rec`: docker run --rm -ti -v "$HOME/.config/asciinema":/root/.config/asciinema asciinema/asciinema /bin/bash root@6689517d99a1:~# apt-get install foobar root@6689517d99a1:~# asciinema rec ### Running latest version from source code checkout If none of the above works for you just clone the repo and run asciinema straight from the checkout. Clone the repo: git clone https://github.com/asciinema/asciinema.git cd asciinema If you want latest stable version: git checkout master If you want current development version: git checkout develop Then run it with: python3 -m asciinema --version ## Usage asciinema is composed of multiple commands, similar to `git`, `apt-get` or `brew`. When you run `asciinema` with no arguments help message is displayed, listing all available commands with their options. ### `rec [filename]` __Record terminal session.__ By running `asciinema rec [filename]` you start a new recording session. The command (process) that is recorded can be specified with `-c` option (see below), and defaults to `$SHELL` which is what you want in most cases. Recording finishes when you exit the shell (hit Ctrl+D or type `exit`). If the recorded process is not a shell then recording finishes when the process exits. If the `filename` argument is omitted then (after asking for confirmation) the resulting asciicast is uploaded to [asciinema-server](https://github.com/asciinema/asciinema-server) (by default to asciinema.org), where it can be watched and shared. If the `filename` argument is given then the resulting recording (called [asciicast](doc/asciicast-v2.md)) is saved to a local file. It can later be replayed with `asciinema play ` and/or uploaded to asciinema server with `asciinema upload `. `ASCIINEMA_REC=1` is added to recorded process environment variables. This can be used by your shell's config file (`.bashrc`, `.zshrc`) to alter the prompt or play a sound when the shell is being recorded. Available options: * `--stdin` - Enable stdin (keyboard) recording (see below) * `--append` - Append to existing recording * `--raw` - Save raw STDOUT output, without timing information or other metadata * `--overwrite` - Overwrite the recording if it already exists * `-c, --command=` - Specify command to record, defaults to $SHELL * `-e, --env=` - List of environment variables to capture, defaults to `SHELL,TERM` * `-t, --title=` - Specify the title of the asciicast * `-i, --idle-time-limit=<sec>` - Limit recorded terminal inactivity to max `<sec>` seconds * `-y, --yes` - Answer "yes" to all prompts (e.g. upload confirmation) * `-q, --quiet` - Be quiet, suppress all notices/warnings (implies -y) Stdin recording allows for capturing of all characters typed in by the user in the currently recorded shell. This may be used by a player (e.g. [asciinema-player](https://github.com/asciinema/asciinema-player)) to display pressed keys. Because it's basically a key-logging (scoped to a single shell instance), it's disabled by default, and has to be explicitly enabled via `--stdin` option. ### `play <filename>` __Replay recorded asciicast in a terminal.__ This command replays given asciicast (as recorded by `rec` command) directly in your terminal. Following keyboard shortcuts are available: - <kbd>Space</kbd> - toggle pause, - <kbd>.</kbd> - step through a recording a frame at a time (when paused), - <kbd>Ctrl+C</kbd> - exit. Playing from a local file: asciinema play /path/to/asciicast.cast Playing from HTTP(S) URL: asciinema play https://asciinema.org/a/22124.cast asciinema play http://example.com/demo.cast Playing from asciicast page URL (requires `<link rel="alternate" type="application/x-asciicast" href="/my/ascii.cast">` in page's HTML): asciinema play https://asciinema.org/a/22124 asciinema play http://example.com/blog/post.html Playing from stdin: cat /path/to/asciicast.cast | asciinema play - ssh user@host cat asciicast.cast | asciinema play - Playing from IPFS: asciinema play dweb:/ipfs/QmNe7FsYaHc9SaDEAEXbaagAzNw9cH7YbzN4xV7jV1MCzK/ascii.cast Available options: * `-i, --idle-time-limit=<sec>` - Limit replayed terminal inactivity to max `<sec>` seconds * `-s, --speed=<factor>` - Playback speed (can be fractional) > For the best playback experience it is recommended to run `asciinema play` in > a terminal of dimensions not smaller than the one used for recording, as > there's no "transcoding" of control sequences for new terminal size. ### `cat <filename>` __Print full output of recorded asciicast to a terminal.__ While `asciinema play <filename>` replays the recorded session using timing information saved in the asciicast, `asciinema cat <filename>` dumps the full output (including all escape sequences) to a terminal immediately. `asciinema cat existing.cast >output.txt` gives the same result as recording via `asciinema rec --raw output.txt`. ### `upload <filename>` __Upload recorded asciicast to asciinema.org site.__ This command uploads given asciicast (recorded by `rec` command) to asciinema.org, where it can be watched and shared. `asciinema rec demo.cast` + `asciinema play demo.cast` + `asciinema upload demo.cast` is a nice combo if you want to review an asciicast before publishing it on asciinema.org. ### `auth` __Link your install ID with your asciinema.org user account.__ If you want to manage your recordings (change title/theme, delete) at asciinema.org you need to link your "install ID" with asciinema.org user account. This command displays the URL to open in a web browser to do that. You may be asked to log in first. Install ID is a random ID ([UUID v4](https://en.wikipedia.org/wiki/Universally_unique_identifier)) generated locally when you run asciinema for the first time, and saved at `$HOME/.config/asciinema/install-id`. It's purpose is to connect local machine with uploaded recordings, so they can later be associated with asciinema.org account. This way we decouple uploading from account creation, allowing them to happen in any order. > A new install ID is generated on each machine and system user account you use > asciinema on, so in order to keep all recordings under a single asciinema.org > account you need to run `asciinema auth` on all of those machines. > asciinema versions prior to 2.0 confusingly referred to install ID as "API > token". ## Hosting the recordings on the web As mentioned in the `Usage > rec` section above, if the `filename` argument to `asciinema rec` is omitted then the recorded asciicast is uploaded to [asciinema.org](https://asciinema.org). You can watch it there and share it via secret URL. If you prefer to host the recordings yourself, you can do so by either: - recording to a file (`asciinema rec demo.cast`), and using [asciinema's standalone web player](https://github.com/asciinema/asciinema-player#self-hosting-quick-start) in your HTML page, or - setting up your own [asciinema-server](https://github.com/asciinema/asciinema-server) instance, and [setting API URL accordingly](https://github.com/asciinema/asciinema-server/blob/master/docs/INSTALL.md#using-asciinema-recorder-with-your-instance). ## Configuration file You can configure asciinema by creating config file at `$HOME/.config/asciinema/config`. Configuration is split into sections (`[api]`, `[record]`, `[play]`). Here's a list of all available options for each section: ```ini [api] ; API server URL, default: https://asciinema.org ; If you run your own instance of asciinema-server then set its address here ; It can also be overriden by setting ASCIINEMA_API_URL environment variable url = https://asciinema.example.com [record] ; Command to record, default: $SHELL command = /bin/bash -l ; Enable stdin (keyboard) recording, default: no stdin = yes ; List of environment variables to capture, default: SHELL,TERM env = SHELL,TERM,USER ; Limit recorded terminal inactivity to max n seconds, default: off idle_time_limit = 2 ; Answer "yes" to all interactive prompts, default: no yes = true ; Be quiet, suppress all notices/warnings, default: no quiet = true [play] ; Playback speed (can be fractional), default: 1 speed = 2 ; Limit replayed terminal inactivity to max n seconds, default: off idle_time_limit = 1 ``` A very minimal config file could look like that: ```ini [record] idle_time_limit = 2 ``` Config directory location can be changed by setting `$ASCIINEMA_CONFIG_HOME` environment variable. If `$XDG_CONFIG_HOME` is set on Linux then asciinema uses `$XDG_CONFIG_HOME/asciinema` instead of `$HOME/.config/asciinema`. > asciinema versions prior to 1.1 used `$HOME/.asciinema`. If you have it > there you should `mv $HOME/.asciinema $HOME/.config/asciinema`. ## Contributing If you want to contribute to this project check out [Contributing](https://asciinema.org/contributing) page. ## Authors Developed with passion by [Marcin Kulik](http://ku1ik.com) and great open source [contributors](https://github.com/asciinema/asciinema/contributors) ## License Copyright © 2011-2017 Marcin Kulik. All code is licensed under the GPL, v3 or later. See LICENSE file for details. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Vagrantfile�����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000732�13237664152�0013256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "1024"] end config.vm.define "archlinux" do |c| c.vm.box = "terrywang/archlinux" end config.vm.define "ubuntu" do |c| c.vm.box = "ubuntu/trusty64" end end ��������������������������������������asciinema/������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0013020�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/__init__.py�������������������������������������������������������������������������������0000664�0000000�0000000�00000000217�13237664152�0015131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys __author__ = 'Marcin Kulik' __version__ = '2.0.0' if sys.version_info[0] < 3: raise ImportError('Python < 3 is unsupported.') ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/__main__.py�������������������������������������������������������������������������������0000664�0000000�0000000�00000013620�13237664152�0015114�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import locale import argparse import os import sys from asciinema import __version__ import asciinema.config as config from asciinema.commands.auth import AuthCommand from asciinema.commands.record import RecordCommand from asciinema.commands.play import PlayCommand from asciinema.commands.cat import CatCommand from asciinema.commands.upload import UploadCommand from asciinema.api import Api def positive_float(value): value = float(value) if value <= 0.0: raise argparse.ArgumentTypeError("must be positive") return value def rec_command(args, config): api = Api(config.api_url, os.environ.get("USER"), config.install_id) return RecordCommand(api, args) def play_command(args, config): return PlayCommand(args.filename, args.idle_time_limit, args.speed) def cat_command(args, config): return CatCommand(args.filename) def upload_command(args, config): api = Api(config.api_url, os.environ.get("USER"), config.install_id) return UploadCommand(api, args.filename) def auth_command(args, config): api = Api(config.api_url, os.environ.get("USER"), config.install_id) return AuthCommand(api) def maybe_str(v): if v is not None: return str(v) def main(): if locale.nl_langinfo(locale.CODESET).upper() != 'UTF-8': print("asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.") sys.exit(1) try: cfg = config.load() except config.ConfigError as e: sys.stderr.write(str(e) + '\n') sys.exit(1) # create the top-level parser parser = argparse.ArgumentParser( description="Record and share your terminal sessions, the right way.", epilog="""example usage: Record terminal and upload it to asciinema.org: \x1b[1masciinema rec\x1b[0m Record terminal to local file: \x1b[1masciinema rec demo.cast\x1b[0m Record terminal and upload it to asciinema.org, specifying title: \x1b[1masciinema rec -t "My git tutorial"\x1b[0m Record terminal to local file, limiting idle time to max 2.5 sec: \x1b[1masciinema rec -i 2.5 demo.cast\x1b[0m Replay terminal recording from local file: \x1b[1masciinema play demo.cast\x1b[0m Replay terminal recording hosted on asciinema.org: \x1b[1masciinema play https://asciinema.org/a/difqlgx86ym6emrmd8u62yqu8\x1b[0m Print full output of recorded session: \x1b[1masciinema cat demo.cast\x1b[0m For help on a specific command run: \x1b[1masciinema <command> -h\x1b[0m""", formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('--version', action='version', version='asciinema %s' % __version__) subparsers = parser.add_subparsers() # create the parser for the "rec" command parser_rec = subparsers.add_parser('rec', help='Record terminal session') parser_rec.add_argument('--stdin', help='enable stdin recording, disabled by default', action='store_true', default=cfg.record_stdin) parser_rec.add_argument('--append', help='append to existing recording', action='store_true', default=False) parser_rec.add_argument('--raw', help='save only raw stdout output', action='store_true', default=False) parser_rec.add_argument('--overwrite', help='overwrite the file if it already exists', action='store_true', default=False) parser_rec.add_argument('-c', '--command', help='command to record, defaults to $SHELL', default=cfg.record_command) parser_rec.add_argument('-e', '--env', help='list of environment variables to capture, defaults to ' + config.DEFAULT_RECORD_ENV, default=cfg.record_env) parser_rec.add_argument('-t', '--title', help='title of the asciicast') parser_rec.add_argument('-i', '--idle-time-limit', help='limit recorded idle time to given number of seconds', type=positive_float, default=maybe_str(cfg.record_idle_time_limit)) parser_rec.add_argument('-y', '--yes', help='answer "yes" to all prompts (e.g. upload confirmation)', action='store_true', default=cfg.record_yes) parser_rec.add_argument('-q', '--quiet', help='be quiet, suppress all notices/warnings (implies -y)', action='store_true', default=cfg.record_quiet) parser_rec.add_argument('filename', nargs='?', default='', help='filename/path to save the recording to') parser_rec.set_defaults(func=rec_command) # create the parser for the "play" command parser_play = subparsers.add_parser('play', help='Replay terminal session') parser_play.add_argument('-i', '--idle-time-limit', help='limit idle time during playback to given number of seconds', type=positive_float, default=maybe_str(cfg.play_idle_time_limit)) parser_play.add_argument('-s', '--speed', help='playback speedup (can be fractional)', type=positive_float, default=cfg.play_speed) parser_play.add_argument('filename', help='local path, http/ipfs URL or "-" (read from stdin)') parser_play.set_defaults(func=play_command) # create the parser for the "cat" command parser_cat = subparsers.add_parser('cat', help='Print full output of terminal session') parser_cat.add_argument('filename', help='local path, http/ipfs URL or "-" (read from stdin)') parser_cat.set_defaults(func=cat_command) # create the parser for the "upload" command parser_upload = subparsers.add_parser('upload', help='Upload locally saved terminal session to asciinema.org') parser_upload.add_argument('filename', help='filename or path of local recording') parser_upload.set_defaults(func=upload_command) # create the parser for the "auth" command parser_auth = subparsers.add_parser('auth', help='Manage recordings on asciinema.org account') parser_auth.set_defaults(func=auth_command) # parse the args and call whatever function was selected args = parser.parse_args() if hasattr(args, 'func'): command = args.func(args, cfg) code = command.execute() sys.exit(code) else: parser.print_help() sys.exit(1) if __name__ == '__main__': main() ����������������������������������������������������������������������������������������������������������������asciinema/api.py������������������������������������������������������������������������������������0000664�0000000�0000000�00000005036�13237664152�0014147�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import platform import re from urllib.parse import urlparse from asciinema import __version__ from asciinema.urllib_http_adapter import URLLibHttpAdapter from asciinema.http_adapter import HTTPConnectionError class APIError(Exception): pass class Api: def __init__(self, url, user, install_id, http_adapter=None): self.url = url self.user = user self.install_id = install_id self.http_adapter = http_adapter if http_adapter is not None else URLLibHttpAdapter() def hostname(self): return urlparse(self.url).hostname def auth_url(self): return "{}/connect/{}".format(self.url, self.install_id) def upload_url(self): return "{}/api/asciicasts".format(self.url) def upload_asciicast(self, path): with open(path, 'rb') as f: try: status, headers, body = self.http_adapter.post( self.upload_url(), files={"asciicast": ("ascii.cast", f)}, headers=self._headers(), username=self.user, password=self.install_id ) except HTTPConnectionError as e: raise APIError(str(e)) if status != 200 and status != 201: self._handle_error(status, body) return body, headers.get('Warning') def _headers(self): return {'User-Agent': self._user_agent()} def _user_agent(self): os = re.sub('([^-]+)-(.*)', '\\1/\\2', platform.platform()) return 'asciinema/%s %s/%s %s' % (__version__, platform.python_implementation(), platform.python_version(), os ) def _handle_error(self, status, body): errors = { 400: "Invalid request: %s" % body, 401: "Invalid or revoked install ID", 404: "API endpoint not found. This asciinema version may no longer be supported. Please upgrade to the latest version.", 413: "Sorry, your asciicast is too big.", 422: "Invalid asciicast: %s" % body, 503: "The server is down for maintenance. Try again in a minute." } error = errors.get(status) if not error: if status >= 500: error = "The server is having temporary problems. Try again in a minute." else: error = "HTTP status: %i" % status raise APIError(error) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/��������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0014763�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/__init__.py���������������������������������������������������������������������0000664�0000000�0000000�00000006543�13237664152�0017104�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys import os from urllib.request import Request, urlopen from urllib.parse import urlparse, urlunparse import urllib.error import html.parser import gzip import codecs from . import v1 from . import v2 class LoadError(Exception): pass class Parser(html.parser.HTMLParser): def __init__(self): html.parser.HTMLParser.__init__(self) self.url = None def handle_starttag(self, tag, attrs_list): # look for <link rel="alternate" type="application/x-asciicast" href="https://...cast"> if tag == 'link': attrs = {} for k, v in attrs_list: attrs[k] = v if attrs.get('rel') == 'alternate': type = attrs.get('type') if type == 'application/asciicast+json' or type == 'application/x-asciicast': self.url = attrs.get('href') def open_url(url): if url == "-": return sys.stdin if url.startswith("ipfs://"): url = "https://ipfs.io/ipfs/%s" % url[7:] elif url.startswith("dweb:/ipfs/"): url = "https://ipfs.io/%s" % url[5:] if url.startswith("http:") or url.startswith("https:"): req = Request(url) req.add_header('Accept-Encoding', 'gzip') response = urlopen(req) body = response url = response.geturl() # final URL after redirects if response.headers['Content-Encoding'] == 'gzip': body = gzip.open(body) utf8_reader = codecs.getreader('utf-8') content_type = response.headers['Content-Type'] if content_type and content_type.startswith('text/html'): html = utf8_reader(body, errors='replace').read() parser = Parser() parser.feed(html) new_url = parser.url if not new_url: raise LoadError("""<link rel="alternate" type="application/x-asciicast" href="..."> not found in fetched HTML document""") if "://" not in new_url: base_url = urlparse(url) if new_url.startswith("/"): new_url = urlunparse((base_url[0], base_url[1], new_url, '', '', '')) else: path = os.path.dirname(base_url[2]) + '/' + new_url new_url = urlunparse((base_url[0], base_url[1], path, '', '', '')) return open_url(new_url) return utf8_reader(body, errors='strict') return open(url, mode='rt', encoding='utf-8') class open_from_url(): FORMAT_ERROR = "only asciicast v1 and v2 formats can be opened" def __init__(self, url): self.url = url def __enter__(self): try: self.file = open_url(self.url) first_line = self.file.readline() try: # try v2 first self.context = v2.open_from_file(first_line, self.file) return self.context.__enter__() except v2.LoadError: try: # try v1 next self.context = v1.open_from_file(first_line, self.file) return self.context.__enter__() except v1.LoadError: raise LoadError(self.FORMAT_ERROR) except (OSError, urllib.error.HTTPError) as e: raise LoadError(str(e)) def __exit__(self, exc_type, exc_value, exc_traceback): self.context.__exit__(exc_type, exc_value, exc_traceback) �������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/frames.py�����������������������������������������������������������������������0000664�0000000�0000000�00000001137�13237664152�0016614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������def to_relative_time(frames): prev_time = 0 for frame in frames: time, data = frame delay = time - prev_time prev_time = time yield [delay, data] def to_absolute_time(frames): time = 0 for frame in frames: delay, data = frame time = time + delay yield [time, data] def cap_relative_time(frames, time_limit): if time_limit: return ([min(delay, time_limit), text] for delay, text in frames) else: return frames def adjust_speed(frames, speed): return ([delay / speed, text] for delay, text in frames) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/raw.py��������������������������������������������������������������������������0000664�0000000�0000000�00000002546�13237664152�0016135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import os from multiprocessing import Process, Queue from asciinema.pty_recorder import PtyRecorder def write_bytes_from_queue(path, mode, queue): mode = mode + 'b' with open(path, mode=mode, buffering=0) as f: for data in iter(queue.get, None): f.write(data) class writer(): def __init__(self, path, append): self.path = path self.mode = 'a' if append else 'w' self.queue = Queue() def __enter__(self): self.process = Process( target=write_bytes_from_queue, args=(self.path, self.mode, self.queue) ) self.process.start() return self def __exit__(self, exc_type, exc_value, exc_traceback): self.queue.put(None) self.process.join() def write_stdin(self, data): pass def write_stdout(self, data): self.queue.put(data) class Recorder: def __init__(self, pty_recorder=None): self.pty_recorder = pty_recorder if pty_recorder is not None else PtyRecorder() def record(self, path, append, command, command_env, _captured_env, _rec_stdin, _title, _idle_time_limit): if os.path.exists(path) and os.stat(path).st_size == 0: # true for pipes append = False with writer(path, append) as w: self.pty_recorder.record_command(['sh', '-c', command], w, command_env) ����������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/v1.py���������������������������������������������������������������������������0000664�0000000�0000000�00000002125�13237664152�0015663�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import json import json.decoder from asciinema.asciicast.frames import to_absolute_time try: JSONDecodeError = json.decoder.JSONDecodeError except AttributeError: JSONDecodeError = ValueError class LoadError(Exception): pass class Asciicast: def __init__(self, stdout): self.version = 1 self.__stdout = stdout self.idle_time_limit = None # v1 doesn't store it def stdout(self): return to_absolute_time(self.__stdout) class open_from_file(): FORMAT_ERROR = "only asciicast v1 format can be opened" def __init__(self, first_line, file): self.first_line = first_line self.file = file def __enter__(self): try: attrs = json.loads(self.first_line + self.file.read()) if attrs.get('version') == 1: return Asciicast(attrs['stdout']) else: raise LoadError(self.FORMAT_ERROR) except JSONDecodeError as e: raise LoadError(self.FORMAT_ERROR) def __exit__(self, exc_type, exc_value, exc_traceback): self.file.close() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/asciicast/v2.py���������������������������������������������������������������������������0000664�0000000�0000000�00000010502�13237664152�0015662�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import os import subprocess import json import json.decoder import time import codecs from multiprocessing import Process, Queue from asciinema.pty_recorder import PtyRecorder try: JSONDecodeError = json.decoder.JSONDecodeError except AttributeError: JSONDecodeError = ValueError class LoadError(Exception): pass class Asciicast: def __init__(self, f, idle_time_limit): self.version = 2 self.__file = f self.idle_time_limit = idle_time_limit def stdout(self): for line in self.__file: time, type, data = json.loads(line) if type == 'o': yield [time, data] def build_from_header_and_file(header, f): idle_time_limit = header.get('idle_time_limit') return Asciicast(f, idle_time_limit) class open_from_file(): FORMAT_ERROR = "only asciicast v2 format can be opened" def __init__(self, first_line, file): self.first_line = first_line self.file = file def __enter__(self): try: v2_header = json.loads(self.first_line) if v2_header.get('version') == 2: return build_from_header_and_file(v2_header, self.file) else: raise LoadError(self.FORMAT_ERROR) except JSONDecodeError as e: raise LoadError(self.FORMAT_ERROR) def __exit__(self, exc_type, exc_value, exc_traceback): self.file.close() def get_duration(path): with open(path, mode='rt', encoding='utf-8') as f: first_line = f.readline() with open_from_file(first_line, f) as a: for last_frame in a.stdout(): pass return last_frame[0] def write_json_lines_from_queue(path, mode, queue): with open(path, mode=mode, buffering=1) as f: for json_value in iter(queue.get, None): line = json.dumps(json_value, ensure_ascii=False, indent=None, separators=(', ', ': ')) f.write(line + '\n') class writer(): def __init__(self, path, header, rec_stdin, start_time_offset=0): self.path = path self.header = header self.rec_stdin = rec_stdin self.start_time_offset = start_time_offset self.queue = Queue() self.stdin_decoder = codecs.getincrementaldecoder('UTF-8')('replace') self.stdout_decoder = codecs.getincrementaldecoder('UTF-8')('replace') def __enter__(self): mode = 'a' if self.start_time_offset > 0 else 'w' self.process = Process( target=write_json_lines_from_queue, args=(self.path, mode, self.queue) ) self.process.start() if self.start_time_offset == 0: self.queue.put(self.header) self.start_time = time.time() - self.start_time_offset return self def __exit__(self, exc_type, exc_value, exc_traceback): self.queue.put(None) self.process.join() def write_stdin(self, data): if self.rec_stdin: text = self.stdin_decoder.decode(data) if text: ts = round(time.time() - self.start_time, 6) self.queue.put([ts, 'i', text]) def write_stdout(self, data): text = self.stdout_decoder.decode(data) if text: ts = round(time.time() - self.start_time, 6) self.queue.put([ts, 'o', text]) class Recorder: def __init__(self, pty_recorder=None): self.pty_recorder = pty_recorder if pty_recorder is not None else PtyRecorder() def record(self, path, append, command, command_env, captured_env, rec_stdin, title, idle_time_limit): start_time_offset = 0 if append and os.stat(path).st_size > 0: start_time_offset = get_duration(path) cols = int(subprocess.check_output(['tput', 'cols'])) lines = int(subprocess.check_output(['tput', 'lines'])) header = { 'version': 2, 'width': cols, 'height': lines, 'timestamp': int(time.time()), } if idle_time_limit is not None: header['idle_time_limit'] = idle_time_limit if captured_env: header['env'] = captured_env if title: header['title'] = title with writer(path, header, rec_stdin, start_time_offset) as w: self.pty_recorder.record_command(['sh', '-c', command], w, command_env) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/���������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0014621�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/__init__.py����������������������������������������������������������������������0000664�0000000�0000000�00000000000�13237664152�0016720�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/auth.py��������������������������������������������������������������������������0000664�0000000�0000000�00000001235�13237664152�0016135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from asciinema.commands.command import Command class AuthCommand(Command): def __init__(self, api): Command.__init__(self) self.api = api def execute(self): self.print('Open the following URL in a web browser to link your ' 'install ID with your %s user account:\n\n' '%s\n\n' 'This will associate all recordings uploaded from this machine ' '(past and future ones) to your account, ' 'and allow you to manage them (change title/theme, delete) at %s.' % (self.api.hostname(), self.api.auth_url(), self.api.hostname())) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/cat.py���������������������������������������������������������������������������0000664�0000000�0000000�00000001121�13237664152�0015735�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys from asciinema.commands.command import Command import asciinema.asciicast as asciicast class CatCommand(Command): def __init__(self, filename): Command.__init__(self) self.filename = filename def execute(self): try: with asciicast.open_from_url(self.filename) as a: for t, text in a.stdout(): sys.stdout.write(text) sys.stdout.flush() except asciicast.LoadError as e: self.print_error("printing failed: %s" % str(e)) return 1 return 0 �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/command.py�����������������������������������������������������������������������0000664�0000000�0000000�00000001051�13237664152�0016606�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys class Command: def __init__(self, quiet=False): self.quiet = quiet def print(self, text, file=sys.stdout, end="\n", force=False): if not self.quiet or force: print(text, file=file, end=end) def print_info(self, text): self.print("\x1b[0;32masciinema: %s\x1b[0m" % text) def print_warning(self, text): self.print("\x1b[0;33masciinema: %s\x1b[0m" % text) def print_error(self, text): self.print("\x1b[0;31masciinema: %s\x1b[0m" % text, file=sys.stderr, force=True) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/play.py��������������������������������������������������������������������������0000664�0000000�0000000�00000001432�13237664152�0016140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from asciinema.commands.command import Command from asciinema.player import Player import asciinema.asciicast as asciicast class PlayCommand(Command): def __init__(self, filename, idle_time_limit, speed, player=None): Command.__init__(self) self.filename = filename self.idle_time_limit = idle_time_limit self.speed = speed self.player = player if player is not None else Player() def execute(self): try: with asciicast.open_from_url(self.filename) as a: self.player.play(a, self.idle_time_limit, self.speed) except asciicast.LoadError as e: self.print_error("playback failed: %s" % str(e)) return 1 except KeyboardInterrupt: return 1 return 0 ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/commands/record.py������������������������������������������������������������������������0000664�0000000�0000000�00000007634�13237664152�0016463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys import os import tempfile from asciinema.commands.command import Command import asciinema.asciicast as asciicast import asciinema.asciicast.v2 as v2 import asciinema.asciicast.raw as raw from asciinema.api import APIError class RecordCommand(Command): def __init__(self, api, args, env=None): Command.__init__(self, args.quiet) self.api = api self.filename = args.filename self.rec_stdin = args.stdin self.command = args.command self.env_whitelist = args.env self.title = args.title self.assume_yes = args.yes or args.quiet self.idle_time_limit = args.idle_time_limit self.append = args.append self.overwrite = args.overwrite self.raw = args.raw self.recorder = raw.Recorder() if args.raw else v2.Recorder() self.env = env if env is not None else os.environ def execute(self): upload = False append = self.append if self.filename == "": if self.raw: self.print_error("filename required when recording in raw mode") return 1 else: self.filename = _tmp_path() upload = True if os.path.exists(self.filename): if not os.access(self.filename, os.W_OK): self.print_error("can't write to %s" % self.filename) return 1 if os.stat(self.filename).st_size > 0 and self.overwrite: os.remove(self.filename) append = False elif os.stat(self.filename).st_size > 0 and not append: self.print_error("%s already exists, aborting" % self.filename) self.print_error("use --append option if you want to append to existing recording") return 1 if append: self.print_info("appending to asciicast at %s" % self.filename) else: self.print_info("recording asciicast to %s" % self.filename) self.print_info("""press <ctrl-d> or type "exit" when you're done""") command = self.command or self.env.get('SHELL') or 'sh' command_env = self.env.copy() command_env['ASCIINEMA_REC'] = '1' vars = filter(None, map((lambda var: var.strip()), self.env_whitelist.split(','))) captured_env = {var: self.env.get(var) for var in vars} try: self.recorder.record( self.filename, append, command, command_env, captured_env, self.rec_stdin, self.title, self.idle_time_limit ) except v2.LoadError: self.print_error("can only append to asciicast v2 format recordings") return 1 self.print_info("recording finished") if upload: if not self.assume_yes: self.print_info("press <enter> to upload to %s, <ctrl-c> to save locally" % self.api.hostname()) try: sys.stdin.readline() except KeyboardInterrupt: self.print("\r", end="") self.print_info("asciicast saved to %s" % self.filename) return 0 try: url, warn = self.api.upload_asciicast(self.filename) if warn: self.print_warning(warn) os.remove(self.filename) self.print(url) except APIError as e: self.print("\r\x1b[A", end="") self.print_error("upload failed: %s" % str(e)) self.print_error("retry later by running: asciinema upload %s" % self.filename) return 1 else: self.print_info("asciicast saved to %s" % self.filename) return 0 def _tmp_path(): fd, path = tempfile.mkstemp(suffix='-ascii.cast') os.close(fd) return path ����������������������������������������������������������������������������������������������������asciinema/commands/upload.py������������������������������������������������������������������������0000664�0000000�0000000�00000001376�13237664152�0016466�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from asciinema.commands.command import Command from asciinema.api import APIError class UploadCommand(Command): def __init__(self, api, filename): Command.__init__(self) self.api = api self.filename = filename def execute(self): try: url, warn = self.api.upload_asciicast(self.filename) if warn: self.print_warning(warn) self.print(url) except OSError as e: self.print_error("upload failed: %s" % str(e)) return 1 except APIError as e: self.print_error("upload failed: %s" % str(e)) self.print_error("retry later by running: asciinema upload %s" % self.filename) return 1 return 0 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/config.py���������������������������������������������������������������������������������0000664�0000000�0000000�00000010667�13237664152�0014651�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import os import os.path as path import sys import uuid import configparser class ConfigError(Exception): pass DEFAULT_API_URL = 'https://asciinema.org' DEFAULT_RECORD_ENV = 'SHELL,TERM' class Config: def __init__(self, config_home, env=None): self.config_home = config_home self.config_file_path = path.join(config_home, "config") self.install_id_path = path.join(self.config_home, 'install-id') self.config = configparser.ConfigParser() self.config.read(self.config_file_path) self.env = env if env is not None else os.environ def upgrade(self): try: self.install_id except ConfigError: id = self.__api_token() or self.__user_token() or self.__gen_install_id() self.__save_install_id(id) items = {name: dict(section) for (name, section) in self.config.items()} if items == {'DEFAULT': {}, 'api': {'token': id}} or items == {'DEFAULT': {}, 'user': {'token': id}}: os.remove(self.config_file_path) if self.env.get('ASCIINEMA_API_TOKEN'): raise ConfigError('ASCIINEMA_API_TOKEN variable is no longer supported, please use ASCIINEMA_INSTALL_ID instead') def __read_install_id(self): p = self.install_id_path if path.isfile(p): with open(p, 'r') as f: return f.read().strip() def __gen_install_id(self): return str(uuid.uuid4()) def __save_install_id(self, id): self.__create_config_home() with open(self.install_id_path, 'w') as f: f.write(id) def __create_config_home(self): if not path.exists(self.config_home): os.makedirs(self.config_home) def __api_token(self): try: return self.config.get('api', 'token') except (configparser.NoOptionError, configparser.NoSectionError): pass def __user_token(self): try: return self.config.get('user', 'token') except (configparser.NoOptionError, configparser.NoSectionError): pass @property def install_id(self): id = self.env.get('ASCIINEMA_INSTALL_ID') or self.__read_install_id() if id: return id else: raise ConfigError('no install ID found') @property def api_url(self): return self.env.get( 'ASCIINEMA_API_URL', self.config.get('api', 'url', fallback=DEFAULT_API_URL) ) @property def record_stdin(self): return self.config.getboolean('record', 'stdin', fallback=False) @property def record_command(self): return self.config.get('record', 'command', fallback=None) @property def record_env(self): return self.config.get('record', 'env', fallback=DEFAULT_RECORD_ENV) @property def record_idle_time_limit(self): fallback = self.config.getfloat('record', 'maxwait', fallback=None) # pre 2.0 return self.config.getfloat('record', 'idle_time_limit', fallback=fallback) @property def record_yes(self): return self.config.getboolean('record', 'yes', fallback=False) @property def record_quiet(self): return self.config.getboolean('record', 'quiet', fallback=False) @property def play_idle_time_limit(self): fallback = self.config.getfloat('play', 'maxwait', fallback=None) # pre 2.0 return self.config.getfloat('play', 'idle_time_limit', fallback=fallback) @property def play_speed(self): return self.config.getfloat('play', 'speed', fallback=1.0) def get_config_home(env=os.environ): env_asciinema_config_home = env.get("ASCIINEMA_CONFIG_HOME") env_xdg_config_home = env.get("XDG_CONFIG_HOME") env_home = env.get("HOME") config_home = None if env_asciinema_config_home: config_home = env_asciinema_config_home elif env_xdg_config_home: config_home = path.join(env_xdg_config_home, "asciinema") elif env_home: if path.isfile(path.join(env_home, ".config", "asciinema", "config")): config_home = path.join(env_home, ".config", "asciinema") else: config_home = path.join(env_home, ".asciinema") # location for versions < 1.1 else: raise Exception("need $HOME or $XDG_CONFIG_HOME or $ASCIINEMA_CONFIG_HOME") return config_home def load(env=os.environ): config = Config(get_config_home(env), env) config.upgrade() return config �������������������������������������������������������������������������asciinema/http_adapter.py���������������������������������������������������������������������������0000664�0000000�0000000�00000000057�13237664152�0016053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������class HTTPConnectionError(Exception): pass ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/player.py���������������������������������������������������������������������������������0000664�0000000�0000000�00000004530�13237664152�0014670�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import os import sys import time import asciinema.asciicast.frames as frames from asciinema.term import raw, read_blocking class Player: def play(self, asciicast, idle_time_limit=None, speed=1.0): try: stdin = open('/dev/tty') with raw(stdin.fileno()): self._play(asciicast, idle_time_limit, speed, stdin) except: self._play(asciicast, idle_time_limit, speed, None) def _play(self, asciicast, idle_time_limit, speed, stdin): idle_time_limit = idle_time_limit or asciicast.idle_time_limit stdout = asciicast.stdout() stdout = frames.to_relative_time(stdout) stdout = frames.cap_relative_time(stdout, idle_time_limit) stdout = frames.to_absolute_time(stdout) stdout = frames.adjust_speed(stdout, speed) base_time = time.time() ctrl_c = False paused = False pause_time = None for t, text in stdout: delay = t - (time.time() - base_time) while stdin and not ctrl_c and delay > 0: if paused: while True: data = read_blocking(stdin.fileno(), 1000) if 0x03 in data: # ctrl-c ctrl_c = True break if 0x20 in data: # space paused = False base_time = base_time + (time.time() - pause_time) break if 0x2e in data: # period (dot) delay = 0 pause_time = time.time() base_time = pause_time - t break else: data = read_blocking(stdin.fileno(), delay) if not data: break if 0x03 in data: # ctrl-c ctrl_c = True break if 0x20 in data: # space paused = True pause_time = time.time() slept = t - (pause_time - base_time) delay = delay - slept if ctrl_c: break sys.stdout.write(text) sys.stdout.flush() ������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/pty_recorder.py���������������������������������������������������������������������������0000664�0000000�0000000�00000010456�13237664152�0016101�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import errno import os import pty import signal import array import fcntl import termios import select import io import shlex import sys import struct from asciinema.term import raw class PtyRecorder: def record_command(self, command, output, env=os.environ): master_fd = None def _set_pty_size(): ''' Sets the window size of the child pty based on the window size of our own controlling terminal. ''' # Get the terminal size of the real terminal, set it on the pseudoterminal. if os.isatty(pty.STDOUT_FILENO): buf = array.array('h', [0, 0, 0, 0]) fcntl.ioctl(pty.STDOUT_FILENO, termios.TIOCGWINSZ, buf, True) else: buf = array.array('h', [24, 80, 0, 0]) fcntl.ioctl(master_fd, termios.TIOCSWINSZ, buf) def _write_stdout(data): '''Writes to stdout as if the child process had written the data.''' os.write(pty.STDOUT_FILENO, data) def _handle_master_read(data): '''Handles new data on child process stdout.''' output.write_stdout(data) _write_stdout(data) def _write_master(data): '''Writes to the child process from its controlling terminal.''' while data: n = os.write(master_fd, data) data = data[n:] def _handle_stdin_read(data): '''Handles new data on child process stdin.''' output.write_stdin(data) _write_master(data) def _signals(signal_list): old_handlers = [] for sig, handler in signal_list: old_handlers.append((sig, signal.signal(sig, handler))) return old_handlers def _copy(signal_fd): '''Main select loop. Passes control to _master_read() or _stdin_read() when new data arrives. ''' fds = [master_fd, pty.STDIN_FILENO, signal_fd] while True: try: rfds, wfds, xfds = select.select(fds, [], []) except OSError as e: # Python >= 3.3 if e.errno == errno.EINTR: continue except select.error as e: # Python < 3.3 if e.args[0] == 4: continue if master_fd in rfds: data = os.read(master_fd, 1024) if not data: # Reached EOF. fds.remove(master_fd) else: _handle_master_read(data) if pty.STDIN_FILENO in rfds: data = os.read(pty.STDIN_FILENO, 1024) if not data: fds.remove(pty.STDIN_FILENO) else: _handle_stdin_read(data) if signal_fd in rfds: data = os.read(signal_fd, 1024) if data: signals = struct.unpack('%uB' % len(data), data) for sig in signals: if sig in [signal.SIGCHLD, signal.SIGHUP, signal.SIGTERM, signal.SIGQUIT]: os.close(master_fd) return elif sig == signal.SIGWINCH: _set_pty_size() pid, master_fd = pty.fork() if pid == pty.CHILD: os.execvpe(command[0], command, env) pipe_r, pipe_w = os.pipe() flags = fcntl.fcntl(pipe_w, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK flags = fcntl.fcntl(pipe_w, fcntl.F_SETFL, flags) signal.set_wakeup_fd(pipe_w) old_handlers = _signals(map(lambda s: (s, lambda signal, frame: None), [signal.SIGWINCH, signal.SIGCHLD, signal.SIGHUP, signal.SIGTERM, signal.SIGQUIT])) _set_pty_size() with raw(pty.STDIN_FILENO): try: _copy(pipe_r) except (IOError, OSError): pass _signals(old_handlers) os.waitpid(pid, 0) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/term.py�����������������������������������������������������������������������������������0000664�0000000�0000000�00000001166�13237664152�0014345�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import tty import select import os class raw(): def __init__(self, fd): self.fd = fd self.restore = False def __enter__(self): try: self.mode = tty.tcgetattr(self.fd) tty.setraw(self.fd) self.restore = True except tty.error: # This is the same as termios.error pass def __exit__(self, type, value, traceback): if self.restore: tty.tcsetattr(self.fd, tty.TCSAFLUSH, self.mode) def read_blocking(fd, timeout): if fd in select.select([fd], [], [], timeout)[0]: return os.read(fd, 1024) return b'' ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema/urllib_http_adapter.py��������������������������������������������������������������������0000664�0000000�0000000�00000006322�13237664152�0017425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import codecs import sys import uuid import io import base64 import http from urllib.request import Request, urlopen from urllib.error import HTTPError, URLError from .http_adapter import HTTPConnectionError class MultipartFormdataEncoder: def __init__(self): self.boundary = uuid.uuid4().hex self.content_type = 'multipart/form-data; boundary={}'.format(self.boundary) @classmethod def u(cls, s): if sys.hexversion >= 0x03000000 and isinstance(s, bytes): s = s.decode('utf-8') return s def iter(self, fields, files): """ fields is a dict of {name: value} for regular form fields. files is a dict of {name: (filename, file-type)} for data to be uploaded as files Yield body's chunk as bytes """ encoder = codecs.getencoder('utf-8') for (key, value) in fields.items(): key = self.u(key) yield encoder('--{}\r\n'.format(self.boundary)) yield encoder(self.u('Content-Disposition: form-data; name="{}"\r\n').format(key)) yield encoder('\r\n') if isinstance(value, int) or isinstance(value, float): value = str(value) yield encoder(self.u(value)) yield encoder('\r\n') for (key, filename_and_f) in files.items(): filename, f = filename_and_f key = self.u(key) filename = self.u(filename) yield encoder('--{}\r\n'.format(self.boundary)) yield encoder(self.u('Content-Disposition: form-data; name="{}"; filename="{}"\r\n').format(key, filename)) yield encoder('Content-Type: application/octet-stream\r\n') yield encoder('\r\n') data = f.read() yield (data, len(data)) yield encoder('\r\n') yield encoder('--{}--\r\n'.format(self.boundary)) def encode(self, fields, files): body = io.BytesIO() for chunk, chunk_len in self.iter(fields, files): body.write(chunk) return self.content_type, body.getvalue() class URLLibHttpAdapter: def post(self, url, fields={}, files={}, headers={}, username=None, password=None): content_type, body = MultipartFormdataEncoder().encode(fields, files) headers = headers.copy() headers["Content-Type"] = content_type if password: auth = "%s:%s" % (username, password) encoded_auth = base64.encodestring(auth.encode('utf-8'))[:-1] headers["Authorization"] = b"Basic " + encoded_auth request = Request(url, data=body, headers=headers, method="POST") try: response = urlopen(request) status = response.status headers = self._parse_headers(response) body = response.read().decode('utf-8') except HTTPError as e: status = e.code headers = {} body = e.read().decode('utf-8') except (http.client.RemoteDisconnected, URLError) as e: raise HTTPConnectionError(str(e)) return (status, headers, body) def _parse_headers(self, response): headers = {} for k, v in response.getheaders(): headers[k] = v return headers ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������doc/������������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0011634�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������doc/asciicast-v1.md���������������������������������������������������������������������������������0000664�0000000�0000000�00000004070�13237664152�0014446�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# asciicast file format (version 1) asciicast file is JSON file containing meta-data like duration or title of the recording, and the actual content printed to terminal's stdout during recording. Version 1 of the format was used by the asciinema recorder versions 1.0 up to 1.4. ## Attributes Every asciicast includes the following set of attributes: * `version` - set to 1, * `width` - terminal width (number of columns), * `height` - terminal height (number of rows), * `duration` - total duration of asciicast as floating point number, * `command` - command that was recorded, as given via `-c` option to `rec`, * `title` - title of the asciicast, as given via `-t` option to `rec`, * `env` - map of environment variables useful for debugging playback problems, * `stdout` - array of "frames", see below. ### Frame Frame represents an event of printing new data to terminal's stdout. It is a 2 element array containing **delay** and **data**. **Delay** is the number of seconds that elapsed since the previous frame (or since the beginning of the recording in case of the 1st frame) represented as a floating point number, with microsecond precision. **Data** is a string containing the data that was printed to a terminal in a given frame. It has to be valid, UTF-8 encoded JSON string as described in [JSON RFC section 2.5](http://www.ietf.org/rfc/rfc4627.txt), with all non-printable Unicode codepoints encoded as `\uXXXX`. For example, frame `[5.4321, "foo\rbar\u0007..."]` means there was 5 seconds of inactivity between previous printing and printing of `foo\rbar\u0007...`. ## Example asciicast A very short asciicast may look like this: { "version": 1, "width": 80, "height": 24, "duration": 1.515658, "command": "/bin/zsh", "title": "", "env": { "TERM": "xterm-256color", "SHELL": "/bin/zsh" }, "stdout": [ [ 0.248848, "\u001b[1;31mHello \u001b[32mWorld!\u001b[0m\n" ], [ 1.001376, "I am \rThis is on the next line." ] ] } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������doc/asciicast-v2.md���������������������������������������������������������������������������������0000664�0000000�0000000�00000013245�13237664152�0014453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# asciicast file format (version 2) asciicast v2 file is [newline-delimited JSON](http://jsonlines.org/) file where: * __first line__ contains header (initial terminal size, timestamp and other meta-data), encoded as JSON object, * __all following lines__ form an event stream, _each line_ representing a separate event, encoded as 3-element JSON array. Example file: ```json {"version": 2, "width": 80, "height": 24, "timestamp": 1504467315, "title": "Demo", "env": {"TERM": "xterm-256color", "SHELL": "/bin/zsh"}} [0.248848, "o", "\u001b[1;31mHello \u001b[32mWorld!\u001b[0m\n"] [1.001376, "o", "That was ok\rThis is better."] [2.143733, "o", " "] [6.541828, "o", "Bye!"] ``` Suggested file extension is `.cast`, suggested media type is `application/x-asciicast`. ## Header asciicast header is JSON-encoded object containing recording meta-data. ### Required header attributes: #### `version` Must be set to `2`. Integer. #### `width` Initial terminal width (number of columns). Integer. #### `height` Initial terminal height (number of rows). Integer. ### Optional header attributes: #### `timestamp` Unix timestamp of the beginning of the recording session. Integer. #### `duration` Duration of the whole recording in seconds (when it's known upfront). Float. #### `idle_time_limit` Idle time limit, as given via `-i` option to `asciinema rec`. Float. This should be used by an asciicast player to reduce all terminal inactivity (delays between frames) to maximum of `idle_time_limit` value. #### `command` Command that was recorded, as given via `-c` option to `asciinema rec`. String. #### `title` Title of the asciicast, as given via `-t` option to `asciinema rec`. String. #### `env` Map of captured environment variables. Object (String -> String). Example env: ```json "env": { "SHELL": "xterm-256color", "TERM": "/bin/bash" } ``` > Official asciinema recorder captures only `SHELL` and `TERM` by default. All > implementations of asciicast-compatible terminal recorder should not capture > any additional environment variables unless explicitly permitted by the user. #### `theme` Color theme of the recorded terminal. Object, with the following attributes: - `fg` - normal text color, - `bg` - normal background color, - `palette` - list of 8 or 16 colors, separated by colon character. All colors are in the CSS `#rrggbb` format. Example theme: ```json "theme": { "fg": "#d0d0d0", "bg": "#212121", "palette": "#151515:#ac4142:#7e8e50:#e5b567:#6c99bb:#9f4e85:#7dd6cf:#d0d0d0:#505050:#ac4142:#7e8e50:#e5b567:#6c99bb:#9f4e85:#7dd6cf:#f5f5f5" } ``` > A specific technique of obtaining the colors from a terminal (using xrdb, > requesting them from a terminal via special escape sequences etc) doesn't > matter as long as the recorder can save it in the above format. ## Event stream Each element of the event stream is a 3-tuple encoded as JSON array: [time, event-type, event-data] Where: * `time` (float) - indicates when this event happened, represented as the number of seconds since the beginning of the recording session, * `event-type` (string) - one of: `"o"`, `"i"`, * `event-data` (any) - event specific data, described separately for each event type. For example, let's look at the following line: [1.001376, "o", "Hello world"] It represents the event which: * happened 1.001376 sec after the start of the recording session, * is of type `"o"` (print to stdout, see below), * has data `"Hello world"`. ### Supported event types This section describes the event types supported in asciicast v2 format. The list is open to extension, and new event types may be added in both the current and future versions of the format. For example, we may add new event type for text overlay (subtitles display). A tool which interprets the event stream (web/cli player, post-processor) should ignore (or pass through) event types it doesn't understand or doesn't care about. #### "o" - data written to stdout Event of type `"o"` represents printing new data to terminal's stdout. `event-data` is a string containing the data that was printed to a terminal. It has to be valid, UTF-8 encoded JSON string as described in [JSON RFC section 2.5](http://www.ietf.org/rfc/rfc4627.txt), with all non-printable Unicode codepoints encoded as `\uXXXX`. #### "i" - data read from stdin Event of type `"i"` represents character(s) typed in by the user, or more specifically, data sent from terminal emulator to stdin of the recorded shell. `event-data` is a string containing the captured character(s). Like with `"o"` event, it's UTF-8 encoded JSON string, with all non-printable Unicode codepoints encoded as `\uXXXX`. > Official asciinema recorder doesn't capture stdin by default. All > implementations of asciicast-compatible terminal recorder should not capture > it either unless explicitly permitted by the user. ## Notes on compatibility Version 2 of asciicast file format solves several problems which couldn't be easily fixed in the old format: * minimal memory usage when recording and replaying arbitrarily long sessions - disk space is the only limit, * when the recording session is interrupted (computer crash, accidental close of terminal window) you don't lose the whole recording, * it's real-time streaming friendly. Due to file structure change (standard JSON => newline-delimited JSON) version 2 is not backwards compatible with version 1. Support for v2 has been added in: * [asciinema terminal recorder](https://github.com/asciinema/asciinema) - 2.0 (to be released, currently on development branch) * [asciinema web player](https://github.com/asciinema/asciinema-player) - 2.6.0 * [asciinema server](https://github.com/asciinema/asciinema-server) - v20171105 tag in git repository �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������man/������������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0011642�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������man/Makefile����������������������������������������������������������������������������������������0000664�0000000�0000000�00000000114�13237664152�0013276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������asciinema.1: asciinema.1.md pandoc asciinema.1.md -s -t man -o asciinema.1 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������man/asciinema.1�������������������������������������������������������������������������������������0000664�0000000�0000000�00000020543�13237664152�0013661�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������.\" Automatically generated by Pandoc 2.1.1 .\" .TH "ASCIINEMA" "1" "" "Version 2.0" "asciinema" .hy .SH NAME .PP \f[B]asciinema\f[] \- terminal session recorder .SH SYNOPSIS .PP \f[B]asciinema \-\-version\f[] .PD 0 .P .PD \f[B]asciinema\f[] \f[I]command\f[] [\f[I]options\f[]] [\f[I]args\f[]] .SH DESCRIPTION .PP asciinema lets you easily record terminal sessions and replay them in a terminal as well as in a web browser. .SH COMMANDS .PP asciinema is composed of multiple commands, similar to \f[C]git\f[], \f[C]apt\-get\f[] or \f[C]brew\f[]. .PP When you run \f[B]asciinema\f[] with no arguments help message is displayed, listing all available commands with their options. .SS rec [\f[I]filename\f[]] .PP Record terminal session. .PP By running \f[B]asciinema rec [filename]\f[] you start a new recording session. The command (process) that is recorded can be specified with \f[B]\-c\f[] option (see below), and defaults to \f[B]$SHELL\f[] which is what you want in most cases. .PP Recording finishes when you exit the shell (hit Ctrl+D or type \f[C]exit\f[]). If the recorded process is not a shell then recording finishes when the process exits. .PP If the \f[I]filename\f[] argument is omitted then (after asking for confirmation) the resulting asciicast is uploaded to asciinema\-server (https://github.com/asciinema/asciinema-server) (by default to asciinema.org), where it can be watched and shared. .PP If the \f[I]filename\f[] argument is given then the resulting recording (called asciicast (doc/asciicast-v2.md)) is saved to a local file. It can later be replayed with \f[B]asciinema play <filename>\f[] and/or uploaded to asciinema server with \f[B]asciinema upload <filename>\f[]. .PP \f[B]ASCIINEMA_REC=1\f[] is added to recorded process environment variables. This can be used by your shell's config file (\f[C]\&.bashrc\f[], \f[C]\&.zshrc\f[]) to alter the prompt or play a sound when the shell is being recorded. .TP .B Available options: \ .RS .TP .B \f[C]\-\-stdin\f[] Enable stdin (keyboard) recording (see below) .RS .RE .TP .B \f[C]\-\-append\f[] Append to existing recording .RS .RE .TP .B \f[C]\-\-raw\f[] Save raw STDOUT output, without timing information or other metadata .RS .RE .TP .B \f[C]\-\-overwrite\f[] Overwrite the recording if it already exists .RS .RE .TP .B \f[C]\-c,\ \-\-command=<command>\f[] Specify command to record, defaults to \f[B]$SHELL\f[] .RS .RE .TP .B \f[C]\-e,\ \-\-env=<var\-names>\f[] List of environment variables to capture, defaults to \f[B]SHELL,TERM\f[] .RS .RE .TP .B \f[C]\-t,\ \-\-title=<title>\f[] Specify the title of the asciicast .RS .RE .TP .B \f[C]\-i,\ \-\-idle\-time\-limit=<sec>\f[] Limit recorded terminal inactivity to max \f[C]<sec>\f[] seconds .RS .RE .TP .B \f[C]\-y,\ \-\-yes\f[] Answer \[lq]yes\[rq] to all prompts (e.g.\ upload confirmation) .RS .RE .TP .B \f[C]\-q,\ \-\-quiet\f[] Be quiet, suppress all notices/warnings (implies \f[B]\-y\f[]) .RS .RE .RE .PP Stdin recording allows for capturing of all characters typed in by the user in the currently recorded shell. This may be used by a player (e.g. asciinema\-player (https://github.com/asciinema/asciinema-player)) to display pressed keys. Because it's basically a key\-logging (scoped to a single shell instance), it's disabled by default, and has to be explicitly enabled via \f[B]\[en]stdin\f[] option. .SS play <\f[I]filename\f[]> .PP Replay recorded asciicast in a terminal. .PP This command replays given asciicast (as recorded by \f[B]rec\f[] command) directly in your terminal. .PP Following keyboard shortcuts are available: .IP .nf \f[C] Space\ \-\ toggle\ pause, \&.\ \-\ step\ through\ a\ recording\ a\ frame\ at\ a\ time\ (when\ paused), Ctrl+C\ \-\ exit. \f[] .fi .PP Playing from a local file: .IP .nf \f[C] asciinema\ play\ /path/to/asciicast.cast \f[] .fi .PP Playing from HTTP(S) URL: .IP .nf \f[C] asciinema\ play\ https://asciinema.org/a/22124.cast asciinema\ play\ http://example.com/demo.cast \f[] .fi .PP Playing from asciicast page URL (requires \f[C]<link\ rel="alternate"\ type="application/x\-asciicast"\ href="/my/ascii.cast">\f[] in page's HTML): .IP .nf \f[C] asciinema\ play\ https://asciinema.org/a/22124 asciinema\ play\ http://example.com/blog/post.html \f[] .fi .PP Playing from stdin: .IP .nf \f[C] cat\ /path/to/asciicast.cast\ |\ asciinema\ play\ \- ssh\ user\@host\ cat\ asciicast.cast\ |\ asciinema\ play\ \- \f[] .fi .PP Playing from IPFS: .IP .nf \f[C] asciinema\ play\ dweb:/ipfs/QmNe7FsYaHc9SaDEAEXbaagAzNw9cH7YbzN4xV7jV1MCzK/ascii.cast \f[] .fi .TP .B Available options: \ .RS .TP .B \f[C]\-i,\ \-\-idle\-time\-limit=<sec>\f[] Limit replayed terminal inactivity to max \f[C]<sec>\f[] seconds .RS .RE .TP .B \f[C]\-s,\ \-\-speed=<factor>\f[] Playback speed (can be fractional) .RS .RE .RE .SS cat <\f[I]filename\f[]> .PP Print full output of recorded asciicast to a terminal. .PP While \f[B]asciinema play \f[] replays the recorded session using timing information saved in the asciicast, \f[B]asciinema cat \f[] dumps the full output (including all escape sequences) to a terminal immediately. .PP \f[B]asciinema cat existing.cast >output.txt\f[] gives the same result as recording via \f[B]asciinema rec \-\-raw output.txt\f[]. .SS upload .PP Upload recorded asciicast to asciinema.org site. .PP This command uploads given asciicast (recorded by \f[B]rec\f[] command) to asciinema.org, where it can be watched and shared. .PP \f[B]asciinema rec demo.cast\f[] + \f[B]asciinema play demo.cast\f[] + \f[B]asciinema upload demo.cast\f[] is a nice combo if you want to review an asciicast before publishing it on asciinema.org. .SS auth .PP Link your install ID with your asciinema.org user account. .PP If you want to manage your recordings (change title/theme, delete) at asciinema.org you need to link your \[lq]install ID\[rq] with asciinema.org user account. .PP This command displays the URL to open in a web browser to do that. You may be asked to log in first. .PP Install ID is a random ID (UUID v4 (https://en.wikipedia.org/wiki/Universally_unique_identifier)) generated locally when you run asciinema for the first time, and saved at \f[B]$HOME/.config/asciinema/install\-id\f[]. It's purpose is to connect local machine with uploaded recordings, so they can later be associated with asciinema.org account. This way we decouple uploading from account creation, allowing them to happen in any order. .PP Note: A new install ID is generated on each machine and system user account you use asciinema on, so in order to keep all recordings under a single asciinema.org account you need to run \f[B]asciinema auth\f[] on all of those machines. .PP Note: asciinema versions prior to 2.0 confusingly referred to install ID as \[lq]API token\[rq]. .SH EXAMPLES .PP Record your first session: .IP .nf \f[C] asciinema\ rec\ first.cast \f[] .fi .PP Now replay it with double speed: .IP .nf \f[C] asciinema\ play\ \-s\ 2\ first.cast \f[] .fi .PP Or with normal speed but with idle time limited to 2 seconds: .IP .nf \f[C] asciinema\ play\ \-i\ 2\ first.cast \f[] .fi .PP You can pass \f[B]\-i 2\f[] to \f[B]asciinema rec\f[] as well, to set it permanently on a recording. Idle time limiting makes the recordings much more interesting to watch, try it. .PP If you want to watch and share it on the web, upload it: .IP .nf \f[C] asciinema\ upload\ first.cast \f[] .fi .PP The above uploads it to <https://asciinema.org>, which is a default asciinema\-server (<https://github.com/asciinema/asciinema-server>) instance, and prints a secret link you can use to watch your recording in a web browser. .PP You can record and upload in one step by omitting the filename: .IP .nf \f[C] asciinema\ rec \f[] .fi .PP You'll be asked to confirm the upload when the recording is done, so nothing is sent anywhere without your consent. .SH ENVIRONMENT .TP .B \f[B]ASCIINEMA_API_URL\f[] This variable allows overriding asciinema\-server URL (which defaults to https://asciinema.org) in case you're running your own asciinema\-server instance. .RS .RE .TP .B \f[B]ASCIINEMA_CONFIG_HOME\f[] This variable allows overriding config directory location. Default location is $XDG_CONFIG_HOME/asciinema (when $XDG_CONFIG_HOME is set) or $HOME/.config/asciinema. .RS .RE .SH BUGS .PP See GitHub Issues: <https://github.com/asciinema/asciinema/issues> .SH AUTHORS .PP asciinema's lead developer is Marcin Kulik. .PP For a list of all contributors look here: <https://github.com/asciinema/asciinema/contributors> .PP This Manual Page was written by Marcin Kulik with help from Kurt Pfeifle. �������������������������������������������������������������������������������������������������������������������������������������������������������������man/asciinema.1.md����������������������������������������������������������������������������������0000664�0000000�0000000�00000017007�13237664152�0014261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������% ASCIINEMA(1) Version 2.0 | asciinema NAME ==== **asciinema** - terminal session recorder SYNOPSIS ======== | **asciinema \-\-version** | **asciinema** _command_ \[_options_] \[_args_] DESCRIPTION =========== asciinema lets you easily record terminal sessions and replay them in a terminal as well as in a web browser. COMMANDS ======== asciinema is composed of multiple commands, similar to `git`, `apt-get` or `brew`. When you run **asciinema** with no arguments help message is displayed, listing all available commands with their options. rec [_filename_] --- Record terminal session. By running **asciinema rec [filename]** you start a new recording session. The command (process) that is recorded can be specified with **-c** option (see below), and defaults to **$SHELL** which is what you want in most cases. Recording finishes when you exit the shell (hit <kbd>Ctrl+D</kbd> or type `exit`). If the recorded process is not a shell then recording finishes when the process exits. If the _filename_ argument is omitted then (after asking for confirmation) the resulting asciicast is uploaded to [asciinema-server](https://github.com/asciinema/asciinema-server) (by default to asciinema.org), where it can be watched and shared. If the _filename_ argument is given then the resulting recording (called [asciicast](doc/asciicast-v2.md)) is saved to a local file. It can later be replayed with **asciinema play \<filename>** and/or uploaded to asciinema server with **asciinema upload \<filename>**. **ASCIINEMA_REC=1** is added to recorded process environment variables. This can be used by your shell's config file (`.bashrc`, `.zshrc`) to alter the prompt or play a sound when the shell is being recorded. Available options: :   `--stdin` : Enable stdin (keyboard) recording (see below) `--append` : Append to existing recording `--raw` : Save raw STDOUT output, without timing information or other metadata `--overwrite` : Overwrite the recording if it already exists `-c, --command=<command>` : Specify command to record, defaults to **$SHELL** `-e, --env=<var-names>` : List of environment variables to capture, defaults to **SHELL,TERM** `-t, --title=<title>` : Specify the title of the asciicast `-i, --idle-time-limit=<sec>` : Limit recorded terminal inactivity to max `<sec>` seconds `-y, --yes` : Answer "yes" to all prompts (e.g. upload confirmation) `-q, --quiet` : Be quiet, suppress all notices/warnings (implies **-y**) Stdin recording allows for capturing of all characters typed in by the user in the currently recorded shell. This may be used by a player (e.g. [asciinema-player](https://github.com/asciinema/asciinema-player)) to display pressed keys. Because it's basically a key-logging (scoped to a single shell instance), it's disabled by default, and has to be explicitly enabled via **--stdin** option. play <_filename_> --- Replay recorded asciicast in a terminal. This command replays given asciicast (as recorded by **rec** command) directly in your terminal. Following keyboard shortcuts are available: Space - toggle pause, . - step through a recording a frame at a time (when paused), Ctrl+C - exit. Playing from a local file: asciinema play /path/to/asciicast.cast Playing from HTTP(S) URL: asciinema play https://asciinema.org/a/22124.cast asciinema play http://example.com/demo.cast Playing from asciicast page URL (requires `<link rel="alternate" type="application/x-asciicast" href="/my/ascii.cast">` in page's HTML): asciinema play https://asciinema.org/a/22124 asciinema play http://example.com/blog/post.html Playing from stdin: cat /path/to/asciicast.cast | asciinema play - ssh user@host cat asciicast.cast | asciinema play - Playing from IPFS: asciinema play dweb:/ipfs/QmNe7FsYaHc9SaDEAEXbaagAzNw9cH7YbzN4xV7jV1MCzK/ascii.cast Available options: :   `-i, --idle-time-limit=<sec>` : Limit replayed terminal inactivity to max `<sec>` seconds `-s, --speed=<factor>` : Playback speed (can be fractional) cat <_filename_> --- Print full output of recorded asciicast to a terminal. While **asciinema play <filename>** replays the recorded session using timing information saved in the asciicast, **asciinema cat <filename>** dumps the full output (including all escape sequences) to a terminal immediately. **asciinema cat existing.cast >output.txt** gives the same result as recording via **asciinema rec \-\-raw output.txt**. upload <filename> --- Upload recorded asciicast to asciinema.org site. This command uploads given asciicast (recorded by **rec** command) to asciinema.org, where it can be watched and shared. **asciinema rec demo.cast** + **asciinema play demo.cast** + **asciinema upload demo.cast** is a nice combo if you want to review an asciicast before publishing it on asciinema.org. auth --- Link your install ID with your asciinema.org user account. If you want to manage your recordings (change title/theme, delete) at asciinema.org you need to link your "install ID" with asciinema.org user account. This command displays the URL to open in a web browser to do that. You may be asked to log in first. Install ID is a random ID ([UUID v4](https://en.wikipedia.org/wiki/Universally_unique_identifier)) generated locally when you run asciinema for the first time, and saved at **$HOME/.config/asciinema/install-id**. It's purpose is to connect local machine with uploaded recordings, so they can later be associated with asciinema.org account. This way we decouple uploading from account creation, allowing them to happen in any order. Note: A new install ID is generated on each machine and system user account you use asciinema on, so in order to keep all recordings under a single asciinema.org account you need to run **asciinema auth** on all of those machines. Note: asciinema versions prior to 2.0 confusingly referred to install ID as "API token". EXAMPLES ======== Record your first session: asciinema rec first.cast Now replay it with double speed: asciinema play -s 2 first.cast Or with normal speed but with idle time limited to 2 seconds: asciinema play -i 2 first.cast You can pass **-i 2** to **asciinema rec** as well, to set it permanently on a recording. Idle time limiting makes the recordings much more interesting to watch, try it. If you want to watch and share it on the web, upload it: asciinema upload first.cast The above uploads it to <https://asciinema.org>, which is a default asciinema-server (<https://github.com/asciinema/asciinema-server>) instance, and prints a secret link you can use to watch your recording in a web browser. You can record and upload in one step by omitting the filename: asciinema rec You'll be asked to confirm the upload when the recording is done, so nothing is sent anywhere without your consent. ENVIRONMENT =========== **ASCIINEMA_API_URL** : This variable allows overriding asciinema-server URL (which defaults to https://asciinema.org) in case you're running your own asciinema-server instance. **ASCIINEMA_CONFIG_HOME** : This variable allows overriding config directory location. Default location is $XDG\_CONFIG\_HOME/asciinema (when $XDG\_CONFIG\_HOME is set) or $HOME/.config/asciinema. BUGS ==== See GitHub Issues: <https://github.com/asciinema/asciinema/issues> AUTHORS ======= asciinema's lead developer is Marcin Kulik. For a list of all contributors look here: <https://github.com/asciinema/asciinema/contributors> This Manual Page was written by Marcin Kulik with help from Kurt Pfeifle. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������setup.cfg�������������������������������������������������������������������������������������������0000664�0000000�0000000�00000000050�13237664152�0012703�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������[metadata] description-file = README.md ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������setup.py��������������������������������������������������������������������������������������������0000664�0000000�0000000�00000002661�13237664152�0012606�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import asciinema import sys from setuptools import setup if sys.version_info[0] < 3: sys.exit('Python < 3 is unsupported.') url_template = 'https://github.com/asciinema/asciinema/archive/v%s.tar.gz' requirements = [] setup( name='asciinema', version=asciinema.__version__, packages=['asciinema', 'asciinema.commands', 'asciinema.asciicast'], license='GNU GPLv3', description='Terminal session recorder', author=asciinema.__author__, author_email='m@ku1ik.com', url='https://asciinema.org', download_url=(url_template % asciinema.__version__), entry_points={ 'console_scripts': [ 'asciinema = asciinema.__main__:main', ], }, install_requires=requirements, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Natural Language :: English', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Topic :: System :: Shells', 'Topic :: Terminals', 'Topic :: Utilities' ], ) �������������������������������������������������������������������������������tests/����������������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0012231�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/__init__.py�����������������������������������������������������������������������������������0000664�0000000�0000000�00000000000�13237664152�0014330�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/config_test.py��������������������������������������������������������������������������������0000664�0000000�0000000�00000012110�13237664152�0015102�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from nose.tools import assert_equal, assert_raises import os import os.path as path import tempfile import re import asciinema.config as cfg def create_config(content=None, env={}): dir = tempfile.mkdtemp() if content: path = dir + '/config' with open(path, 'w') as f: f.write(content) return cfg.Config(dir, env) def read_install_id(install_id_path): with open(install_id_path, 'r') as f: return f.read().strip() def test_upgrade_no_config_file(): config = create_config() config.upgrade() install_id = read_install_id(config.install_id_path) assert re.match('^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}', install_id) assert_equal(install_id, config.install_id) assert not path.exists(config.config_file_path) # it must not change after another upgrade config.upgrade() assert_equal(read_install_id(config.install_id_path), install_id) def test_upgrade_config_file_with_api_token(): config = create_config("[api]\ntoken = foo-bar-baz") config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') assert_equal(config.install_id, 'foo-bar-baz') assert not path.exists(config.config_file_path) config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') def test_upgrade_config_file_with_api_token_and_more(): config = create_config("[api]\ntoken = foo-bar-baz\nurl = http://example.com") config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') assert_equal(config.install_id, 'foo-bar-baz') assert_equal(config.api_url, 'http://example.com') assert path.exists(config.config_file_path) config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') def test_upgrade_config_file_with_user_token(): config = create_config("[user]\ntoken = foo-bar-baz") config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') assert_equal(config.install_id, 'foo-bar-baz') assert not path.exists(config.config_file_path) config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') def test_upgrade_config_file_with_user_token_and_more(): config = create_config("[user]\ntoken = foo-bar-baz\n[api]\nurl = http://example.com") config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') assert_equal(config.install_id, 'foo-bar-baz') assert_equal(config.api_url, 'http://example.com') assert path.exists(config.config_file_path) config.upgrade() assert_equal(read_install_id(config.install_id_path), 'foo-bar-baz') def test_default_api_url(): config = create_config('') assert_equal('https://asciinema.org', config.api_url) def test_default_record_stdin(): config = create_config('') assert_equal(False, config.record_stdin) def test_default_record_command(): config = create_config('') assert_equal(None, config.record_command) def test_default_record_env(): config = create_config('') assert_equal('SHELL,TERM', config.record_env) def test_default_record_idle_time_limit(): config = create_config('') assert_equal(None, config.record_idle_time_limit) def test_default_record_yes(): config = create_config('') assert_equal(False, config.record_yes) def test_default_record_quiet(): config = create_config('') assert_equal(False, config.record_quiet) def test_default_play_idle_time_limit(): config = create_config('') assert_equal(None, config.play_idle_time_limit) def test_api_url(): config = create_config("[api]\nurl = http://the/url") assert_equal('http://the/url', config.api_url) def test_api_url_when_override_set(): config = create_config("[api]\nurl = http://the/url", { 'ASCIINEMA_API_URL': 'http://the/url2'}) assert_equal('http://the/url2', config.api_url) def test_record_command(): command = 'bash -l' config = create_config("[record]\ncommand = %s" % command) assert_equal(command, config.record_command) def test_record_stdin(): config = create_config("[record]\nstdin = yes") assert_equal(True, config.record_stdin) def test_record_env(): config = create_config("[record]\nenv = FOO,BAR") assert_equal('FOO,BAR', config.record_env) def test_record_idle_time_limit(): config = create_config("[record]\nidle_time_limit = 2.35") assert_equal(2.35, config.record_idle_time_limit) config = create_config("[record]\nmaxwait = 2.35") assert_equal(2.35, config.record_idle_time_limit) def test_record_yes(): yes = 'yes' config = create_config("[record]\nyes = %s" % yes) assert_equal(True, config.record_yes) def test_record_quiet(): quiet = 'yes' config = create_config("[record]\nquiet = %s" % quiet) assert_equal(True, config.record_quiet) def test_play_idle_time_limit(): config = create_config("[play]\nidle_time_limit = 2.35") assert_equal(2.35, config.play_idle_time_limit) config = create_config("[play]\nmaxwait = 2.35") assert_equal(2.35, config.play_idle_time_limit) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/demo.cast�������������������������������������������������������������������������������������0000664�0000000�0000000�00000012076�13237664152�0014037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{"env": {"TERM": "xterm-256color", "SHELL": "/usr/local/bin/fish"}, "width": 75, "height": 18, "timestamp": 1509091818, "version": 2, "idle_time_limit": 2.0} [0.089436, "o", "\u001b]0;fish /Users/sickill/code/asciinema/asciinema\u0007\u001b[30m\u001b(B\u001b[m"] [0.100989, "o", "\u001b[?2004h"] [0.164215, "o", "\u001b]0;fish /Users/sickill/code/asciinema/asciinema\u0007\u001b[30m\u001b(B\u001b[m"] [0.164513, "o", "\u001b[38;5;237m⏎\u001b(B\u001b[m \r⏎ \r\u001b[2K"] [0.164709, "o", "\u001b[32m~/c/a/asciinema\u001b[30m\u001b(B\u001b[m (develop ↩☡=) \u001b[30m\u001b(B\u001b[m\u001b[K"] [1.511526, "i", "v"] [1.511937, "o", "v"] [1.512148, "o", "\b\u001b[38;2;0;95;215mv\u001b[30m\u001b(B\u001b[m"] [1.514564, "o", "\u001b[38;2;85;85;85mim tests/vim.cast \u001b[18D\u001b[30m\u001b(B\u001b[m"] [1.615727, "i", "i"] [1.616261, "o", "\u001b[38;2;0;95;215mi\u001b[38;2;85;85;85mm tests/vim.cast \u001b[17D\u001b[30m\u001b(B\u001b[m"] [1.694908, "i", "m"] [1.695262, "o", "\u001b[38;2;0;95;215mm\u001b[38;2;85;85;85m tests/vim.cast \u001b[16D\u001b[30m\u001b(B\u001b[m"] [2.751713, "i", "\r"] [2.752186, "o", "\u001b[K\r\n\u001b[30m"] [2.752381, "o", "\u001b(B\u001b[m\u001b[?2004l"] [2.752718, "o", "\u001b]0;vim /Users/sickill/code/asciinema/asciinema\u0007\u001b[30m\u001b(B\u001b[m\r"] [2.86619, "o", "\u001b[?1000h\u001b[?2004h\u001b[?1049h\u001b[?1h\u001b=\u001b[?2004h"] [2.867669, "o", "\u001b[1;18r\u001b[?12h\u001b[?12l\u001b[27m\u001b[29m\u001b[m\u001b[38;5;231m\u001b[48;5;235m\u001b[H\u001b[2J\u001b[2;1H▽\u001b[6n\u001b[2;1H \u001b[1;1H\u001b[>c"] [2.868169, "i", "\u001b[2;2R\u001b[>0;95;0c"] [2.869918, "o", "\u001b[?1000l\u001b[?1002h\u001b[?12$p"] [2.870136, "o", "\u001b[?25l\u001b[1;1H\u001b[93m1 \u001b[m\u001b[38;5;231m\u001b[48;5;235m\r\n\u001b[38;5;59m\u001b[48;5;236m~ \u001b[3;1H~ \u001b[4;1H~ \u001b[5;1H~ \u001b[6;1H~ \u001b[7;1H~ \u001b[8;1H~ \u001b[9;1H~ \u001b[10;1H~ \u001b[11;1H~ \u001b[12;1H~ \u001b[13;1H~ "] [2.870245, "o", " \u001b[14;1H~ \u001b[15;1H~ \u001b[16;1H~ \u001b[m\u001b[38;5;231m\u001b[48;5;235m\u001b[17;1H\u001b[1m\u001b[38;5;231m\u001b[48;5;236m[No Name] (unix/utf-8/) (line 0/1, col 000)\u001b[m\u001b[38;5;231m\u001b[48;5;235m\u001b[3;30HVIM - Vi IMproved\u001b[5;30Hversion 8.0.1171\u001b[6;26Hby Bram Moolenaar et al.\u001b[7;17HVim is open source and freely distributable\u001b[9;24HBecome a registered Vim user!\u001b[10;15Htype :help register\u001b[38;5;59m\u001b[48;5;236m<Enter>\u001b[m\u001b[38;5;231m\u001b[48;5;235m for information \u001b[12;15Htype :q\u001b[38;5;59m\u001b[48;5;236m<Enter>\u001b[m\u001b[38;5;231m\u001b[48;5;235m to exit \u001b[13;15Htype :help\u001b[38;5;59m\u001b[48;5;236m<Enter>\u001b[m\u001b[38;5;231m\u001b[48;5;235m or \u001b[38;5;59m\u001b[48;5;236m<F1>\u001b[m\u001b[38;5;231m\u001b[48;5;235m for on-line help\u001b[14;15Htype :help version8\u001b[38;5;59m\u001b[48;5;236m<Enter>\u001b[m\u001b[38;5;231m\u001b[48;5;235m for version"] [2.870302, "o", " info\u001b[1;5H\u001b[?25h"] [5.63147, "i", ":"] [5.631755, "o", "\u001b[?25l\u001b[18;65H:\u001b[1;5H"] [5.631934, "o", "\u001b[18;65H\u001b[K\u001b[18;1H:\u001b[?2004l\u001b[?2004h\u001b[?25h"] [6.16692, "i", "q"] [6.167137, "o", "q\u001b[?25l\u001b[?25h"] [7.463349, "i", "\r"] [7.463561, "o", "\r"] [7.498922, "o", "\u001b[?25l\u001b[?1002l\u001b[?2004l"] [7.604236, "o", "\u001b[18;1H\u001b[K\u001b[18;1H\u001b[?2004l\u001b[?1l\u001b>\u001b[?25h\u001b[?1049l"] [7.612576, "o", "\u001b[?2004h"] [7.655999, "o", "\u001b]0;fish /Users/sickill/code/asciinema/asciinema\u0007\u001b[30m\u001b(B\u001b[m"] [7.656239, "o", "\u001b[38;5;237m⏎\u001b(B\u001b[m \r⏎ \r\u001b[2K\u001b[32m~/c/a/asciinema\u001b[30m\u001b(B\u001b[m (develop ↩☡=) \u001b[30m\u001b(B\u001b[m\u001b[K"] [11.891762, "i", "\u0004"] [11.893297, "o", "\r\n\u001b[30m\u001b(B\u001b[m\u001b[30m\u001b(B\u001b[m"] [11.89348, "o", "\u001b[?2004l"] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/demo.json�������������������������������������������������������������������������������������0000664�0000000�0000000�00000013012�13237664152�0014045�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "version": 1, "width": 80, "height": 40, "duration": 6.46111, "command": "/bin/bash", "title": null, "env": { "TERM": "xterm-256color", "SHELL": "/bin/bash" }, "stdout": [ [ 0.013659, "\u001b[?1034hbash-3.2$ " ], [ 1.923187, "v" ], [ 0.064049, "i" ], [ 0.032034, "m" ], [ 0.19157, "\r\n" ], [ 0.032342, "\u001b[?1049h\u001b[?1h\u001b=\u001b[2;1H▽\u001b[6n\u001b[2;1H \u001b[1;1H" ], [ 0.001436, "\u001b[1;40r\u001b[?12;25h\u001b[?12l\u001b[?25h\u001b[27m\u001b[m\u001b[H\u001b[2J\u001b[>c" ], [ 0.000311, "\u001b[?25l\u001b[1;1H\u001b[33m 1 \u001b[m\r\n\u001b[1m\u001b[34m~ \u001b[3;1H~ \u001b[4;1H~ \u001b[5;1H~ \u001b[6;1H~ \u001b[7;1H~ \u001b[8;1H~ \u001b[9;1H~ \u001b[10;1H~ \u001b[11;1H~ \u001b[12;1H~ \u001b[13;1H~ " ], [ 3.9e-05, " \u001b[14;1H~ \u001b[15;1H~ \u001b[16;1H~ \u001b[17;1H~ \u001b[18;1H~ \u001b[19;1H~ \u001b[20;1H~ \u001b[21;1H~ \u001b[22;1H~ \u001b[23;1H~ \u001b[24;1H~ \u001b[25;1H~ " ], [ 9.2e-05, " \u001b[26;1H~ \u001b[27;1H~ \u001b[28;1H~ \u001b[29;1H~ \u001b[30;1H~ \u001b[31;1H~ \u001b[32;1H~ \u001b[33;1H~ \u001b[34;1H~ \u001b[35;1H~ \u001b[36;1H~ \u001b[37;" ], [ 2.4e-05, "1H~ \u001b[38;1H~ \u001b[m\u001b[39;1H\u001b[1m\u001b[7m[No Name] \u001b[m\u001b[14;32HVIM - Vi IMproved\u001b[16;33Hversion 7.4.8056\u001b[17;29Hby Bram Moolenaar et al.\u001b[18;19HVim is open source and freely distributable\u001b[20;26HBecome a registered Vim user!\u001b[21;18Htype :help register\u001b[32m<Enter>\u001b[m for information \u001b[23;18Htype :q\u001b[32m<Enter>\u001b[m to exit \u001b[24;18Htype :help\u001b[32m<Enter>\u001b[m or \u001b[32m<F1>\u001b[m for on-line help\u001b[25;18Htype :help version7\u001b[32m<Enter>\u001b[m for version info\u001b[1;5H\u001b[?12l\u001b[?25h" ], [ 1.070242, "\u001b[?25l\u001b[40;1H:" ], [ 2.3e-05, "\u001b[?12l\u001b[?25h" ], [ 0.503964, "q" ], [ 0.151903, "u" ], [ 0.04002, "i" ], [ 0.088084, "t" ], [ 0.287636, "\r" ], [ 0.002178, "\u001b[?25l\u001b[40;1H\u001b[K\u001b[40;1H\u001b[?1l\u001b>\u001b[?12l\u001b[?25h\u001b[?1049l" ], [ 0.000999, "bash-3.2$ " ], [ 1.58912, "e" ], [ 0.184114, "x" ], [ 0.087915, "i" ], [ 0.103987, "t" ], [ 0.087613, "\r\n" ] ] }����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/distros.sh������������������������������������������������������������������������������������0000775�0000000�0000000�00000000650�13237664152�0014260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env bash set -e path_to_self="${BASH_SOURCE[0]}" tests_dir="$(cd "$(dirname "$path_to_self")" && pwd)" test() { printf "\e[1;32mTesting on $1...\e[0m\n" echo docker build -t asciinema/asciinema:$1 -f tests/distros/Dockerfile.$1 . docker run --rm -ti asciinema/asciinema:$1 tests/integration.sh } test ubuntu test debian test fedora test centos echo printf "\e[1;32mAll tests passed.\e[0m\n" ����������������������������������������������������������������������������������������tests/distros/��������������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13237664152�0013720�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/distros/Dockerfile.centos���������������������������������������������������������������������0000664�0000000�0000000�00000000302�13237664152�0017177�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������FROM centos:7 RUN yum install -y epel-release RUN yum install -y python34 WORKDIR /usr/src/app COPY asciinema asciinema COPY tests tests ENV LANG en_US.utf8 ENV SHELL /bin/bash ENV USER docker ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/distros/Dockerfile.debian���������������������������������������������������������������������0000664�0000000�0000000�00000000467�13237664152�0017142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������FROM debian:jessie RUN apt-get update && apt-get install -y \ ca-certificates \ locales \ python3 RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 WORKDIR /usr/src/app COPY asciinema asciinema COPY tests tests ENV LANG en_US.utf8 ENV SHELL /bin/bash ENV USER docker ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/distros/Dockerfile.fedora���������������������������������������������������������������������0000664�0000000�0000000�00000000251�13237664152�0017147�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������FROM fedora:26 RUN dnf install -y python3 procps WORKDIR /usr/src/app COPY asciinema asciinema COPY tests tests ENV LANG en_US.utf8 ENV SHELL /bin/bash ENV USER docker �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/distros/Dockerfile.ubuntu���������������������������������������������������������������������0000664�0000000�0000000�00000000466�13237664152�0017241�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������FROM ubuntu:16.04 RUN apt-get update && apt-get install -y \ ca-certificates \ locales \ python3 RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 WORKDIR /usr/src/app COPY asciinema asciinema COPY tests tests ENV LANG en_US.utf8 ENV SHELL /bin/bash ENV USER docker ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/integration.sh��������������������������������������������������������������������������������0000775�0000000�0000000�00000004147�13237664152�0015121�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env bash set -e set -x if ! type "pkill" >/dev/null 2>&1; then echo "error: pkill not installed" exit 1 fi python3 -V export ASCIINEMA_CONFIG_HOME=`mktemp -d 2>/dev/null || mktemp -d -t asciinema-config-home` TMP_DATA_DIR=`mktemp -d 2>/dev/null || mktemp -d -t asciinema-data-dir` trap "rm -rf $ASCIINEMA_CONFIG_HOME $TMP_DATA_DIR" EXIT function asciinema() { python3 -m asciinema "$@" } ## test help message asciinema -h ## test version command asciinema --version ## test auth command asciinema auth ## test play command # asciicast v1 asciinema play -s 5 tests/demo.json asciinema play -s 5 -i 0.2 tests/demo.json cat tests/demo.json | asciinema play -s 5 - # asciicast v2 asciinema play -s 5 tests/demo.cast asciinema play -s 5 -i 0.2 tests/demo.cast cat tests/demo.cast | asciinema play -s 5 - ## test cat command # asciicast v1 asciinema cat tests/demo.json cat tests/demo.json | asciinema cat - # asciicast v2 asciinema cat tests/demo.cast cat tests/demo.cast | asciinema cat - ## test rec command # normal program asciinema rec -c 'bash -c "echo t3st; sleep 2; echo ok"' "$TMP_DATA_DIR/1a.cast" grep '"o",' "$TMP_DATA_DIR/1a.cast" # very quickly exiting program # https://github.com/asciinema/asciinema/issues/246 # asciinema rec -c who "$TMP_DATA_DIR/1b.cast" # grep '"o",' "$TMP_DATA_DIR/1b.cast" # signal handling bash -c "sleep 1; pkill -28 -n -f 'm asciinema'" & asciinema rec -c 'bash -c "echo t3st; sleep 2; echo ok"' "$TMP_DATA_DIR/2.cast" bash -c "sleep 1; pkill -n -f 'bash -c echo t3st'" & asciinema rec -c 'bash -c "echo t3st; sleep 2; echo ok"' "$TMP_DATA_DIR/3.cast" bash -c "sleep 1; pkill -9 -n -f 'bash -c echo t3st'" & asciinema rec -c 'bash -c "echo t3st; sleep 2; echo ok"' "$TMP_DATA_DIR/4.cast" # with stdin recording asciinema rec --stdin -c 'bash -c "echo t3st; sleep 1; echo ok"' "$TMP_DATA_DIR/5.cast" # raw output recording asciinema rec --raw -c 'bash -c "echo t3st; sleep 1; echo ok"' "$TMP_DATA_DIR/6.raw" # appending to existing recording asciinema rec -c 'echo allright!; sleep 0.1' "$TMP_DATA_DIR/7.cast" asciinema rec --append -c uptime "$TMP_DATA_DIR/7.cast" �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tests/pty_recorder_test.py��������������������������������������������������������������������������0000664�0000000�0000000�00000001746�13237664152�0016353�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import os import pty from nose.tools import assert_equal from .test_helper import Test from asciinema.pty_recorder import PtyRecorder class FakeStdout: def __init__(self): self.data = [] def write_stdout(self, data): self.data.append(data) def write_stdin(self, data): pass class TestPtyRecorder(Test): def setUp(self): self.real_os_write = os.write os.write = self.os_write def tearDown(self): os.write = self.real_os_write def os_write(self, fd, data): if fd != pty.STDOUT_FILENO: self.real_os_write(fd, data) def test_record_command_writes_to_stdout(self): pty_recorder = PtyRecorder() output = FakeStdout() command = ['python3', '-c', "import sys; import time; sys.stdout.write(\'foo\'); sys.stdout.flush(); time.sleep(0.01); sys.stdout.write(\'bar\')"] pty_recorder.record_command(command, output) assert_equal([b'foo', b'bar'], output.data) ��������������������������tests/test_helper.py��������������������������������������������������������������������������������0000664�0000000�0000000�00000001774�13237664152�0015132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������import sys try: from StringIO import StringIO except ImportError: from io import StringIO stdout = None def assert_printed(expected): success = expected in stdout.getvalue() assert success, 'expected text "%s" not printed' % expected def assert_not_printed(expected): success = expected not in stdout.getvalue() assert success, 'not expected text "%s" printed' % expected class Test: def setUp(self): global stdout self.real_stdout = sys.stdout sys.stdout = stdout = StringIO() def tearDown(self): sys.stdout = self.real_stdout class FakeClock: def __init__(self, values): self.values = values self.n = 0 def time(self): value = self.values[self.n] self.n += 1 return value class FakeAsciicast: def __init__(self, cmd=None, title=None, stdout=None, meta_data=None): self.cmd = cmd self.title = title self.stdout = stdout self.meta_data = meta_data or {} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������