[hntool] 2 new revisions pushed by linux.r...@gmail.com on 2011-01-19 17:43 GMT

3 views
Skip to first unread message

hnt...@googlecode.com

unread,
Jan 19, 2011, 12:43:50 PM1/19/11
to hnt...@googlegroups.com
2 new revisions:

Revision: 87b270915c
Author: Rafael Gomes <rafae...@techfree.com.br>
Date: Tue Jan 18 23:21:33 2011
Log: Added test module and create a hyperlink to more information in
every ...
http://code.google.com/p/hntool/source/detail?r=87b270915c

Revision: da284cf4e1
Author: Rafael Gomes <rafae...@techfree.com.br>
Date: Wed Jan 19 09:41:23 2011
Log: Problem of output terminal fixed
http://code.google.com/p/hntool/source/detail?r=da284cf4e1

==============================================================================
Revision: 87b270915c
Author: Rafael Gomes <rafae...@techfree.com.br>
Date: Tue Jan 18 23:21:33 2011
Log: Added test module and create a hyperlink to more information in every
error message. (Html output version)
http://code.google.com/p/hntool/source/detail?r=87b270915c

Added:
/teste/output_html.test.py
Modified:
/HnTool/modules/ports.py
/HnTool/output/html.py

=======================================
--- /dev/null
+++ /teste/output_html.test.py Tue Jan 18 23:21:33 2011
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest, os, tempfile, sys
+sys.path.append('..')
+from HnTool.core import HnToolCore
+
+class OutputHtmlTest(unittest.TestCase):
+
+ def setUp(self):
+ self.hn = HnToolCore()
+ self.hn.load_output_modules()
+ self.out = self.hn.output_modules['html']
+
+ def tearDown(self):
+ pass
+
+ def test_wikify(self):
+ self.assertEqual( 'MeuTitulo', self.out.wikify('meu
titulo'), 'Simple test' )
+ self.assertEqual( u'ÁrvoreDeMaçã', self.out.wikify(u'árvore de
maçã'), 'Latin test' )
+ self.assertEqual( 'TestTest', self.out.wikify(' test
test '), 'Start and end blank space test' )
+ self.assertEqual( 'TestTest',
self.out.wikify('_test_test_'), 'Underline test' )
+ self.assertEqual( 'TestTest', self.out.wikify('-test-test-'), 'Hyphen
test' )
+
+ def test_msg_status(self):
+ self.assertEqual( '<tr>' + \
+ self.out.format_status( 'ok' ) + \
+ '<td><a
href="http://code.google.com/p/hntool/wiki/Help_TestMessage">test
message</a></td>' + \
+ '</tr>', self.out.msg_status('test message', 'ok'), 'Basic
message' )
+
+if __name__ == '__main__':
+ unittest.main()
=======================================
--- /HnTool/modules/ports.py Sun Aug 22 07:48:58 2010
+++ /HnTool/modules/ports.py Tue Jan 18 23:21:33 2011
@@ -51,8 +51,11 @@
else:
tmp_msg = 'ports "' + '"
and "'.join(services[service]) \
+ '"'
- check_results['info'].append('Service "' + service + '"
using ' \
- + tmp_msg + ' found')
+ info = {
+ 'message':'Service "%s" using %s found' %
(service,tmp_msg),
+ 'wiki_help_page':'ServiceFoundOnPort'
+ }
+ check_results['info'].append(info)
else:
check_results['ok'].append("Could not find any open door")

=======================================
--- /HnTool/output/html.py Fri May 28 05:08:41 2010
+++ /HnTool/output/html.py Tue Jan 18 23:21:33 2011
@@ -22,6 +22,7 @@

import HnTool.modules
import string
+import re

class Format:

@@ -47,11 +48,24 @@
'''
Method to show the check results
'''
+ if type(msg) == dict:
+ m = msg['message']
+ else:
+ m = msg
+ url = 'http://code.google.com/p/hntool/wiki/Help_' +
self.wikify(msg)
return '<tr>' + \
self.format_status( status ) + \
- '<td>' + msg + '</td>' + \
+ '<td><a href="%s">%s</a></td>' % (url,m) + \
'</tr>'

+ def wikify(self, phrase):
+ if type(phrase) == dict:
+ return phrase['wiki_help_page']
+ phrase_re = re.compile(ur'[\W_]+', re.UNICODE)
+ phrase = phrase_re.split(phrase)
+ return u''.join([w.capitalize() for w in phrase])
+
+
def output( self, report, conf ):
self.conf = conf
# Print all the results, from the 5 types of messages ( ok, low,
medium, high and info ).
@@ -162,26 +176,11 @@
statistics = {'ok': 0, 'high': 0, 'medium': 0, 'low': 0, 'info': 0}
for m in report:
print '<tr><th colspan="2" align="left"><h2>' + m['title']
+ '</h2></th></tr>'
- if m['results']['ok'] != []:
- for result in m['results']['ok']:
- print self.msg_status( result, 'ok' )
- statistics['ok'] += 1
- if m['results']['low'] != []:
- for result in m['results']['low']:
- print self.msg_status( result, 'low' )
- statistics['low'] += 1
- if m['results']['medium'] != []:
- for result in m['results']['medium']:
- print self.msg_status( result, 'medium' )
- statistics['medium'] += 1
- if m['results']['high'] != []:
- for result in m['results']['high']:
- print self.msg_status( result, 'high' )
- statistics['high'] += 1
- if m['results']['info'] != []:
- for result in m['results']['info']:
- print self.msg_status( result, 'info' )
- statistics['info'] += 1
+ for k in statistics.keys():
+ if m['results'][k] != []:
+ for result in m['results'][k]:
+ print self.msg_status( result, k )
+ statistics[k] += 1

print '''
</table>

==============================================================================
Revision: da284cf4e1
Author: Rafael Gomes <rafae...@techfree.com.br>
Date: Wed Jan 19 09:41:23 2011
Log: Problem of output terminal fixed
http://code.google.com/p/hntool/source/detail?r=da284cf4e1

Modified:
/HnTool/output/terminal.py

=======================================
--- /HnTool/output/terminal.py Mon Aug 30 10:28:56 2010
+++ /HnTool/output/terminal.py Wed Jan 19 09:41:23 2011
@@ -56,6 +56,9 @@
'''
Method to show the check results
'''
+ if type(msg) == dict:
+ msg = msg['message']
+
maxmsg_len = HnTool.modules.util.term_len() - 15
msg_splited = HnTool.modules.util.split_len( msg, maxmsg_len )
result = ""
Reply all
Reply to author
Forward
0 new messages