setup.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码
def buildDMG(self):
                # remove DMG if it already exists
                if os.path.exists(self.dmgName):
                    os.unlink(self.dmgName)

                tmpDir = os.path.join(self.buildDir, 'tmp')
                if os.path.exists(tmpDir):
                    dir_util.remove_tree(tmpDir, verbose=1)
                self.mkpath(tmpDir)

                # move the app bundle into a separate folder since hdutil copies in the dmg
                # the content of the folder specified in the -srcfolder folder parameter, and if we
                # specify as input the app bundle itself, its content will be copied and not the bundle
                if os.spawnvp(os.P_WAIT, 'cp', ['cp', '-R', self.bundleDir, tmpDir]):
                    raise OSError('could not move app bundle in staging directory')

                createargs = [
                    'hdiutil', 'create', '-fs', 'HFSX', '-format', 'UDZO',
                    self.dmgName, '-imagekey', 'zlib-level=9', '-srcfolder',
                    tmpDir, '-volname', self.volume_label
                ]

                if self.applications_shortcut:
                    scriptargs = [
                        'osascript', '-e', 'tell application "Finder" to make alias \
                        file to POSIX file "/Applications" at POSIX file "%s"' %
                        os.path.realpath(self.buildDir)
                    ]

                    if os.spawnvp(os.P_WAIT, 'osascript', scriptargs) != 0:
                        raise OSError('creation of Applications shortcut failed')

                    createargs.append('-srcfolder')
                    createargs.append(self.buildDir + '/Applications')

                # create the dmg
                if os.spawnvp(os.P_WAIT, 'hdiutil', createargs) != 0:
                    raise OSError('creation of the dmg failed')

                # remove the temporary folder
                dir_util.remove_tree(tmpDir, verbose=1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号