mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 21:51:28 +00:00
Make Ndiff install as a Python module as well as script
Discussion: http://seclists.org/nmap-dev/2013/q4/19
This commit is contained in:
@@ -39,7 +39,7 @@ winbuild: nmap.rc nsis/Nmap.nsi LICENSE
|
|||||||
cp ../nping/Release/nping.exe nmap-$(NMAP_VERSION)
|
cp ../nping/Release/nping.exe nmap-$(NMAP_VERSION)
|
||||||
cp ../nmap-update/Release/nmap-update.exe nmap-$(NMAP_VERSION)
|
cp ../nmap-update/Release/nmap-update.exe nmap-$(NMAP_VERSION)
|
||||||
# Install the ndiff batch file wrapper in the zip distribution.
|
# Install the ndiff batch file wrapper in the zip distribution.
|
||||||
cp ../ndiff/ndiff nmap-$(NMAP_VERSION)/ndiff.py
|
cp ../ndiff/ndiff.py nmap-$(NMAP_VERSION)/ndiff.py
|
||||||
cp python-wrap.bat nmap-$(NMAP_VERSION)/ndiff.bat
|
cp python-wrap.bat nmap-$(NMAP_VERSION)/ndiff.bat
|
||||||
zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION)
|
zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION)
|
||||||
# Remove ndiff.py and ndiff.bat for the installer because it has ndiff.exe.
|
# Remove ndiff.py and ndiff.bat for the installer because it has ndiff.exe.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import StringIO
|
|||||||
import imp
|
import imp
|
||||||
dont_write_bytecode = sys.dont_write_bytecode
|
dont_write_bytecode = sys.dont_write_bytecode
|
||||||
sys.dont_write_bytecode = True
|
sys.dont_write_bytecode = True
|
||||||
ndiff = imp.load_source("ndiff", "ndiff")
|
ndiff = imp.load_source("ndiff", "ndiff.py")
|
||||||
for x in dir(ndiff):
|
for x in dir(ndiff):
|
||||||
if not x.startswith("_"):
|
if not x.startswith("_"):
|
||||||
globals()[x] = getattr(ndiff, x)
|
globals()[x] = getattr(ndiff, x)
|
||||||
@@ -742,10 +742,10 @@ def host_apply_diff(host, diff):
|
|||||||
def call_quiet(args, **kwargs):
|
def call_quiet(args, **kwargs):
|
||||||
"""Run a command with subprocess.call and hide its output."""
|
"""Run a command with subprocess.call and hide its output."""
|
||||||
return subprocess.call(args, stdout = subprocess.PIPE,
|
return subprocess.call(args, stdout = subprocess.PIPE,
|
||||||
stderr = subprocess.STDOUT, **kwargs)
|
stderr = subprocess.STDOUT, env = {'PYTHONPATH': "."}, **kwargs)
|
||||||
|
|
||||||
class exit_code_test(unittest.TestCase):
|
class exit_code_test(unittest.TestCase):
|
||||||
NDIFF = "./ndiff"
|
NDIFF = "./scripts/ndiff"
|
||||||
|
|
||||||
def test_exit_equal(self):
|
def test_exit_equal(self):
|
||||||
"""Test that the exit code is 0 when the diff is empty."""
|
"""Test that the exit code is 0 when the diff is empty."""
|
||||||
|
|||||||
21
ndiff/scripts/ndiff
Executable file
21
ndiff/scripts/ndiff
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Ndiff
|
||||||
|
#
|
||||||
|
# This programs reads two Nmap XML files and displays a list of their
|
||||||
|
# differences.
|
||||||
|
#
|
||||||
|
# Copyright 2008 Insecure.Com LLC
|
||||||
|
# Ndiff is distributed under the same license as Nmap. See the file COPYING or
|
||||||
|
# http://nmap.org/data/COPYING. See http://nmap.org/book/man-legal.html for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# David Fifield
|
||||||
|
# based on a design by Michael Pattrick
|
||||||
|
|
||||||
|
import ndiff
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.excepthook = ndiff.excepthook
|
||||||
|
sys.exit(ndiff.main())
|
||||||
@@ -28,6 +28,7 @@ class checked_install(distutils.command.install.install):
|
|||||||
raise distutils.errors.DistutilsPlatformError(str(e) + "\n"
|
raise distutils.errors.DistutilsPlatformError(str(e) + "\n"
|
||||||
+ "Installing your distribution's python-dev package may solve this problem.")
|
+ "Installing your distribution's python-dev package may solve this problem.")
|
||||||
|
|
||||||
distutils.core.setup(name = u"ndiff", scripts = [u"ndiff"],
|
distutils.core.setup(name = u"ndiff", scripts = [u"scripts/ndiff"],
|
||||||
|
py_modules = [u"ndiff"],
|
||||||
data_files = [(u"share/man/man1", [u"docs/ndiff.1"])],
|
data_files = [(u"share/man/man1", [u"docs/ndiff.1"])],
|
||||||
cmdclass = {"install_egg_info": null_command, "install": checked_install})
|
cmdclass = {"install_egg_info": null_command, "install": checked_install})
|
||||||
|
|||||||
Reference in New Issue
Block a user