This repository has been archived on 2023-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-package-manager-addon/blenderpack.py
gandalf3 8baacc366b Split repo generation functionality out of blenderpack.py
Moved repo.json generation to make_repo.py
Package/addon parsing is getting a bit messy, this can be
cleaned up when we have a clearer idea of what a package is.

For now just make it work.
2017-07-02 15:15:48 -07:00

83 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
# HACK: seems 'requests' module bundled with blender isn't bundled with 'idna' module. So force system python for now
import sys
sys.path.insert(0, '/usr/lib/python3.6/site-packages')
import requests
import json
import os
import pathlib
import ast
import argparse
import zipfile
import logging
log = logging.getLogger(__name__)
REQUIRED_KEYS = set(['name', 'blender', 'version'])
SCHEMA_VERSION = 1
class BadAddon(Exception):
pass
def fetch(url, pipe):
# we have to explicitly close the end of the pipe we are NOT using,
# otherwise no exception will be generated when the other process closes its end.
pipe[0].close()
local_repo_path = pathlib.Path(__file__).parent / 'packages'
local_repo_path.mkdir(exist_ok=True)
try:
# TODO: do conditional request
re = requests.get(url)
pipe[1].send(re.status_code)
repo = re.json()
repo['etag'] = re.headers.get('etag')
repo['last-modified'] = re.headers.get('last-modified')
# just stick it here for now..
dump_repo(local_repo_path, repo)
finally:
pipe[1].close()
# class Package:
# def __init__(self):
# self.bl_info = None
# self.url = None
# self.type = None
#
# class Repository:
# def __init__(self, name):
# self.name = name
# self.packages = None
#
# def json(self):
# return json.dumps(self.__dict__)
def main():
pass
# print(args)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Search, install, and manage packages for Blender')
subparsers = parser.add_subparsers()
make = subparsers.add_parser('make')
make.add_argument('path')
make.set_defaults(func=lambda args: make_repo(pathlib.Path(args.path)))
args = parser.parse_args()
args.func(args)
main()