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

📄 buildapp.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 4 页
字号:
        ## of the directory now and when we're done unpacking        ## distributions, take the difference and return it        ## as a list        old_listdir = os.listdir(os.curdir)        local_path = module.name        url = "http://horton/archive/%s/%s" % (            sysinfo.distribution_id, module.name)        outmsg.send(url)        ## remove any current archive with the same name        if os.path.exists(local_path):            shell.rm(local_path)        ## download archive        try:            import urllib            urllib.urlretrieve(url, module.name)        except IOError, ioe:            e = err.Error()            e.Set("Could not download archive specified in bif file "                  "from url=\"%s\" because of IOError=\"%s\"." % (                url, str(ioe)))            raise err.error, e        ## get a directory listing, and form a filter function which        ## prevents unpacking of modules which already exist        dir_list = self.depends.checkout_list('name') + \                   self.depends.distribution_list('name')        ## add the "build" directory to the list to prevent it from        ## getting overwritten        dir_list.append("build")        ## add the "distribution" directory to the list to prevent it from        ## getting overwritten        dir_list.append("distribution")        ## This could be slow... -Hubbe        def filter_func(x, dir_list = dir_list):            for e in range(0, len(dir_list)):                dir=dir_list[e]                if x[:len(dir)] == dir:                    if len(x) == len(dir) or x[len(dir)]=='/':                        print "archive skipping=\"%s\"" % (x)                        ## Swap to first for efficiency                        if e:                            dir_list[0], dir_list[e] = (dir, dir_list[0])                        return 0            return 1        ## extract and delete the archive        import archive        archive.RNA_Extract(local_path, filter_func, 1)        shell.rm(local_path)        ## take a snapshot of the new directory list        ## FIXME: This is not good if distributions actually go into subdirs!        new_directory_list = []        new_listdir = os.listdir(os.curdir)        for directory in new_listdir:            if not old_listdir.count(directory):                new_directory_list.append(directory)        return new_directory_list    def get_distribution(self, module, cvs_tag, cvs_date):        ## distributions with a .rna extension are treated specially --        ## these are usually huge archives of an entire build which are        ## too big to revision control        base, ext = os.path.splitext(module.name)        if ext == ".rna":            return self.get_archive(module)        ## FIXME: add a command-line-option for this!        root = self.default_cvs_root        if module.cvs_root:            root = module.cvs_root        profile = os.environ.get("PROFILE_ID","default")        import distributions        df=distributions.DistFinder(module.name, root, cvs_tag, cvs_date)        return df.get_distribution(sysinfo.distribution_id,                                   profile,                                   self.build_type)                                    def get_distribution_list(self, module_list, default_cvs_tag, default_cvs_date):        new_directory_list = []        for module in module_list:            ## Don't check these out            if module.checkin_dep_only:                if "distribute" not in self.settings['build_options'] and \                   "make_distributions" not in self.settings['build_options']:                    continue                        cvs_tag = default_cvs_tag            if module.cvs_tag_flag:                cvs_tag = module.cvs_tag            cvs_date = default_cvs_date            if module.cvs_date_flag:                cvs_date = module.cvs_date            new_directory_list = new_directory_list +\                                 self.get_distribution(module, cvs_tag, cvs_date)        return new_directory_list    def checkout_module(self, modules):        paths=[]        for module in modules:            if module.type != "cvs":                continue            if os.path.exists(module.name):                print "%s exists" % module.name                if ( not self.settings.get('update_mode_flag') and \                     not self.settings.get('clobber_mode_flag') ):                    continue            paths.append(module.name)        if not paths:            return        tag=self.default_cvs_tag        if self.everything_from_cvs_tag:            tag = self.everything_from_cvs_tag        elif module.cvs_tag_flag:            tag = module.cvs_tag        date=self.default_cvs_date        if self.everything_from_cvs_date:            date = self.everything_from_cvs_date        elif module.cvs_date_flag:            date = module.cvs_date;        ## FIXME: add a command-line-option for this!        root = self.default_cvs_root        if module.cvs_root:            root = module.cvs_root        if module.cvs_path:            d=apply(os.path.join,[os.curdir]+string.split(module.cvs_path,"/"))            if os.path.isdir(d):                print "Copying %s to %s" % (d, module.name)                shell.cp(d, module.name)            else:                self.checkout_files_from_tag([ module.cvs_path ],                                             tag,                                             root,                                             module.name,                                             date)            ## This will probably never happen            if len(paths) > 1:                checkout_modules(self, modules[:-1])        else:            print "OK"            self.checkout_files_from_tag(paths,                                         tag,                                         root,                                         None,                                         date)                        def checkout_files(self):        import chaingang        chaingang.ProcessModules_grouped(self.depends.checkout_list(),                                         self.checkout_module)        import cvs        cvs.MagicFixDir()        ## verify all modules checked out        broken = 0        for module in self.depends.checkout_list():            if not os.path.isdir(module.path()):                broken = broken + 1                if module.error_message:                    outmsg.error(module.error_message)                else:                    outmsg.error('module %s failed to check out' % (module.name))        if broken:            outmsg.send('')            outmsg.error("================================================")            outmsg.error("Some modules failed to check out, please look in")            outmsg.error("build.out to find out why.")            outmsg.error("================================================")                outmsg.send('')    def checkout_files_from_tag(self,                                module_name_list,                                cvs_tag,                                repository,                                as  = None,                                date = None):        report_cvs_tag = cvs_tag        if not len(cvs_tag):            report_cvs_tag = "HEAD"        if as:            for module_name in module_name_list:                outmsg.send("checking out [%s]%s tag=\"%s\" from path=\"%s\"" % (                    repository, as, report_cvs_tag, module_name))        else:            for module_name in module_name_list:                outmsg.send("checking out [%s]%s tag=\"%s\"" % (                    repository, module_name, report_cvs_tag))        import cvs        cvs.Checkout(cvs_tag, module_name_list, repository, as, date)    ## updates the platform.h in modules that wish it    def update_platform(self):        for module in self.depends.list():            if module.update_platform_header_flag:                import header                header.update_platform_header(module, self.build_branch)        # Backwards compatible cruft        if self.module_hash.has_key("include") and \           os.path.exists(os.path.join(os.curdir, "include","platform.h")):            import header            header.update_platform_header(self.module_hash["include"],                                          self.build_branch)                def collate_output(self, text):        outmsg.send(text[:-1])    def collate_error(self, text):        outmsg.error(text[:-1])    def collate_halt_or_print_error(self, module, e):        self.errors = self.errors + 1        if self.settings.get("halt_priority"):            priority_list = ["red", "yellow", "green"]            i1 = priority_list.index(self.settings.get("halt_priority"))            i2 = priority_list.index(module.halt_priority)            if i2 <= i1:                raise err.error, e        outmsg.send("\n" + e.Text())    def collate_module(self, module):        import plugin        ## change directory to the module directory        old_dir    = os.getcwd()        module_dir = os.path.join(old_dir, module.path())        ## check if the module path exists        if not os.path.isdir(module_dir):            outmsg.error('directory %s does not exist' % (module_dir))            return        ## set the current-module registry setting        bldreg.set_value('current-module', 'id', module.id)        bldreg.set_value('current-module', 'name', module.name)        ## change to module subdirectory        outmsg.send('from directory %s' % (old_dir))        outmsg.send('entering directory %s' % (module.name))        os.chdir(module_dir)        self.built = self.built + 1        try:            ## load collation class/plugin for module            collate_class = plugin.load_class(module)            if collate_class:                collate = collate_class(module, self.settings)                collate.set_output_func(self.collate_output)                collate.set_error_func(self.collate_error)                collate.run()        ## pass KeyboardInterrupt        except KeyboardInterrupt:            raise        ## if someone calls sys.exit() in a plugin, catch it here        ## and continue        except SystemExit:            pass        except err.error, e:            self.collate_halt_or_print_error(module, e)        ## all other exceptions catch and print traceback        except:            e = err.Error()            e.Set("A exception occurred while running plugin.")            e.SetTraceback(sys.exc_info())            self.collate_halt_or_print_error(module, e)        ## clear the current-module registry section        bldreg.clear_section('current-module')        ## change back to original directory        outmsg.send("leaving directory %s" % (module_dir))        try:            os.chdir(old_dir)        except os.error:            e = err.Error()            e.Set("could not return to directory=\"%s\"." % (old_dir))            raise err.error, e    # Kind of crufty..    def write_uber_umakefile(self):        def mangle(filename):

⌨️ 快捷键说明

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