Browse Source

Update scripts.

v1
Andrew Belt 5 years ago
parent
commit
0c950c82a5
2 changed files with 32 additions and 21 deletions
  1. +9
    -9
      scripts/collect_latest.py
  2. +23
    -12
      scripts/update.py

+ 9
- 9
scripts/collect_latest.py View File

@@ -18,14 +18,14 @@ for manifest_filename in glob.glob('manifests/*.json'):
with open(manifest_filename, "r") as f:
manifest = json.load(f)

if 'version' not in manifest:
continue
if "authorEmail" in manifest:
print(manifest["authorEmail"])

version = manifest['version']
arch = 'win'
package_filename = os.path.join(PACKAGES_DIR, f"{slug}-{version}-{arch}.zip")
# version = manifest['version']
# arch = 'win'
# package_filename = os.path.join(PACKAGES_DIR, f"{slug}-{version}-{arch}.zip")

try:
system(f'cp {package_filename} {DOWNLOADS_DIR}')
except Exception as e:
print(e)
# try:
# system(f'cp {package_filename} {DOWNLOADS_DIR}')
# except Exception as e:
# print(e)

+ 23
- 12
scripts/update.py View File

@@ -5,12 +5,13 @@ import json
import time
import build
import zipfile
import re


PACKAGES_DIR = "../packages"
SCREENSHOTS_DIR = "../screenshots"
MANIFESTS_DIR = "manifests"
RACK_USER_DIR = "~/.Rack"
RACK_USER_DIR = "$HOME/.Rack"
RACK_USER_PLUGIN_DIR = os.path.join(RACK_USER_DIR, "plugins-v1")

# Update git before continuing
@@ -26,7 +27,7 @@ if not plugin_filenames:
updated_slugs = set()

for plugin_filename in plugin_filenames:
(plugin_basename, plugin_ext) = os.path.splitext(plugin_filename)
(plugin_basename, plugin_ext) = os.path.splitext(os.path.basename(plugin_filename))
# Extract manifest from plugin dir or package
if os.path.isdir(plugin_filename):
manifest_filename = os.path.join(plugin_filename, "plugin.json")
@@ -37,19 +38,27 @@ for plugin_filename in plugin_filenames:
except IOError:
# Skip plugins without plugin.json
continue
slug = manifest['slug']
version = manifest['version']
elif plugin_ext == ".zip":
m = re.match(r'^(.*)-(.*?)-(.*?)$', plugin_basename)
slug = m[1]
version = m[2]
arch = m[3]
# Open ZIP
z = zipfile.ZipFile(plugin_filename)
manifest_filename = [f for f in z.namelist() if f.endswith("/plugin.json")][0]
# Unzip manifest
manifest_filename = f"{slug}/plugin.json"
with z.open(manifest_filename) as f:
manifest = json.load(f)
if manifest['slug'] != slug:
raise Exception(f"Manifest slug does not match filename slug {slug}")
if manifest['version'] != version:
raise Exception(f"Manifest slug does not match filename slug {slug}")
else:
raise Exception(f"Plugin {plugin_filename} must be a source dir or zip package")
raise Exception(f"Plugin {plugin_filename} is not a valid format")

# Get library manifest
slug = manifest['slug']
version = manifest['version']
library_manifest_filename = os.path.join(MANIFESTS_DIR, f"{slug}.json")

if os.path.isdir(plugin_filename):
@@ -68,8 +77,8 @@ for plugin_filename in plugin_filenames:
try:
build.delete_stage()
build.build(plugin_filename)
build.system(f"cp -vi stage/* '{PACKAGES_DIR}'")
build.system(f"cp -vi stage/* '{RACK_USER_PLUGIN_DIR}'")
build.system(f'cp -vi stage/* "{PACKAGES_DIR}"')
build.system(f'cp -vi stage/* "{RACK_USER_PLUGIN_DIR}"')
except Exception as e:
print(e)
print(f"{slug} build failed")
@@ -89,8 +98,10 @@ for plugin_filename in plugin_filenames:

# Copy package
package_dest = os.path.join(PACKAGES_DIR, os.path.basename(plugin_filename))
build.system(f"cp '{plugin_filename}' '{package_dest}'")
build.system(f"touch '{package_dest}'")
build.system(f'cp "{plugin_filename}" "{package_dest}"')
build.system(f'touch "{package_dest}"')
if arch == 'lin':
build.system(f'cp "{plugin_filename}" "{RACK_USER_PLUGIN_DIR}"')

# Copy manifest
with open(library_manifest_filename, "w") as f:
@@ -98,7 +109,7 @@ for plugin_filename in plugin_filenames:

# Delete screenshot cache
screenshots_dir = os.path.join(SCREENSHOTS_DIR, slug)
build.system(f"rm -rf '{screenshots_dir}'")
build.system(f'rm -rf "{screenshots_dir}"')

updated_slugs.add(slug)

@@ -121,5 +132,5 @@ build.system(f"git commit -m 'Update manifest for {built_slugs_str}'")
build.system("git push")

print()
print(f"Built {built_slugs_str}")
print(f"Updated {built_slugs_str}")
print("Remember to generate and upload screenshots")

Loading…
Cancel
Save