Changeset 176

Show
Ignore:
Timestamp:
02/07/07 05:07:24 (6 years ago)
Author:
mk
Message:

Raised pylint default time limit to 120 seconds.
Implemented --pylint-max-execution-time option.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cheesecake/cheesecake_index.py

    r173 r176  
    10541054    pylint_args = ' '.join(map(lambda x: '--disable-msg=%s' % x, disabled_messages)) 
    10551055 
    1056     max_execution_time = 60 
    1057  
    1058     def compute(self, files_list, package_dir): 
     1056    def compute(self, files_list, package_dir, pylint_max_execution_time): 
    10591057        # See if pylint script location is set via environment variable 
    10601058        pylint_location = os.environ.get("PYLINT", "pylint") 
     
    10891087            # Run pylint, but don't allow it to work longer than one minute. 
    10901088            rc, output = run_cmd("%s %s --persistent=n %s" % (pylint_location, filenames, self.pylint_args), 
    1091                                  max_timeout=self.max_execution_time) 
     1089                                 max_timeout=pylint_max_execution_time) 
    10921090            if rc: 
    10931091                if output == 'Time exceeded': 
     
    10951093                    #   and thus won't affect the score. 
    10961094                    self.cheesecake.log.debug("pylint exceeded maximum execution time of %d seconds and was terminated." % \ 
    1097                                               self.max_execution_time) 
     1095                                              pylint_max_execution_time) 
    10981096                    raise OSError 
    10991097                self.cheesecake.log.debug("encountered an error (%d):\n***\n%s\n***\n" % (rc, output)) 
     
    12941292    } 
    12951293 
    1296     def __init__(self, name="", url="", path="", sandbox=None, 
    1297                  logfile=None, verbose=False, quiet=False, static_only=False, 
    1298                  lite=False, keep_log=False, with_pep8=False): 
     1294    def __init__(self, 
     1295                 keep_log                  = False, 
     1296                 lite                      = False, 
     1297                 logfile                   = None, 
     1298                 name                      = "", 
     1299                 path                      = "", 
     1300                 pylint_max_execution_time = None, 
     1301                 quiet                     = False, 
     1302                 sandbox                   = None, 
     1303                 static_only               = False, 
     1304                 url                       = "", 
     1305                 verbose                   = False, 
     1306                 with_pep8                 = False): 
    12991307        """Initialize critical variables, download and unpack package, 
    13001308        walk package tree. 
     
    13241332        self.keep_log = keep_log 
    13251333        self.with_pep8 = with_pep8 
     1334        self.pylint_max_execution_time = pylint_max_execution_time 
    13261335 
    13271336        self.sandbox_pkg_file = "" 
     
    18201829    parser.add_option("--keep-log", action="store_true", dest="keep_log", 
    18211830                      default=False, help="don't remove log file even if run was successful") 
     1831    parser.add_option("--pylint-max-execution-time", action="store", dest="pylint_max_execution_time", 
     1832                      default=120, help="maximum time (in seconds) you allow pylint process to run (default=120)") 
    18221833 
    18231834    parser.add_option("-V", "--version", action="store_true", dest="version", 
     
    18431854    version = options.version 
    18441855    with_pep8 = options.with_pep8 
     1856    pylint_max_execution_time = int(options.pylint_max_execution_time) 
    18451857 
    18461858    if version: 
     
    18531865 
    18541866    try: 
    1855         c = Cheesecake(name=name, url=url, path=path, sandbox=sandbox, 
    1856                        logfile=logfile, verbose=verbose, 
    1857                        quiet=quiet, static_only=static_only, lite=lite, 
    1858                        keep_log=keep_log, with_pep8=with_pep8) 
     1867        c = Cheesecake(keep_log                  = keep_log, 
     1868                       lite                      = lite, 
     1869                       logfile                   = logfile, 
     1870                       name                      = name, 
     1871                       path                      = path, 
     1872                       pylint_max_execution_time = pylint_max_execution_time, 
     1873                       quiet                     = quiet, 
     1874                       sandbox                   = sandbox, 
     1875                       static_only               = static_only, 
     1876                       url                       = url, 
     1877                       verbose                   = verbose, 
     1878                       with_pep8                 = with_pep8) 
    18591879        c.compute_cheesecake_index() 
    18601880        c.cleanup()