
from __future__ import absolute_import
from __future__ import with_statement
import sys

try:
    import json
except ImportError:
    import simplejson as json

import six
import thutils

import tcconfig
import tcconfig.traffic_control

from ._common import verify_network_interface


def parse_option():
    parser = thutils.option.ArgumentParserObject()
    parser.make(version=tcconfig.VERSION)

    group = parser.add_argument_group("Traffic Control")
    group.add_argument(
        "--device", action="append", required=True,
        help="network device name (e.g. eth0)")

    return parser.parse_args()


@thutils.main.Main
def main():
    options = parse_option()

    thutils.initialize_library(__file__, options)
    thutils.common.verify_install_command(["tc"])

    subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper()
    tc_param = {}

    for device in options.device:
        verify_network_interface(device)

        tc = tcconfig.traffic_control.TrafficControl(
            subproc_wrapper, device)
        tc_param.update(tc.get_tc_parameter())

    six.print_(json.dumps(tc_param, indent=4))

    return 0


if __name__ == '__main__':
    sys.exit(main())


from __future__ import absolute_import
from __future__ import with_statement
import json
import sys
import six
import thutils

import tcconfig
import tcconfig.traffic_control

from ._common import verify_network_interface


def parse_option():
    parser = thutils.option.ArgumentParserObject()
    parser.make(version=tcconfig.VERSION)

    group = parser.add_argument_group("Traffic Control")
    group.add_argument(
        "--device", action="append", required=True,
        help="network device name (e.g. eth0)")

    return parser.parse_args()


@thutils.main.Main
def main():
    options = parse_option()

    thutils.initialize_library(__file__, options)
    thutils.common.verify_install_command(["tc"])

    subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper()
    tc_param = {}

    for device in options.device:
        verify_network_interface(device)

        tc = tcconfig.traffic_control.TrafficControl(
            subproc_wrapper, device)
        tc_param.update(tc.get_tc_parameter())

    six.print_(json.dumps(tc_param, indent=4))

    return 0


if __name__ == '__main__':
    sys.exit(main())

Drop support for Python 2.6
Drop support for Python 2.6

  
  from __future__ import absolute_import
  from __future__ import with_statement
+ import json
  import sys
- 
- try:
-     import json
- except ImportError:
-     import simplejson as json
- 
  import six
  import thutils
  
  import tcconfig
  import tcconfig.traffic_control
  
  from ._common import verify_network_interface
  
  
  def parse_option():
      parser = thutils.option.ArgumentParserObject()
      parser.make(version=tcconfig.VERSION)
  
      group = parser.add_argument_group("Traffic Control")
      group.add_argument(
          "--device", action="append", required=True,
          help="network device name (e.g. eth0)")
  
      return parser.parse_args()
  
  
  @thutils.main.Main
  def main():
      options = parse_option()
  
      thutils.initialize_library(__file__, options)
      thutils.common.verify_install_command(["tc"])
  
      subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper()
      tc_param = {}
  
      for device in options.device:
          verify_network_interface(device)
  
          tc = tcconfig.traffic_control.TrafficControl(
              subproc_wrapper, device)
          tc_param.update(tc.get_tc_parameter())
  
      six.print_(json.dumps(tc_param, indent=4))
  
      return 0
  
  
  if __name__ == '__main__':
      sys.exit(main())
  
Drop support for Python 2.6
## Code Before:

from __future__ import absolute_import
from __future__ import with_statement
import sys

try:
    import json
except ImportError:
    import simplejson as json

import six
import thutils

import tcconfig
import tcconfig.traffic_control

from ._common import verify_network_interface


def parse_option():
    parser = thutils.option.ArgumentParserObject()
    parser.make(version=tcconfig.VERSION)

    group = parser.add_argument_group("Traffic Control")
    group.add_argument(
        "--device", action="append", required=True,
        help="network device name (e.g. eth0)")

    return parser.parse_args()


@thutils.main.Main
def main():
    options = parse_option()

    thutils.initialize_library(__file__, options)
    thutils.common.verify_install_command(["tc"])

    subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper()
    tc_param = {}

    for device in options.device:
        verify_network_interface(device)

        tc = tcconfig.traffic_control.TrafficControl(
            subproc_wrapper, device)
        tc_param.update(tc.get_tc_parameter())

    six.print_(json.dumps(tc_param, indent=4))

    return 0


if __name__ == '__main__':
    sys.exit(main())

## Instruction:
Drop support for Python 2.6
## Code After:

from __future__ import absolute_import
from __future__ import with_statement
import json
import sys
import six
import thutils

import tcconfig
import tcconfig.traffic_control

from ._common import verify_network_interface


def parse_option():
    parser = thutils.option.ArgumentParserObject()
    parser.make(version=tcconfig.VERSION)

    group = parser.add_argument_group("Traffic Control")
    group.add_argument(
        "--device", action="append", required=True,
        help="network device name (e.g. eth0)")

    return parser.parse_args()


@thutils.main.Main
def main():
    options = parse_option()

    thutils.initialize_library(__file__, options)
    thutils.common.verify_install_command(["tc"])

    subproc_wrapper = thutils.subprocwrapper.SubprocessWrapper()
    tc_param = {}

    for device in options.device:
        verify_network_interface(device)

        tc = tcconfig.traffic_control.TrafficControl(
            subproc_wrapper, device)
        tc_param.update(tc.get_tc_parameter())

    six.print_(json.dumps(tc_param, indent=4))

    return 0


if __name__ == '__main__':
    sys.exit(main())
