How to use the macholib.util.flipwritable function in macholib

To help you get started, we’ve selected a few macholib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metachris / py2app / py2app / build_app.py View on Github external
raise DistutilsPlatformError('_tkinter is linked to a version of Tk not in /System')

        rewrite_map[tk_path] = '/System/Library/Frameworks/Tk.framework/Versions/%s/Tk'%(ver,)

    if rewrite_map:
        print("Relinking _tkinter.so to system Tcl/Tk")
        rewroteAny = False
        for header in m.headers:
            for idx, name, other in header.walkRelocatables():
                data = rewrite_map.get(other)
                if data:
                    if header.rewriteDataForCommand(idx, data.encode(sys.getfilesystemencoding())):
                        rewroteAny = True

        if rewroteAny:
            old_mode = flipwritable(m.filename)
            try:
                with open(m.filename, 'rb+') as f:
                    for header in m.headers:
                        f.seek(0)
                        header.write(f)
                        f.seek(0, 2)
                        f.flush()

            finally:
                flipwritable(m.filename, old_mode)

    else:
        print("_tkinter already linked against system Tcl/Tk")
github nortd / driveboardapp / other / pyinstaller / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
changemap[node.filename] = dest

        def changefunc(path):
            res = mm.locate(path)
            return changemap.get(res)

        for node in machfiles:
            fn = mm.locate(node.filename)
            if fn is None:
                continue
            rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    f = open(fn, 'rb+')
                    for header in node.headers:
                        f.seek(0)
                        node.write(f)
                    f.seek(0, 2)
                    f.flush()
                    f.close()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github pyinstaller / pyinstaller / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
continue
            rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    with open(fn, 'rb+') as f:
                        for header in node.headers:
                            f.seek(0)
                            node.write(f)
                        f.seek(0, 2)
                        f.flush()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github nortd / driveboardapp / other / pyinstaller / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    f = open(fn, 'rb+')
                    for header in node.headers:
                        f.seek(0)
                        node.write(f)
                    f.seek(0, 2)
                    f.flush()
                    f.close()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github pyinstaller / pyinstaller / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
changemap[node.filename] = dest

        def changefunc(path):
            res = mm.locate(path)
            return changemap.get(res)

        for node in machfiles:
            fn = mm.locate(node.filename)
            if fn is None:
                continue
            rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    with open(fn, 'rb+') as f:
                        for header in node.headers:
                            f.seek(0)
                            node.write(f)
                        f.seek(0, 2)
                        f.flush()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github HenriWahl / Nagstamon / build / helpers / pyinstaller-2.1 / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
changemap[node.filename] = dest

        def changefunc(path):
            res = mm.locate(path)
            return changemap.get(res)

        for node in machfiles:
            fn = mm.locate(node.filename)
            if fn is None:
                continue
            rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    with open(fn, 'rb+') as f:
                        for header in node.headers:
                            f.seek(0)
                            node.write(f)
                        f.seek(0, 2)
                        f.flush()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github HenriWahl / Nagstamon / build / helpers / pyinstaller-2.1 / PyInstaller / lib / macholib / MachOStandalone.py View on Github external
continue
            rewroteAny = False
            for header in node.headers:
                if node.rewriteLoadCommands(changefunc):
                    rewroteAny = True
            if rewroteAny:
                old_mode = flipwritable(fn)
                try:
                    with open(fn, 'rb+') as f:
                        for header in node.headers:
                            f.seek(0)
                            node.write(f)
                        f.seek(0, 2)
                        f.flush()
                finally:
                    flipwritable(fn, old_mode)

        allfiles = [mm.locate(node.filename) for node in machfiles]
        return set(filter(None, allfiles))
github metachris / py2app / py2app / build_app.py View on Github external
if data:
                    if header.rewriteDataForCommand(idx, data.encode(sys.getfilesystemencoding())):
                        rewroteAny = True

        if rewroteAny:
            old_mode = flipwritable(m.filename)
            try:
                with open(m.filename, 'rb+') as f:
                    for header in m.headers:
                        f.seek(0)
                        header.write(f)
                        f.seek(0, 2)
                        f.flush()

            finally:
                flipwritable(m.filename, old_mode)

    else:
        print("_tkinter already linked against system Tcl/Tk")