Skip to content

Commit 9197286

Browse files
committed
Added support for python 2 and 3
1 parent 25eced8 commit 9197286

8 files changed

Lines changed: 29 additions & 22 deletions

File tree

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ services: mongodb
1717
install:
1818
- "pip install pep8 --use-mirrors"
1919
- "pip install pyflakes --use-mirrors"
20-
- "pip install boto --use-mirrors"
20+
# - "pip install boto --use-mirrors" # disabled: since boto not supporting py3
2121
- "pip install pymongo sqlalchemy MySQL-python --use-mirrors"
22-
- "pip install coveralls"
22+
- "pip install coveralls"
2323
- "python setup.py install"
24-
# - "pip install -r requirements.txt --use-mirrors"
25-
# # command to run tests
2624
before_script:
2725
- "pep8 . --exclude test,docs,examples"
2826
- "pyflakes ."

README.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The lib currently offers the following modules:
3535

3636
- mongodb: insert/get/getAll/delete
3737
- sqlalchemy: insert/get/getAll/delete
38-
- aws s3: insert/get/getAll/delete
38+
- aws s3: insert/get/getAll/delete (not supported for python3 since boto is not supporting py3)
3939
- csv: todo (easy to implement)
4040
- elastic search: todo
4141

@@ -57,6 +57,16 @@ Below the list of optional dependencies:
5757
- `pymongo`_
5858
- `boto`_
5959

60+
Python Support
61+
--------------
62+
63+
The libnmap code is tested against the following python interpreters:
64+
65+
- Python 2.6
66+
- Python 2.7
67+
- Python 3.3
68+
- Python 3.4
69+
6070
Install
6171
-------
6272

libnmap/test/process-stressbox/check_fqp_nmap.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def do_scan(targets, options, fqp=None):
1111
if rc != 0:
1212
print("nmap scan failed: {0}".format(nm.stderr))
1313

14-
print(nm.stdout)
1514
try:
1615
parsed = NmapParser.parse(nm.stdout)
1716
except NmapParserException as e:
@@ -51,16 +50,16 @@ def print_scan(nmap_report):
5150

5251

5352
if __name__ == "__main__":
54-
report = do_scan("127.0.0.1", "-sV")
55-
print(report)
53+
report = do_scan("127.0.0.1", "-sT")
5654
print_scan(report)
5755
# test with full path to bin
5856
# /usr/bin/nmap
59-
report = do_scan("127.0.0.1", "-sV", fqp="/usr/bin/nmap")
57+
report = do_scan("127.0.0.1", "-sT", fqp="/usr/bin/nmap")
6058
print_scan(report)
6159
# /usr/bin/lol --> will throw exception
6260
try:
6361
report = do_scan("127.0.0.1", "-sV", fqp="/usr/bin/lol")
62+
print("lolbin")
6463
print_scan(report)
6564
except Exception as exc:
6665
print(exc)

libnmap/test/process-stressbox/multi_nmap_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def start_all(nmprocs):
1212

1313
def summarize(nmprocs):
1414
for nmp in nmprocs:
15-
print "rc: {0} output: {1}".format(nmp.rc, len(nmp.stdout))
15+
print("rc: {0} output: {1}".format(nmp.rc, len(nmp.stdout)))
1616

1717
nm_targets = []
1818
for h in range(20): nm_targets.append("localhost")

libnmap/test/process-stressbox/multi_nmap_process_background.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def any_running(nmprocs):
1414

1515
def summarize(nmprocs):
1616
for nmp in nmprocs:
17-
print "rc: {0} output: {1} stdout len: {2}".format(nmp.rc, nmp.summary, len(nmp.stdout))
17+
print("rc: {0} output: {1} stdout len: {2}".format(nmp.rc, nmp.summary, len(nmp.stdout)))
1818

1919
nm_targets = []
2020
for h in range(10):
@@ -25,7 +25,7 @@ def summarize(nmprocs):
2525
start_all_bg(nm_procs)
2626

2727
while any_running(nm_procs):
28-
print "Nmap Scan running..."
28+
print("Nmap Scan running...")
2929
sleep(2)
3030

3131
summarize(nm_procs)

libnmap/test/process-stressbox/proc_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
while nmap_proc.is_running():
1010
nmaptask = nmap_proc.current_task
1111
if nmaptask:
12-
print "Task {0} ({1}): ETC: {2} DONE: {3}%".format(nmaptask.name,
12+
print("Task {0} ({1}): ETC: {2} DONE: {3}%".format(nmaptask.name,
1313
nmaptask.status,
1414
nmaptask.etc,
15-
nmaptask.progress)
15+
nmaptask.progress))
1616
sleep(0.5)
1717

18-
print "rc: {0} output: {1}".format(nmap_proc.rc, nmap_proc.summary)
19-
print nmap_proc.stdout
18+
print("rc: {0} output: {1}".format(nmap_proc.rc, nmap_proc.summary))
19+
print(nmap_proc.stdout)

libnmap/test/process-stressbox/stop_scan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
while nmap_proc.is_running():
1010
nmaptask = nmap_proc.current_task
1111
if nmaptask:
12-
print "Task {0} ({1}): ETC: {2} DONE: {3}%".format(nmaptask.name,
12+
print("Task {0} ({1}): ETC: {2} DONE: {3}%".format(nmaptask.name,
1313
nmaptask.status,
1414
nmaptask.etc,
15-
nmaptask.progress)
15+
nmaptask.progress))
1616
sleep(3)
1717
nmap_proc.stop()
1818

19-
print "rc: {0} output: {1}".format(nmap_proc.rc, nmap_proc.summary)
20-
print nmap_proc.stdout
21-
print nmap_proc.stderr
19+
print("rc: {0} output: {1}".format(nmap_proc.rc, nmap_proc.summary))
20+
print(nmap_proc.stdout)
21+
print(nmap_proc.stderr)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='python-libnmap',
9-
version='0.5.2',
9+
version='0.6',
1010
author='Ronald Bister',
1111
author_email='mini.pelle@gmail.com',
1212
packages=['libnmap', 'libnmap.plugins', 'libnmap.objects'],

0 commit comments

Comments
 (0)