⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regression.py

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 PY
📖 第 1 页 / 共 3 页
字号:
        if hasattr(self,'proxy') and self.proxy is not None:            proxies = { 'http' : self.proxy }        src = urllib.urlopen( source_url, proxies = proxies )        f = open( destination_file, 'wb' )        while True:            data = src.read( 16*1024 )            if len( data ) == 0: break            f.write( data )        f.close()        src.close()    def import_utils(self):        global utils        if utils is None:            sys.path.append( self.xsl_reports_dir )            import utils as utils_module            utils = utils_module    def build_if_needed( self, tool, toolset ):        self.import_utils()        if os.path.exists( tool[ 'path' ] ):            self.log( 'Found preinstalled "%s"; will use it.' % tool[ 'path' ] )            return        self.log( 'Preinstalled "%s" is not found; building one...' % tool[ 'path' ] )        if toolset is None:            if self.toolsets is not None:                toolset = string.split( self.toolsets, ',' )[0]            else:                toolset = tool[ 'default_toolset' ]                self.log( 'Warning: No bootstrap toolset for "%s" was specified.' % tool[ 'name' ] )                self.log( '         Using default toolset for the platform (%s).' % toolset )        if os.path.exists( tool[ 'source_dir' ] ):            self.log( 'Found "%s" source directory "%s"' % ( tool[ 'name' ], tool[ 'source_dir' ] ) )            build_cmd = tool[ 'build_cmd' ]( toolset, tool['build_args'] )            self.log( 'Building "%s" (%s)...' % ( tool[ 'name'], build_cmd ) )            utils.system( [ 'cd "%s"' % tool[ 'source_dir' ], build_cmd ] )        else:            raise 'Could not find "%s" source directory "%s"' % ( tool[ 'name' ], tool[ 'source_dir' ] )        if not tool.has_key( 'build_path' ):            tool[ 'build_path' ] = self.tool_path( tool )        if not os.path.exists( tool[ 'build_path' ] ):            raise 'Failed to find "%s" after build.' % tool[ 'build_path' ]        self.log( '%s succesfully built in "%s" location' % ( tool[ 'name' ], tool[ 'build_path' ] ) )    def tool_path( self, name_or_spec ):        if isinstance( name_or_spec, basestring ):            return os.path.join( self.regression_root, name_or_spec )        if os.path.exists( name_or_spec[ 'path' ] ):            return name_or_spec[ 'path' ]        if name_or_spec.has_key( 'build_path' ):            return name_or_spec[ 'build_path' ]        build_dir = name_or_spec[ 'build_dir' ]        self.log( 'Searching for "%s" in "%s"...' % ( name_or_spec[ 'name' ], build_dir ) )        for root, dirs, files in os.walk( build_dir ):            if name_or_spec[ 'name' ] in files:                return os.path.join( root, name_or_spec[ 'name' ] )        raise Exception( 'Cannot find "%s" in any of the following locations:\n%s' % (              name_or_spec[ 'name' ]            , '\n'.join( [ name_or_spec[ 'path' ], build_dir ] )            ) )        def bjam_build_cmd( self, *rest ):        if sys.platform == 'win32':            cmd = 'build.bat %s' % self.bjam_toolset        else:            cmd = './build.sh %s' % self.bjam_toolset        env_setup_key = 'BJAM_ENVIRONMENT_SETUP'        if os.environ.has_key( env_setup_key ):            return '%s & %s' % ( os.environ[env_setup_key], cmd )        return cmd        def bjam_cmd( self, toolsets, args = '', *rest ):        build_path = self.regression_root        if build_path[-1] == '\\': build_path += '\\'                if self.timeout > 0:            args += ' -l%s' % (self.timeout*60)        cmd = '"%(bjam)s"' +\            ' "-sBOOST_BUILD_PATH=%(bbpath)s"' +\            ' "-sBOOST_ROOT=%(boost)s"' +\            ' "--boost=%(boost)s"' +\            ' "--boost-build=%(bb)s"' +\            ' "--debug-configuration"' +\            ' %(arg)s'        cmd %= {            'bjam' : self.tool_path( self.bjam ),            'bbpath' : os.pathsep.join([build_path,self.tools_bb_root]),            'bb' : self.tools_bb_root,            'boost' : self.boost_root,            'arg' : args }        if toolsets:            import string            cmd += ' ' + string.join(string.split( toolsets, ',' ), ' ' )        return cmd    def send_mail( self, subject, msg = '' ):        import smtplib        if not self.smtp_login:            server_name = 'mail.%s' % mail.split( '@' )[-1]            user_name = None            password = None        else:            server_name = self.smtp_login.split( '@' )[-1]            ( user_name, password ) = string.split( self.smtp_login.split( '@' )[0], ':' )        log( '    Sending mail through "%s"...' % server_name )        smtp_server = smtplib.SMTP( server_name )        smtp_server.set_debuglevel( self.debug_level )        if user_name:            smtp_server.login( user_name, password )        smtp_server.sendmail( self.mail, [ self.mail ],            'Subject: %s\nTo: %s\n\n%s' % ( subject, self.mail, msg ) )    #~ Dowloading source, from SVN...    def svn_checkout( self ):        os.chdir( self.regression_root )        self.svn_command( 'co %s %s' % (self.svn_repository_url(self.tag),'boost') )    def svn_update( self ):        os.chdir( self.boost_root )        self.svn_command( 'update' )    def svn_command( self, command ):        svn_anonymous_command_line  = 'svn --non-interactive %(command)s'        svn_command_line            = 'svn --non-interactive --username=%(user)s %(command)s'                if not hasattr(self,'user') or self.user is None or self.user == 'anonymous':            cmd = svn_anonymous_command_line % { 'command': command }        else:            cmd = svn_command_line % { 'user': self.user, 'command': command }        self.log( 'Executing SVN command "%s"' % cmd )        rc = os.system( cmd )        if rc != 0:            raise Exception( 'SVN command "%s" failed with code %d' % ( cmd, rc ) )    def svn_repository_url( self, path ):        if hasattr(self,'user') and self.user is not None and self.user != 'anonymous':            return '%s%s' % (repo_root['user'],path)        else:            return '%s%s' % (repo_root['anon'],path)        #~ Downloading and extracting source archives, from tarballs or zipballs...        def get_tarball( self, *args ):        if not args or args == []:            args = [ 'download', 'unpack' ]        tarball_path = None        if hasattr(self,'local') and self.local is not None:            tarball_path = self.local        elif 'download' in args:            tarball_path = self.download_tarball(self.boost_tarball_name(),self.boost_tarball_url())        if not tarball_path:            tarball_path = os.path.join( self.regression_root, self.boost_tarball_url() )        if 'unpack' in args:            self.unpack_tarball( tarball_path, self.boost_root )        pass    def download_tarball( self, tarball_name, tarball_url ):        tarball_path = os.path.join( self.regression_root, tarball_name )        self.log( 'Downloading "%s" to "%s"...'  % ( tarball_url, os.path.dirname( tarball_path ) ) )        if os.path.exists( tarball_path ):            os.unlink( tarball_path )        self.http_get( tarball_url, tarball_path )        return tarball_path        def tarball_url( self, path ):        return 'http://beta.boost.org/development/snapshot.php/%s' % path    def boost_tarball_name( self ):        return 'boost-%s.tar.bz2' % self.tag.split( '/' )[-1]    def boost_tarball_url( self ):        return self.tarball_url( self.tag )    def unpack_tarball( self, tarball_path, target_path ):        self.log( 'Looking for old unpacked archives...' )        old_boost_dirs = self.find_boost_dirs( )        for old_boost_dir in old_boost_dirs:            if old_boost_dir != tarball_path:                self.log( 'Deleting old directory %s.' % old_boost_dir )                self.rmtree( old_boost_dir )        self.log( 'Unpacking boost tarball ("%s")...' % tarball_path )        tarball_name = os.path.basename( tarball_path )        extension = tarball_name[ tarball_name.find( '.' ) : ]        if extension in ( ".tar.gz", ".tar.bz2" ):            import tarfile            import stat                        mode = os.path.splitext( extension )[1][1:]            tar = tarfile.open( tarball_path, 'r:%s' % mode )            for tarinfo in tar:                tar.extract( tarinfo, self.regression_root )                if sys.platform == 'win32' and not tarinfo.isdir():                    # workaround what appears to be a Win32-specific bug in 'tarfile'                    # (modification times for extracted files are not set properly)                    f = os.path.join( self.regression_root, tarinfo.name )                    os.chmod( f, stat.S_IWRITE )                    os.utime( f, ( tarinfo.mtime, tarinfo.mtime ) )            tar.close()        elif extension in ( ".zip" ):            import zipfile            z = zipfile.ZipFile( tarball_path, 'r', zipfile.ZIP_DEFLATED )            for f in z.infolist():                destination_file_path = os.path.join( self.regression_root, f.filename )                if destination_file_path[-1] == "/": # directory                    if not os.path.exists( destination_file_path  ):                        os.makedirs( destination_file_path  )                else: # file                    result = open( destination_file_path, 'wb' )                    result.write( z.read( f.filename ) )                    result.close()            z.close()        else:            raise 'Do not know how to unpack archives with extension \"%s\"' % extension        boost_dir = self.find_boost_dirs()[0]        self.log( '    Unpacked into directory "%s"' % boost_dir )        if os.path.exists( target_path ):            self.log( 'Deleting "%s" directory...' % target_path )            self.rmtree( target_path )        self.log( 'Renaming "%s" into "%s"' % ( boost_dir, target_path ) )        os.rename( boost_dir, target_path )    def find_boost_dirs( self ):        return [            x for x in                glob.glob( os.path.join( self.regression_root, 'boost[-_]*' ) )                if os.path.isdir( x )            ]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -