Inspired by John Long's uao script.
Using Python 3
Inspired by John Long's uao script.
Using Python 3
#!/usr/bin/env python | |
import sys | |
import os | |
import subprocess | |
def execute(command): | |
print('Running: {}'.format(command)) | |
return subprocess.check_call(command, shell=True) | |
if __name__ == '__main__': | |
assert len(sys.argv) == 2 and sys.argv[1].endswith('.zip'), 'Must supply a single zip file to unpackage.' | |
fileName = sys.argv[1] | |
zipFile = os.path.abspath(sys.argv[1]) | |
assert os.path.exists(zipFile), 'Provided file does not exist.' | |
try: | |
execute('unzip -a "{}"'.format(zipFile)) | |
except: | |
sys.exit("Error while unzipping {}. Exiting.".format(fileName)) | |
extension = ".zip" | |
folder = zipFile[:-len(extension)] if zipFile.endswith(extension) else zipFile | |
pom = os.path.join(folder, 'pom.xml') | |
try: | |
execute('open -a /Applications/IntelliJ\ IDEA\ CE.app/ "{}"'.format(pom)) | |
except: | |
sys.exit("Unable to open pom file.") | |
print("Deleting {}".format(zipFile)) | |
os.remove(zipFile) |