Added auto get for application, cli and core data

This commit is contained in:
Christoffer Martinsson
2018-10-29 00:22:23 +01:00
parent 4d5fd60ef3
commit 6d54150f06
18 changed files with 173 additions and 38 deletions

54
get_app_data.py Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/python
import requests
import sys
import os
apps = {"broadlink": "68", "zwave": "60", "huee": "62", "webapp": "59"}
headers = {"PRIVATE-TOKEN": sys.argv[1]}
# Core
date = requests.get('https://git.cmtec.se/api/v4/projects/58/repository/commits/master', headers=headers).json()["committed_date"]
readme = requests.get('https://git.cmtec.se/api/v4/projects/58/repository/files/README.md/raw?ref=master', headers=headers).text
changelog = requests.get('https://git.cmtec.se/api/v4/projects/58/repository/files/CHANGELOG.md/raw?ref=master', headers=headers).text
meta_readme = '+++\ntitle = "Core"\nhead = "<label>Modules</label>"\nweight = 5\ndate = "' + date + '"\n+++\n'
meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\n+++\n'
if not os.path.exists("content/core"):
os.makedirs("content/core")
with open('content/core/_index.md', 'w') as file:
file.write(meta_readme + readme)
with open('content/core/changelog.md', 'w') as file:
file.write(meta_changelog + changelog)
# CLI
date = requests.get('https://git.cmtec.se/api/v4/projects/69/repository/commits/master', headers=headers).json()["committed_date"]
readme = requests.get('https://git.cmtec.se/api/v4/projects/69/repository/files/README.md/raw?ref=master', headers=headers).text
changelog = requests.get('https://git.cmtec.se/api/v4/projects/69/repository/files/CHANGELOG.md/raw?ref=master', headers=headers).text
meta_readme = '+++\ntitle = "CLI"\nweight = 7\ndate = "' + date + '"\n+++\n'
meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\n+++\n'
if not os.path.exists("content/cli"):
os.makedirs("content/cli")
with open('content/cli/_index.md', 'w') as file:
file.write(meta_readme + readme)
with open('content/cli/changelog.md', 'w') as file:
file.write(meta_changelog + changelog)
# Applications
for app in apps.keys():
date = requests.get('https://git.cmtec.se/api/v4/projects/' + apps[app] + '/repository/commits/master', headers=headers).json()["committed_date"]
readme = requests.get('https://git.cmtec.se/api/v4/projects/' + apps[app] + '/repository/files/README.md/raw?ref=master', headers=headers).text
changelog = requests.get('https://git.cmtec.se/api/v4/projects/' + apps[app] + '/repository/files/CHANGELOG.md/raw?ref=master', headers=headers).text
meta_readme = '+++\ntitle = "' + app[0].upper() + app[1:] + '"\ndate = "' + date + '"\n+++\n'
meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\n+++\n'
if not os.path.exists("content/applications/" + app):
os.makedirs("content/applications/" + app)
with open('content/applications/' + app + '/_index.md', 'w') as file:
file.write(meta_readme + readme)
with open('content/applications/' + app + '/changelog.md', 'w') as file:
file.write(meta_changelog + changelog)