31BqBSiH9IeUuL5S4Dyq8Z changeset

Changeset613532643934 (b)
ParentNone (a)
ab
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()
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--- Revision None
+++ Revision 613532643934
@@ -0,0 +1,37 @@
+env_user = "toto"
+
+def function(use_sudo=False):
+ run('mycommand', use_sudo)
+
+
+def function2(use_sudo=False):
+ run('mycommand', use_sudo)
+
+
+if env_user != "root": use_sudo = True
+
+function(use_sudo)
+
+function2(use_sudo)
+
+
+# INSTEAD OF:
+
+
+def function():
+ if env_user == "root":
+ run('mycommand')
+ else:
+ sudo('mycommand')
+
+
+def function2():
+ if env_user == "root":
+ run('mycommand')
+ else:
+ sudo('mycommand')
+
+
+function()
+
+function2()