31BqBSiH9IeUuL5S4Dyq8Z changeset
| Changeset | 613532643934 (b) |
|---|---|
| Parent | None (a) |
| a | b | ||
|---|---|---|---|
| 0 | + | env_user = "toto" | |
| 0 | + | ||
| 0 | + | def function(use_sudo=False): | |
| 0 | + | run('mycommand', use_sudo) | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | def function2(use_sudo=False): | |
| 0 | + | run('mycommand', use_sudo) | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | if env_user != "root": use_sudo = True | |
| 0 | + | ||
| 0 | + | function(use_sudo) | |
| 0 | + | ||
| 0 | + | function2(use_sudo) | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | # INSTEAD OF: | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | def function(): | |
| 0 | + | if env_user == "root": | |
| 0 | + | run('mycommand') | |
| 0 | + | else: | |
| 0 | + | sudo('mycommand') | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | def function2(): | |
| 0 | + | if env_user == "root": | |
| 0 | + | run('mycommand') | |
| 0 | + | else: | |
| 0 | + | sudo('mycommand') | |
| 0 | + | ||
| 0 | + | ||
| 0 | + | function() | |
| 0 | + | ||
| 0 | + | function2() | |
| ... | |||
|
|