Eclectic Media Git toast-with_toast_when_complete / 1777d80
Merge remote-tracking branch 'upstream/master' Pulls commits 1f2b89 513c72 from git://eclecticmedia.space/public/toast Ariana Giroux 8 months ago
4 changed file(s) with 69 addition(s) and 144 deletion(s). Raw diff Collapse all Expand all
0 Copyright 2019 Ariana Giroux <ariana.giroux@gmail.com>
1
2 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
4 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
6 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 Quickstart guide for toast
1 ==========================
2
3 ``toast`` provides an ease of access layer to BurntToast_ native Windows notifications. This fork provides an ease of use script that allows automatic toast notifications on command execution.
4
5 This script is contained within ``./bin/`` and is simple to use: ::
6
7 $ toast_when_complete nmap -sP 172.16.1.0/24 # runs command, and spawns notification detailing command exit status.
8
9 Installing from Source
10 ======================
11
12 To install from source, first clone the repository_: ::
13
14 git clone git://eclecticmedia.hopto.org/arianagiroux/toast.git; cd toast
15
16 Then, with ``python3`` and ``pip`` installed, install the directory with: ::
17
18 python3 -m pip install .
19
20 *Note: You may need to install the BurntToast_ powershell executable. To do so, run "Install-Module -Name BurntToast" (with administrator privilleges)*
21
22 Usage
23 =====
24
25 First and foremost, the package provides a simple python API for notification scripting: ::
26
27 >>> from toast import toast
28 >>> toast(body='my message body',
29 >>> title='my optional title') # notification spawns
30
31 It also provides a simple `Click CLI` based command line interface. It can be used by simply using: ::
32
33 $ toast 'my message body' -t 'my optional title' # notification spawns
34
35
36 A Note about Compatibility
37 ==========================
38
39 It should be noted that this package is initially developed for the Windows Subsystem Layer for Linux, and may have mixed results on native Windows python interpreters. By design, the package only requires that BurntToast_ be on the system path, and callable from the command line with ``$ burnttoast.exe``. Feel free to submit a bug report to ``ariana.giroux+toast@gmail.com`` if you encounter issues. While untested under Windows proper, it should run without issue.
40
41 Contributing to the Project
42 ===========================
43
44 We expect to use a git native workflow. Fork the repository, host your fork publicly, and notify the development team that you have changes you would like to merge.
45
46 To do so, add our repository as your upstream: ::
47
48 git remote add upstream git-server:arianagiroux/toast.git
49
50 Obtain ``request-pull`` text: ::
51
52 git request-pull upstream/master origin
53
54 Send that output to the development team at ``ariana.giroux+toast@gmail.com``.
55
56
57 *Note: git-bug is used internally for the project, should we open that up to the public?*
58
59
60 .. _BurntToast: https://github.com/Windos/BurntToast
61 .. _repository: https://git.eclecticmedia.space/public/toast
+0
-61
Readme.rst less more
0 Quickstart guide for toast
1 ==========================
2
3 ``toast`` provides an ease of access layer to BurntToast_ native Windows notifications.
4
5 This fork adds an ease of use script, written in Bash called `toast_when_complete`. This script provides a wrapper around toast, and auto-formats a toast notification based on the execution of a user specified oneliner.
6
7 For example:
8 ::
9
10 toast_when_complete python3 -m venv venv # or some other long running oneliner
11
12 ``toast`` will then format the title and body of the toast notification to be as useful as possible, placing the command passed as the title, and the exit status in the body.
13
14 .. note:: the script is located at ``scripts/toast_when_complete``
15
16 Installing from Source
17 ======================
18
19 To install from source, first clone the repository_:
20 ::
21
22 git clone git://ecelcticmedia.hopto.org/arianagiroux/public/toast-with_toast_when_complete.git; cd toast
23
24 Then, with ``python3`` and ``pip`` installed, install the directory with:
25 ::
26
27 python3 -m pip install .
28
29 .. note:: You may need to install the BurntToast_ powershell executable. To do so, run "Install-Module -Name BurntToast" (with administrator privilleges)
30
31 Installing the Manpages
32 -----------------------
33
34 An ease of use command has been added to ``setup.py``, allowing you to simply
35 run:
36 ::
37
38 python3 setup.py install_docs
39
40 .. note:: You can uninstall the docs with ``setup.py`` via ``uninstall_docs``
41
42 Building the Manpages
43 =====================
44
45 A convienience function has been added to ``setup.py``, allowing you to compile
46 the docs with:
47 ::
48
49 python3 setup.py build_sphinx
50
51 .. note:: built pages located under ``docs/build/man``
52
53 .. note:: to view the manpages directly after compile, use ``python3 setup.py docs``.
54
55 ----
56
57 Consult the manpages for more information
58
59 .. _BurntToast: https://github.com/Windos/BurntToast
60 .. _repository: git-server:arianagiroux/toast.git
00 from setuptools import setup, find_packages
11 from distutils.cmd import Command
2 from sphinx.setup_command import BuildDoc
32 from sys import executable
43 from os import system, access, F_OK
54
109
1110 with open("requirements.txt", "r") as f:
1211 required = f.read().splitlines()
13
14
15 class Docs(Command):
16 user_options = [
17 ('manpage=', None, 'The man page section you want to view (likely 5)'),
18 ('compile', None, 'Force recompile of the docs'),
19 ]
20
21 def initialize_options(self):
22 self.manpage = '1'
23 self.compile = False
24
25 def finalize_options(self):
26 try:
27 int(self.manpage)
28 except ValueError:
29 print('--manpage must be an int between 1 and 8')
30 exit(1)
31
32 def run(self):
33 if not access('docs/build/man', F_OK) or self.compile:
34 self.announce('Compiling docs...', level=4)
35 system('%s setup.py build_sphinx' % executable)
36
37 if self.manpage == '':
38 system('man ./docs/build/man/toast.1')
39 else:
40 system('man ./docs/build/man/toast.%s' % self.manpage)
41
42
43 class InstallDocs(Command):
44 user_options = [
45 ('system-wide', None, 'Install pages system wide'),
46 ]
47
48 def initialize_options(self):
49 self.system_wide = False
50
51 def finalize_options(self):
52 pass
53
54 def run(self):
55 self.announce('Compiling docs...')
56 system('%s setup.py build_sphinx' % executable)
57 self.announce('Installing docs')
58 system('mkdir -p ~/.local/man/man1 ~/.local/man/man5')
59 system('cp docs/build/man/toast.1 ~/.local/man/man1/')
60 system('cp docs/build/man/toast.5 ~/.local/man/man5/')
61 system('mandb')
62
63
64 class UninstallDocs(Command):
65 user_options = [
66 ('system-wide', None, 'Install pages system wide'),
67 ]
68
69 def initialize_options(self):
70 self.system_wide = False
71
72 def finalize_options(self):
73 pass
74
75 def run(self):
76 self.announce('Uninstalling manpages')
77 system('rm ~/.local/man/man1/toast.1')
78 system('rm ~/.local/man/man5/toast.5')
79 system('mandb')
80
8112
8213 version = __version__
8314 setup(
9829 entry_points={
9930 'console_scripts': ['toast=toast.__main__'],
10031 },
101 cmdclass={
102 'build_sphinx': BuildDoc,
103 'docs': Docs,
104 'install_docs': InstallDocs,
105 'uninstall_docs': UninstallDocs,
106 },
107 command_options={
108 'build_sphinx': {
109 'project': ('setup.py', 'toast'),
110 'version': ('setup.py', str(__version__)),
111 'source_dir': ('setup.py', 'docs'),
112 'build_dir': ('setup.py', 'docs/build'),
113 'builder': ('setup.py', 'man'),
114 }},
11532 classifiers=(
11633 "Programming Language :: Python :: 3",
11734 "License :: OSI Approved :: MIT License",