Last active
October 25, 2018 22:55
-
-
Save waveform80/7d0a74e59ab1d073908d99b7a4523c01 to your computer and use it in GitHub Desktop.
Quick hack to scan for symlinks in wheels on piwheels master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
import stat | |
import zipfile | |
import tarfile | |
def scan(path): | |
for dirpath, dirnames, filenames in os.walk(path): | |
for filename in filenames: | |
if filename.endswith(('.zip', '.whl')): | |
print('Checking %s/%s' % (dirpath, filename)) | |
with zipfile.ZipFile(os.path.join(dirpath, filename)) as arc: | |
for info in arc.infolist(): | |
mode = info.external_attr >> 16 | |
if stat.S_ISLNK(mode): | |
print('Found symlink: %s' % info.filename) | |
elif filename.endswith(('.tar', '.tgz', '.tar.gz', '.tar.xz')): | |
print('Checking %s/%s' % (dirpath, filename)) | |
with tarfile.TarFile(os.path.join(dirpath, filename)) as arc: | |
for member in arc.getmembers(): | |
if member.issym(): | |
print('Found symlink: %s' % member.name) | |
for dirname in dirnames: | |
scan(os.path.join(dirpath, dirname)) | |
scan('www/simple') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment