Created
August 31, 2015 12:43
-
-
Save t0mk/09b08d4d6a9d3c8e0edf to your computer and use it in GitHub Desktop.
apps fact
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
#!/home/core/bin/python | |
APP_PATH = '/apps' | |
CONFIG = 'config.yml' | |
import os | |
import yaml | |
import json | |
import subprocess | |
result = {} | |
for d in os.listdir(APP_PATH): | |
if d.startswith('.'): | |
continue | |
result[d] = None | |
try: | |
with open(os.path.join(APP_PATH, d, CONFIG)) as f: | |
result[d] = yaml.load(f) | |
cwd = os.getcwd() | |
os.chdir(os.path.join(APP_PATH, d)) | |
comm = "git config --get remote.origin.url" | |
result[d]['repourl'] = subprocess.check_output(comm.split()).strip() | |
os.chdir(cwd) | |
except Exception as e: | |
print e | |
print json.dumps(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment