Browse Source

Fix and update build scripts.

v1
Andrew Belt 5 years ago
parent
commit
ad78366900
3 changed files with 15 additions and 8 deletions
  1. +8
    -4
      scripts/common.py
  2. +1
    -1
      scripts/update.py
  3. +6
    -3
      scripts/update_cache.py

+ 8
- 4
scripts/common.py View File

@@ -1,6 +1,13 @@
import subprocess


def system(cmd):
print(cmd)
result = subprocess.run(cmd, shell=True)
if result.returncode != 0:
raise Exception(f"Command failed with error {result.returncode}: {cmd}")


def system(cmd):
print(cmd)
result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
@@ -10,7 +17,4 @@ def system(cmd):


def find(list, f):
try:
return next(x for x in list if f(x))
except:
return None
return next((x for x in list if f(x)), None)

+ 1
- 1
scripts/update.py View File

@@ -143,7 +143,7 @@ common.system("cd ../screenshots && make upload")

# Commit repository
common.system("git add manifests")
common.system("git add manifest-cache.json ModularGrid-VCVLibrary.json")
common.system("git add manifests-cache.json ModularGrid-VCVLibrary.json")
common.system(f"git commit -m 'Update manifest for {built_slugs_str}'")
common.system("git push")



+ 6
- 3
scripts/update_cache.py View File

@@ -22,19 +22,19 @@ def get_plugin_build(plugin):

# Get the timestamp of the earliest commit touching the manifest file
def get_plugin_creation(manifest_filename):
stdout = common.system(f"git log --format=%ct -- {manifest_filename} | tail -1")
stdout = common.run(f"git log --format=%ct -- {manifest_filename} | tail -1")
return float(stdout.strip())


# Get the timestamp of the earliest commit having the module slug
def get_module_creation(manifest_filename, module_slug):
stdout = common.system(f"git log --format='%H %ct' -- {manifest_filename}")
stdout = common.run(f"git log --format='%H %ct' -- {manifest_filename}")
# Use current time as a fallback because if there's no commit with the module, it was added just now.
earliestTime = time.time()
for line in stdout.strip().split("\n"):
hash, timestamp = line.split(" ")
try:
stdout = common.system(f"git show {hash}:{manifest_filename}")
stdout = common.run(f"git show {hash}:{manifest_filename}")
manifest = json.loads(stdout)
# If the module exists in this commit, keep iterating
if not common.find(manifest.get('modules', []), lambda module: module['slug'] == module_slug):
@@ -65,6 +65,7 @@ def update():

# Get plugin build
if 'buildTimestamp' not in cache_plugin:
print(f"Getting buildTimestamp for plugin {plugin_slug}")
try:
cache_plugin['buildTimestamp'] = get_plugin_build(plugin)
except:
@@ -72,6 +73,7 @@ def update():

# Get plugin creation
if 'creationTimestamp' not in cache_plugin:
print(f"Getting creationTimestamp for plugin {plugin_slug}")
cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename)

# Iterate modules in plugin
@@ -82,6 +84,7 @@ def update():

# Get module creation
if 'creationTimestamp' not in cache_module:
print(f"Getting creationTimestamp for plugin {plugin_slug} module {module_slug}")
cache_module['creationTimestamp'] = get_module_creation(manifest_filename, module_slug)

cache_modules[module_slug] = cache_module


Loading…
Cancel
Save