# Path: sts/util/console.py
# class msg():
#   global_io_master = None
# 
#   BEGIN = '\033[1;'
#   END = '\033[1;m'
# 
#   GRAY, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, CRIMSON = map(lambda num: str(num) + "m", range(30, 39))
#   B_BLACK, B_RED, B_GREEN, B_YELLOW, B_BLUE, B_MAGENTA, B_CYAN, B_GRAY, B_CRIMSON =  map(lambda num: str(num) + "m", range(40, 49))
# 
#   @staticmethod
#   def interactive(message):
#     # todo: would be nice to simply give logger a color arg, but that doesn't exist...
#     print msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def event(message):
#     print msg.BEGIN + msg.CYAN + message + msg.END
# 
#   @staticmethod
#   def openflow_event(message):
#     print msg.BEGIN + msg.BLUE + message + msg.END
# 
#   @staticmethod
#   def special_event(message):
#     print msg.BEGIN + msg.MAGENTA + message + msg.END
# 
#   @staticmethod
#   def replay_event_success(message):
#     print msg.BEGIN + msg.CYAN + msg.BEGIN + msg.B_BLUE + message + msg.END
# 
#   @staticmethod
#   def replay_event_timeout(message):
#     print msg.BEGIN + msg.MAGENTA + msg.BEGIN + msg.B_RED + message + msg.END
# 
#   @staticmethod
#   def mcs_event(message):
#     print msg.BEGIN + msg.B_MAGENTA + message + msg.END
# 
#   @staticmethod
#   def raw_input(message):
#     prompt = msg.BEGIN + msg.WHITE + message + msg.END
#     if msg.global_io_master:
#       s = msg.global_io_master.raw_input(prompt)
#     else:
#       s = raw_input(prompt)
# 
#     if s == "debug":
#       import pdb
#       pdb.set_trace()
#     return s
# 
#   @staticmethod
#   def success(message):
#     print msg.BEGIN + msg.B_GREEN + msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def fail(message):
#     print msg.BEGIN + msg.B_RED + msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def set_io_master(io_master):
#     msg.global_io_master = io_master
# 
#   @staticmethod
#   def unset_io_master():
#     msg.global_io_master = None


from pox.openflow.software_switch import OFConnection
from pox.openflow.libopenflow_01 import ofp_flow_mod
from pox.lib.addresses import EthAddr, IPAddr
from sts.util.console import msg
import time
import re
import os
import sys
import errno
import socket
import random
import types
import struct
import shutil
import base64
import subprocess
import warnings
import functools
import importlib
# Copyright 2011-2013 Colin Scott
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# don't use the standard instance - we don't want to be seeded
true_random = random.Random()

def is_sorted(l):
  return all(l[i] <= l[i+1] for i in xrange(len(l)-1))


# Path: sts/util/console.py
# class msg():
#   global_io_master = None
# 
#   BEGIN = '\033[1;'
#   END = '\033[1;m'
# 
#   GRAY, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, CRIMSON = map(lambda num: str(num) + "m", range(30, 39))
#   B_BLACK, B_RED, B_GREEN, B_YELLOW, B_BLUE, B_MAGENTA, B_CYAN, B_GRAY, B_CRIMSON =  map(lambda num: str(num) + "m", range(40, 49))
# 
#   @staticmethod
#   def interactive(message):
#     # todo: would be nice to simply give logger a color arg, but that doesn't exist...
#     print msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def event(message):
#     print msg.BEGIN + msg.CYAN + message + msg.END
# 
#   @staticmethod
#   def openflow_event(message):
#     print msg.BEGIN + msg.BLUE + message + msg.END
# 
#   @staticmethod
#   def special_event(message):
#     print msg.BEGIN + msg.MAGENTA + message + msg.END
# 
#   @staticmethod
#   def replay_event_success(message):
#     print msg.BEGIN + msg.CYAN + msg.BEGIN + msg.B_BLUE + message + msg.END
# 
#   @staticmethod
#   def replay_event_timeout(message):
#     print msg.BEGIN + msg.MAGENTA + msg.BEGIN + msg.B_RED + message + msg.END
# 
#   @staticmethod
#   def mcs_event(message):
#     print msg.BEGIN + msg.B_MAGENTA + message + msg.END
# 
#   @staticmethod
#   def raw_input(message):
#     prompt = msg.BEGIN + msg.WHITE + message + msg.END
#     if msg.global_io_master:
#       s = msg.global_io_master.raw_input(prompt)
#     else:
#       s = raw_input(prompt)
# 
#     if s == "debug":
#       import pdb
#       pdb.set_trace()
#     return s
# 
#   @staticmethod
#   def success(message):
#     print msg.BEGIN + msg.B_GREEN + msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def fail(message):
#     print msg.BEGIN + msg.B_RED + msg.BEGIN + msg.WHITE + message + msg.END
# 
#   @staticmethod
#   def set_io_master(io_master):
#     msg.global_io_master = io_master
# 
#   @staticmethod
#   def unset_io_master():
#     msg.global_io_master = None


# Path: sts/util/convenience.py
from pox.openflow.software_switch import OFConnection
from pox.openflow.libopenflow_01 import ofp_flow_mod
from pox.lib.addresses import EthAddr, IPAddr
from sts.util.console import msg
import time
import re
import os
import sys
import errno
import socket
import random
import types
import struct
import shutil
import base64
import subprocess
import warnings
import functools
import importlib

# Copyright 2011-2013 Colin Scott
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# don't use the standard instance - we don't want to be seeded
true_random = random.Random()

def is_sorted(l):
  return all(l[i] <= l[i+1] for i in xrange(len(l)-1))


def is_strictly_sorted(l):