def main(warn, folder, options=None): badFiles = [] exitCode = 0 if not hasPep8(): print("Warning: This machine does not have pep8 installed.") if sys.platform.startswith('linux'): print(" install it using: yum install python-pep8") else: print(" install it using: easy_install pep8") return 0 if not folder: folder = sandbox.current.get_code_root() oldStdout = None sendEmail = xmail.hasDest(options) if sendEmail: oldStdout = sys.stdout sys.stdout = FakeFile() try: badFiles = check(folder, warn) if sendEmail: msg = sys.stdout.txt #print(msg) sys.stdout = oldStdout oldStdout = None xmail.sendmail(msg, sender='Pep8 Scanner <*****@*****.**>', subject='pep8 scan on %s' % metadata.get_friendly_name_for_path(folder), options=options) finally: if oldStdout: sys.stdout = oldStdout return badFiles
def check(path, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking for disabled unit tests in %s...\n' % path) visitor = TestCheckVisitor() checkedFiles, checkedFolders = metadata.visit(path, visitor) rootLen = len(path) if visitor.improperSummary: print(visitor.improperSummary) shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options) for dt in visitor.disabledTests: txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:], dt.lineNum) txt += ' ' + str(dt).replace('\n', '\n ') print(txt + '\n') if visitor.improperSummary: txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount txt += 'Please consider fixing these as well:\n\n' txt += visitor.improperSummary if shouldNag: nag(dt, txt, options) print( 'Checked %d files in %d folders.\n Found %d correctly disabled tests.\n Found %d tests that seem to be disabled but not documented.' % (checkedFiles, checkedFolders, len( visitor.disabledTests), visitor.improperCount))
def main(warn, folder, options=None): badFiles = None exitCode = 0 if not folder: folder = sandbox.current.get_code_root() oldStdout = None sendEmail = xmail.hasDest(options) if sendEmail: oldStdout = sys.stdout sys.stdout = FakeFile() try: badFiles = check(folder, warn) if sendEmail: msg = sys.stdout.txt #print(msg) sys.stdout = oldStdout oldStdout = None xmail.sendmail(msg, sender='Keyword Scanner <*****@*****.**>', subject='svn:keywords scan on %s' % metadata.get_friendly_name_for_path(folder), options=options) finally: if oldStdout: sys.stdout = oldStdout return badFiles
def analyze(path, prebuilt, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) stats = StatsHolder(path) print('\nCompiling stats for %s...' % metadata.get_friendly_name_for_path(path)) visitor = StatsVisitor(stats) recurser = StatsRecurser(stats) visitedFiles, visitedFolders = metadata.visit(path, visitor, recurser, excludePrograms=True)#, debug=True) report = generateReport(stats) print(report) if xmail.hasDest(options): xmail.sendmail(report, subject='code stats for %s' % metadata.get_friendly_name_for_path(path), sender='Code Stat Scanner <*****@*****.**>', options=options)
def analyze(path, prebuilt, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) stats = StatsHolder(path) print('\nCompiling stats for %s...' % metadata.get_friendly_name_for_path(path)) visitor = StatsVisitor(stats) recurser = StatsRecurser(stats) visitedFiles, visitedFolders = metadata.visit( path, visitor, recurser, excludePrograms=True) #, debug=True) report = generateReport(stats) print(report) if xmail.hasDest(options): xmail.sendmail(report, subject='code stats for %s' % metadata.get_friendly_name_for_path(path), sender='Code Stat Scanner <*****@*****.**>', options=options)
def main(warn, folder, options=None): badFiles = None exitCode = 0 if not folder: folder = sandbox.current.get_code_root() oldStdout = None sendEmail = xmail.hasDest(options) if sendEmail: oldStdout = sys.stdout sys.stdout = FakeFile() try: exitCode, badFiles = check(folder, warn) if sendEmail: msg = sys.stdout.txt print(msg) sys.stdout = oldStdout oldStdout = None xmail.sendmail(msg, sender='Javascript Console Scanner <*****@*****.**>', subject='Javascript scan on %s' % metadata.get_friendly_name_for_path(folder), options=options) finally: if oldStdout: sys.stdout = oldStdout return exitCode, badFiles
def check(path, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking for disabled unit tests in %s...\n' % path) visitor = TestCheckVisitor() checkedFiles, checkedFolders = metadata.visit(path, visitor) rootLen = len(path) if visitor.improperSummary: print(visitor.improperSummary) shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options) for dt in visitor.disabledTests: txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:], dt.lineNum) txt += ' ' + str(dt).replace('\n', '\n ') print(txt + '\n') if visitor.improperSummary: txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount txt += 'Please consider fixing these as well:\n\n' txt += visitor.improperSummary if shouldNag: nag(dt, txt, options) print('Checked %d files in %d folders.\n Found %d correctly disabled tests.\n Found %d tests that seem to be disabled but not documented.' % (checkedFiles, checkedFolders, len(visitor.disabledTests), visitor.improperCount))
if __name__ == "__main__": exitCode = 1 (options, args) = parser.parse_args() complainAboutOp = not args if not complainAboutOp: op = args[0] if not op in _OPs: complainAboutOp = True if complainAboutOp: print("Expected operation: " + "|".join(_OPs.keys())) else: op = _OPs[op] folder = options.coderoot folder = ioutil.norm_folder(folder) oldStdout = None sendEmail = xmail.hasDest(options) if sendEmail: oldStdout = sys.stdout sys.stdout = FakeFile() try: # print('%s %s...\n' % (args[0], folder)) exitCode = op(folder) if sendEmail: msg = sys.stdout.txt print(msg) sys.stdout = oldStdout oldStdout = None xmail.sendmail( msg, sender="Localizer <*****@*****.**>", subject="localize %s report on %s" % (op, metadata.get_friendly_name_for_path(folder)),
if __name__ == '__main__': exitCode = 1 (options, args) = parser.parse_args() complainAboutOp = not args if not complainAboutOp: op = args[0] if not op in _OPs: complainAboutOp = True if complainAboutOp: print('Expected operation: ' + '|'.join(_OPs.keys())) else: op = _OPs[op] folder = options.coderoot folder = ioutil.norm_folder(folder) oldStdout = None sendEmail = xmail.hasDest(options) if sendEmail: oldStdout = sys.stdout sys.stdout = FakeFile() try: #print('%s %s...\n' % (args[0], folder)) exitCode = op(folder) if sendEmail: msg = sys.stdout.txt print(msg) sys.stdout = oldStdout oldStdout = None xmail.sendmail( msg, sender='Localizer <*****@*****.**>', subject='localize %s report on %s' %