bindings: (fixes #796) Gracefully exit when bindings are unavailable
This commit is contained in:
@@ -23,7 +23,14 @@
|
||||
# - DropTail queues
|
||||
# - Tracing of queues and packet receptions to file "udp-echo.tr"
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
def main(argv):
|
||||
#
|
||||
|
||||
@@ -27,7 +27,14 @@
|
||||
# router
|
||||
#
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# */
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
# // Default Network Topology
|
||||
# //
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
# * Ported to Python by Mohit P. Tahiliani
|
||||
# */
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
import sys
|
||||
|
||||
# // Default Network Topology
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
# * Ported to Python by Mohit P. Tahiliani
|
||||
# */
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
import sys
|
||||
|
||||
# // Default Network Topology
|
||||
|
||||
@@ -51,7 +51,14 @@
|
||||
# +----------------+ +----------------+
|
||||
#
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
# #
|
||||
# # This function will be used below as a trace sink
|
||||
|
||||
@@ -22,7 +22,14 @@
|
||||
|
||||
import sys
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
# void
|
||||
# DevTxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# /*
|
||||
# * This program is free software; you can redistribute it and/or modify
|
||||
# * it under the terms of the GNU General Public License version 2 as
|
||||
# * published by the Free Software Foundation
|
||||
# *
|
||||
# * This program is distributed in the hope that it will be useful,
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# * GNU General Public License for more details.
|
||||
# *
|
||||
# * You should have received a copy of the GNU General Public License
|
||||
# * along with this program; if not, write to the Free Software
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# */
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# Network topology
|
||||
#
|
||||
@@ -32,8 +32,15 @@
|
||||
# \ingroup bridge
|
||||
# Bridge example connecting two broadcast domains.
|
||||
|
||||
|
||||
from ns import ns
|
||||
## Import ns-3
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
# Modified by: Gabriel Ferreira <gabrielcarvfer@gmail.com>
|
||||
#
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
ns.LogComponentEnable("BriteTopologyHelper", ns.LOG_LEVEL_ALL)
|
||||
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
|
||||
import os.path
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
ns.LogComponentEnable("Ipv4ClickRouting", ns.LOG_LEVEL_ALL)
|
||||
ns.LogComponentEnable("Ipv4L3ClickProtocol", ns.LOG_LEVEL_ALL)
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# -*- Mode:Python; -*-
|
||||
# /*
|
||||
# * This program is free software; you can redistribute it and/or modify
|
||||
# * it under the terms of the GNU General Public License version 2 as
|
||||
# * published by the Free Software Foundation
|
||||
# *
|
||||
# * This program is distributed in the hope that it will be useful,
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# * GNU General Public License for more details.
|
||||
# *
|
||||
# * You should have received a copy of the GNU General Public License
|
||||
# * along with this program; if not, write to the Free Software
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# */
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
## @file
|
||||
# @ingroup core-examples
|
||||
@@ -27,7 +26,15 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import sys
|
||||
import argparse
|
||||
from ns import ns
|
||||
## Import ns-3
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
# -*- Mode:Python; -*-
|
||||
# /*
|
||||
# * Copyright (c) 2010 INRIA
|
||||
# *
|
||||
# * This program is free software; you can redistribute it and/or modify
|
||||
# * it under the terms of the GNU General Public License version 2 as
|
||||
# * published by the Free Software Foundation;
|
||||
# *
|
||||
# * This program is distributed in the hope that it will be useful,
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# * GNU General Public License for more details.
|
||||
# *
|
||||
# * You should have received a copy of the GNU General Public License
|
||||
# * along with this program; if not, write to the Free Software
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# *
|
||||
# * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
# */
|
||||
#
|
||||
# Copyright (c) 2010 INRIA
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation;
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
#
|
||||
#
|
||||
# Python version of sample-simulator.cc
|
||||
|
||||
@@ -25,8 +24,15 @@
|
||||
# \ingroup simulator
|
||||
# Python example program demonstrating use of various Schedule functions.
|
||||
|
||||
|
||||
from ns import ns
|
||||
## Import ns-3
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
## Example function - triggered at a random time.
|
||||
## \return None.
|
||||
|
||||
@@ -20,7 +20,14 @@
|
||||
# Demonstrates the discharge behavior of a NIMH battery discharged with a
|
||||
# constant current of 6.5 A (1C)
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
def main(argv):
|
||||
"""The main function in this Battery discharge example
|
||||
|
||||
@@ -19,7 +19,14 @@
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
DISTANCE = 20 # (m)
|
||||
NUM_NODES_SIDE = 3
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
# Gabriel Ferreira <gabrielcarvfer@gmail.com>
|
||||
#
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
ns.LogComponentEnable("OpenFlowInterface", ns.LOG_LEVEL_ALL)
|
||||
ns.LogComponentEnable("OpenFlowSwitchNetDevice", ns.LOG_LEVEL_ALL)
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
|
||||
import sys
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
def main(argv):
|
||||
|
||||
|
||||
@@ -17,7 +17,14 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
def main(argv):
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
|
||||
try:
|
||||
from ns3.visualizer.base import InformationWindow
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import math
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
from gi.repository import GooCanvas
|
||||
|
||||
try:
|
||||
|
||||
@@ -19,7 +19,14 @@
|
||||
# Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
|
||||
|
||||
import unittest
|
||||
from ns import ns
|
||||
try:
|
||||
from ns import ns
|
||||
except ModuleNotFoundError:
|
||||
raise SystemExit(
|
||||
"Error: ns3 Python module not found;"
|
||||
" Python bindings may not be enabled"
|
||||
" or your PYTHONPATH might not be properly configured"
|
||||
)
|
||||
import sys
|
||||
|
||||
UINT32_MAX = 0xFFFFFFFF
|
||||
|
||||
Reference in New Issue
Block a user