# Proprietary and confidential. # Copyright $Date:: 2011#$ Perfect Search Corporation. # All rights reserved. # import sys, os buildscriptDir = os.path.dirname(__file__) buildscriptDir = os.path.abspath(os.path.join(buildscriptDir, os.path.pardir)) sys.path.append(buildscriptDir) import re, sandbox, optparse, codecs, optparse import metadata, codescan, xmail from ioutil import * parser = optparse.OptionParser('Usage: %prog [options] [path]\n\nCheck whether code has active console code in javascript files.') xmail.addMailOptions(parser) JAVASCRIPT_PAT = re.compile(r'.*\.js$') CONSOLE_PAT = re.compile(r'console\.[debug|log]') COMMENT_PAT = re.compile(r'[ \t]*//[= \w\.@{}\(\)<>#/\'";:-]*') def _read(path): f = codecs.open(path, 'r', 'utf-8') txt = f.read() f.close() return txt def consoleMatches(matches, txt): m2 = [] for m in matches: offset = m.start()
#!/usr/bin/env python # # $Id: mailout.py 9318 2011-06-10 02:37:10Z nathan_george $ # # Proprietary and confidential. # Copyright $Date:: 2011#$ Perfect Search Corporation. # All rights reserved. # import optparse, sys, os, subprocess, xmail parser = optparse.OptionParser('Usage: %prog --to ADDRLIST --sender ADDR --subject SUB [options] ["commandline"]\n\nRun an arbitrary command and email its stdout/stderr.') parser.add_option('--body', dest="body", help="Body of the email if you are not running a command.") xmail.addMailOptions(parser, sender=True, subject=True) def mailout(args, options): if args: process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) txt = process.stdout.read() process.wait() elif options.body: if os.path.exists(options.body): body = open(options.body, 'r') txt = body.read() body.close() else: txt = '' else: txt = '' xmail.sendmail(txt, options=options)
DISABLED_PAT = re.compile( '/\\*[-_\\.\\* \t\r\n]*%s.*?\\*/' % _DISABLED_DESCRIPTOR_MARKER, re.DOTALL) NON_RECURSING_FOLDERS_PAT = re.compile( r'(.svn|ext(js)?|boost|.metadata|buildtools|Debug|Release|psa-htdocs|sample-data|data|build|Archive|Dist|Install|bin|lib)$' ) FROM = 'Disabled Unit Test Scanner <*****@*****.**>' ## TODO make configurable DISABLED_JAVA_PAT = re.compile('^\s*//\s*@Test', re.MULTILINE | re.DOTALL) parser = optparse.OptionParser( 'Usage: %prog [options] [path]\n\nCheck for disabled unit tests; optionally nag developers to fix them.' ) parser.add_option('--nag', dest="nag", action="store_true", help="Emit emails nagging people to fix disabled tests.") xmail.addMailOptions(parser, to=False) def getUnique(items): uniques = {} for x in items: uniques[x] = 1 return uniques.keys()[:] def getAddressList(txt): items = [] if txt: txt = txt.replace(';', ',') items = [x.strip() for x in txt.split(',') if x.strip()] items = getUnique(items)
import xmail import metadata from ioutil import * from disabled_unit_test import DisabledUnitTest EXT_PAT = re.compile(r'.*\.(cpp|java|h|py)$', re.IGNORECASE) _LBL_PAT = re.compile(r'^\s*([a-z]+):\s*(.*?)\s*$', re.IGNORECASE) _DISABLED_DESCRIPTOR_MARKER = 'UNIT TEST TEMPORARILY DISABLED' DISABLED_PAT = re.compile('/\\*[-_\\.\\* \t\r\n]*%s.*?\\*/' % _DISABLED_DESCRIPTOR_MARKER, re.DOTALL) NON_RECURSING_FOLDERS_PAT = re.compile(r'(.svn|ext(js)?|boost|.metadata|buildtools|Debug|Release|psa-htdocs|sample-data|data|build|Archive|Dist|Install|bin|lib)$') FROM = 'Disabled Unit Test Scanner <*****@*****.**>' ## TODO make configurable DISABLED_JAVA_PAT = re.compile('^\s*//\s*@Test', re.MULTILINE | re.DOTALL) parser = optparse.OptionParser('Usage: %prog [options] [path]\n\nCheck for disabled unit tests; optionally nag developers to fix them.') parser.add_option('--nag', dest="nag", action="store_true", help="Emit emails nagging people to fix disabled tests.") xmail.addMailOptions(parser, to=False) def getUnique(items): uniques = {} for x in items: uniques[x] = 1 return uniques.keys()[:] def getAddressList(txt): items = [] if txt: txt = txt.replace(';', ',') items = [x.strip() for x in txt.split(',') if x.strip()] items = getUnique(items) items.sort() return items