1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +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:
dmiller
2013-10-17 19:20:49 +00:00
parent a7b0fea687
commit 1e6db2b22c
5 changed files with 27 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ winbuild: nmap.rc nsis/Nmap.nsi LICENSE
cp ../nping/Release/nping.exe nmap-$(NMAP_VERSION)
cp ../nmap-update/Release/nmap-update.exe nmap-$(NMAP_VERSION)
# 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
zip -r nmap-$(NMAP_VERSION)-win32.zip nmap-$(NMAP_VERSION)
# Remove ndiff.py and ndiff.bat for the installer because it has ndiff.exe.

View File

@@ -11,7 +11,7 @@ import StringIO
import imp
dont_write_bytecode = sys.dont_write_bytecode
sys.dont_write_bytecode = True
ndiff = imp.load_source("ndiff", "ndiff")
ndiff = imp.load_source("ndiff", "ndiff.py")
for x in dir(ndiff):
if not x.startswith("_"):
globals()[x] = getattr(ndiff, x)
@@ -742,10 +742,10 @@ def host_apply_diff(host, diff):
def call_quiet(args, **kwargs):
"""Run a command with subprocess.call and hide its output."""
return subprocess.call(args, stdout = subprocess.PIPE,
stderr = subprocess.STDOUT, **kwargs)
stderr = subprocess.STDOUT, env = {'PYTHONPATH': "."}, **kwargs)
class exit_code_test(unittest.TestCase):
NDIFF = "./ndiff"
NDIFF = "./scripts/ndiff"
def test_exit_equal(self):
"""Test that the exit code is 0 when the diff is empty."""

21
ndiff/scripts/ndiff Executable file
View 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())

View File

@@ -28,6 +28,7 @@ class checked_install(distutils.command.install.install):
raise distutils.errors.DistutilsPlatformError(str(e) + "\n"
+ "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"])],
cmdclass = {"install_egg_info": null_command, "install": checked_install})