Skip to content

Commit 247c0b4

Browse files
author
Zaytsev Dmitry
committed
added base example to jupyter notebook and setup_email example in readme
1 parent 95285d4 commit 247c0b4

File tree

2 files changed

+78
-20
lines changed

2 files changed

+78
-20
lines changed

README.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,61 +127,80 @@ Alternatively, the progress can be tracked via the equivalent generator function
127127
##### ProgBar
128128

129129
*`ProgBar(iterations, track_time=True, width=30, bar_char='#',
130-
stream=2, title='', monitor=False, update_interval=None))`*
130+
stream=2, title='', monitor=False, update_interval=None, email=False))`*
131131

132-
- iterations : `int`
132+
- iterations : `int`
133133
Number of iterations for the iterative computation.
134-
- track_time : `bool` (default: `True`)
134+
- track_time : `bool` (default: `True`)
135135
Prints elapsed time when loop has finished.
136-
- width : `int` (default: 30)
136+
- width : `int` (default: 30)
137137
Sets the progress bar width in characters.
138-
- stream : `int` (default: 2).
138+
- stream : `int` (default: 2).
139139
Setting the output stream.
140140
Takes `1` for stdout, `2` for stderr, or a custom stream object
141-
- title : `str` (default: `''`)
141+
- title : `str` (default: `''`)
142142
Setting a title for the progress bar.
143-
- monitor : `bool` (default: `False`)
143+
- monitor : `bool` (default: `False`)
144144
Monitors CPU and memory usage if `True` (requires `psutil` package).
145-
- update_interval : float or int (default: `None`)
145+
- update_interval : float or int (default: `None`)
146146
The update_interval in seconds controls how often the progress
147147
is flushed to the screen.
148148
Automatic mode if `update_interval=None`.
149+
- email : `bool` (default: False)
150+
If `True` sends an email notification after finishing the task
149151

150152
##### ProgPercent
151153

152154
*`ProgPercent(iterations, track_time=True,
153-
stream=2, title='', monitor=False, update_interval=None)`*
155+
stream=2, title='', monitor=False, update_interval=None, email=False)`*
154156

155-
- iterations : `int`
156-
Number of iterations for the iterative computation.
157-
- track_time : `bool` (default: `True`)
157+
- iterations : `int`
158+
Number of iterations for the iterative computation.
159+
- track_time : `bool` (default: `True`)
158160
Prints elapsed time when loop has finished.
159-
- stream : `int` (default: 2).
161+
- stream : `int` (default: 2).
160162
Setting the output stream.
161163
Takes `1` for stdout, `2` for stderr, or a custom stream object
162-
- title : `str` (default : `''`).
164+
- title : `str` (default : `''`).
163165
Setting a title for the percentage indicator.
164-
- monitor : `bool` (default: `False`)
166+
- monitor : `bool` (default: `False`)
165167
Monitors CPU and memory usage if `True` (requires `psutil` package).
166-
- update_interval : float or int (default: `None`)
168+
- update_interval : float or int (default: `None`)
167169
The update_interval in seconds controls how often the progress
168170
is flushed to the screen.
169171
Automatic mode if `update_interval=None`.
172+
- email : `bool` (default: False)
173+
If `True` sends an email notification after finishing the task
170174

171175
##### update method
172176

173177
*`update(iterations=1, item_id=None, force_flush=False)`*
174178

175-
- iterations : int (default: `1`)
179+
- iterations : int (default: `1`)
176180
default argument can be changed to integer values
177181
`>=1` in order to update the progress indicators more than once
178182
per iteration.
179-
- item_id : str (default: `None`)
183+
- item_id : str (default: `None`)
180184
Print an item_id sring behind the progress bar
181-
- force_flush : bool (default: `False`)
185+
- force_flush : bool (default: `False`)
182186
If True, flushes the progress indicator to the output screen
183187
in each iteration.
184188

189+
190+
191+
##### Enable email notifications
192+
193+
*`pyprind.setup_email(smtp_server, smtp_port, username, password)`*
194+
195+
- smtp_server : str
196+
- smtp_port : int
197+
- username : str
198+
your full email username example (pyprind@pyprind.com)
199+
- password : str
200+
your password
201+
202+
If you want to use email notifications you can call function *`pyprind.setup_email`* only once and it will create an encrypted file with your email config and will be using it, if you want to change the email config just call *`pyprind.setup_email`* with new parameters and it will rewrite the email config file.
203+
185204
<br>
186205

187206

examples/pyprind_demo.ipynb

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"- [Progress Bar/Percentage Indicator - Changing the output stream](#Progress-Bar/Percentage-Indicator---Setting-a-title)\n",
7979
"- [Stopping the Progress Bar/Percentage Indicator early](#Stopping-the-Progress-Bar/Percentage-Indicator-early)\n",
8080
"- [Choosing your own progress bar style](#Choosing-your-own-progress-bar-style)\n",
81-
"- [Controlling the update frequency](#Controlling-the-update-frequency)"
81+
"- [Controlling the update frequency](#Controlling-the-update-frequency)\n",
82+
"- [Setting up email notification](#Setting-up-email-notification)"
8283
]
8384
},
8485
{
@@ -1038,6 +1039,44 @@
10381039
" time.sleep(0.2) # do some computation\n",
10391040
" bar.update()"
10401041
]
1042+
},
1043+
{
1044+
"cell_type": "markdown",
1045+
"metadata": {
1046+
"collapsed": false,
1047+
"deletable": true,
1048+
"editable": true
1049+
},
1050+
"source": [
1051+
"## Setting up email notification"
1052+
]
1053+
},
1054+
{
1055+
"cell_type": "code",
1056+
"execution_count": 7,
1057+
"metadata": {
1058+
"collapsed": false,
1059+
"deletable": true,
1060+
"editable": true
1061+
},
1062+
"outputs": [
1063+
{
1064+
"name": "stderr",
1065+
"output_type": "stream",
1066+
"text": [
1067+
"[100 %] Time elapsed: 00:00:20 | ETA: 00:00:00\n",
1068+
"Total time elapsed: 00:00:20\n"
1069+
]
1070+
}
1071+
],
1072+
"source": [
1073+
"n = 100\n",
1074+
"pyprind.setup_email('smtp.example.ru', 465, 'example@example.com', 'password')\n",
1075+
"bar = pyprind.ProgPercent(n, update_interval=4, email=True)\n",
1076+
"for i in range(n):\n",
1077+
" time.sleep(0.2) # do some computation\n",
1078+
" bar.update()"
1079+
]
10411080
}
10421081
],
10431082
"metadata": {

0 commit comments

Comments
 (0)