Browse Source

added:

- parsing of shell command into a list in suprocess example
- usage of RLock() as a context manager
- how to log exceptions in loguru example
pull/28/head
Martin Hanzalek 6 years ago
parent
commit
52e4027047
1 changed files with 15 additions and 2 deletions
  1. 17
      README.md

17
README.md

@ -1179,8 +1179,8 @@ import os
### Subprocess ### Subprocess
```python ```python
>>> import subprocess
>>> a = subprocess.run(['ls', '-a'], stdout=subprocess.PIPE)
>>> import subprocess, shlex
>>> a = subprocess.run(shlex.split('ls -a'), stdout=subprocess.PIPE)
>>> a.stdout >>> a.stdout
b'.\n..\nfile1.txt\nfile2.txt\n' b'.\n..\nfile1.txt\nfile2.txt\n'
>>> a.returncode >>> a.returncode
@ -1421,6 +1421,12 @@ lock.acquire()
... ...
lock.release() lock.release()
``` ```
or
```python
lock = RLock()
with lock:
...
```
Introspection Introspection
@ -1701,6 +1707,13 @@ logger.<level>('A logging message')
``` ```
* **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.** * **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.**
```python
try:
...
except Exception as e:
logger.exception('An error happened', e)
```
### Rotation ### Rotation
**Parameter that sets a condition when a new log file is created.** **Parameter that sets a condition when a new log file is created.**
```python ```python

Loading…
Cancel
Save