Last active
January 6, 2017 20:27
-
-
Save cryzed/0b88defc9371cf76b2f5c8d52685732c to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
import shlex | |
import subprocess | |
PATH = '/usr/lib/python3.5/site-packages' | |
def main(): | |
if not os.path.exists(PATH): | |
print(PATH, 'could not be found. No packages will need to be rebuilt.') | |
return | |
packages = set() | |
for name in os.listdir(PATH): | |
command = ['pacman', '-Qoq', os.path.join(PATH, name)] | |
try: | |
output = subprocess.check_output(command, stderr=subprocess.PIPE, universal_newlines=True) | |
except subprocess.CalledProcessError as exception: | |
print(f'Failed to execute "{" ".join(shlex.quote(part) for part in command)}": {exception.stderr.strip()}') | |
continue | |
# a file or folder might be owned by many packages, for example __pycache__ | |
packages.update(output.strip().split('\n')) | |
print('The following packages will need to be rebuilt:', ' '.join(sorted(packages))) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment