Chromium Code Reviews| Index: media/tools/constrained_network_server/traffic_control.py |
| diff --git a/media/tools/constrained_network_server/traffic_control.py b/media/tools/constrained_network_server/traffic_control.py |
| index c27a255365b766cdd68ade24204916fc9d02285d..342b01d8e4c3beb6bbbddca73d1995790db4e682 100755 |
| --- a/media/tools/constrained_network_server/traffic_control.py |
| +++ b/media/tools/constrained_network_server/traffic_control.py |
| @@ -9,6 +9,7 @@ Traffic to the constrained port is forwarded to a specified server port. |
| """ |
| import logging |
| +import os |
| import re |
| import subprocess |
| @@ -37,6 +38,18 @@ class TrafficControlError(BaseException): |
| self.error = error |
| +def CheckRequirements(): |
| + """Checks if permissions are available to run traffic control commands. |
| + |
| + Raises: |
| + TrafficControlError: If permissions to run traffic control commands are not |
| + available. |
| + """ |
| + if not os.geteuid() == 0: |
|
DaleCurtis
2012/01/10 00:17:59
Use != 0.
shadi
2012/01/10 00:36:39
I thought (from previous CL) 'not' is preferred ov
DaleCurtis
2012/01/10 00:40:01
For objects and boolean statements, but usually no
|
| + _Exec(['sudo', '-n', 'tc'], msg=('Cannot run traffic control commands. ' |
|
DaleCurtis
2012/01/10 00:17:59
Add -help just to be sure.
Where is the iptables
shadi
2012/01/10 00:36:39
My bad. I thought the purpose was to check if sudo
|
| + 'Please check that you have root access.')) |
| + |
| + |
| def CreateConstrainedPort(config): |
| """Creates a new constrained port. |