Created
August 13, 2015 19:26
-
-
Save ludflu/b910c827ff6b17f2aa92 to your computer and use it in GitHub Desktop.
python script for rooting out unused jars
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
#!/usr/local/bin/python | |
import subprocess | |
from os import listdir,rename,mkdir,system | |
from os.path import isfile, join | |
try: | |
mkdir('bad') | |
except: | |
print "already exists" | |
path = 'lib' | |
jars = [ f for f in listdir(path) if isfile(join(path,f)) and f.endswith('jar')] | |
for j in jars: | |
print "moving " + j | |
rename ('lib/'+j, 'bad/'+j) | |
rtcode = -1 | |
try: | |
rc = system("ant junit") | |
rtcode = rc | |
print "returncode" | |
print rtcode | |
except Exception as e: | |
print "failed! " + e.message | |
if rtcode != 0: | |
print "bad returncode, moving file back: " + j | |
rename ('bad/'+j, 'lib/'+j) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment