Example #1
0
def normBinaryName(path, isPathPreserved=False, isGui=False):
    if path is None: return None
    if not isPathPreserved: path = fileBaseName(path)
    base, ext = splitExt(path)
    if IS_MACOS and isGui:
        return "%s%s" % (base, _MACOS_APP_EXT)
    if IS_WINDOWS: return base + (".exe" if ext == "" else ext)
    return base
Example #2
0
def normIconName(path, isPathPreserved=False):
    if path is None: return None
    if not isPathPreserved: path = fileBaseName(path)
    base, _ = splitExt(path)
    if IS_WINDOWS: return "%s%s" % (base, _WINDOWS_ICON_EXT)
    elif IS_MACOS: return "%s%s" % (base, _MACOS_ICON_EXT)
    elif IS_LINUX: return "%s%s" % (base, _LINUX_ICON_EXT)
    raise Exception(__NOT_SUPPORTED_MSG)
    return base
Example #3
0
    def _macMountDmg(dmgPath):
        def _toRet(isNew, mountPath, appPath, binPath):
            return (isNew, mountPath, appPath if isFile(appPath) else None,
                    binPath if isFile(binPath) else None)

        #example mount path:
        #   /Volumes/QtInstallerFramework-mac-x64/QtInstallerFramework-mac-x64.app/Contents/MacOS/QtInstallerFramework-mac-x64
        dmgBaseName = splitExt(fileBaseName(dmgPath))[0]
        mountPath = joinPath(PATH_DELIM, joinPath("Volumes", dmgBaseName))
        appPath = joinPath(mountPath, "%s.app" % (dmgBaseName, ))
        binPath = __INTERNAL_MACOS_APP_BINARY_TMPLT % (
            normBinaryName(appPath, isPathPreserved=True, isGui=True),
            normBinaryName(appPath, isPathPreserved=False, isGui=False))
        if isDir(mountPath):
            return _toRet(False, mountPath, appPath, binPath)
        _system('hdiutil mount "%s"' % (dmgPath, ))
        if isDir(mountPath):
            return _toRet(True, mountPath, appPath, binPath)
        raise Exception("Failed to mount %s to %s" % (dmgPath, mountPath))
Example #4
0
def toZipFile(sourceDir,
              zipDest=None,
              removeScr=True,
              isWrapperDirIncluded=False):
    sourceDir = absPath(sourceDir)
    if zipDest is None:
        zipDest = sourceDir  # make_archive adds extension
    else:
        if isFile(zipDest): removeFile(zipDest)
        zipDest, _ = splitExt(zipDest)
    if isWrapperDirIncluded:
        filePath = make_archive(zipDest, 'zip', dirPath(sourceDir),
                                fileBaseName(sourceDir))
    else:
        filePath = make_archive(zipDest, 'zip', sourceDir)
    print('Created zip file: "%s"' % (filePath, ))
    if removeScr:
        removeDir(sourceDir)
        print('Removed directory: "%s"' % (sourceDir, ))
    return filePath
Example #5
0
def rootFileName(path):
    if path is None: return None
    return splitExt(fileBaseName(path))[0]
Example #6
0
def _isMacApp(path):
    if path is None: return False
    return IS_MACOS and splitExt(path)[1] == ".app"
Example #7
0
 def _isDmg(filePath):
     try:
         return splitExt(filePath)[1].lower() == ".dmg"
     except:
         return False