|
@ -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 |
|
|