From 02e5cc1ae2400da9d737969f7eb72be608ab19da Mon Sep 17 00:00:00 2001 From: Matt Venn Date: Thu, 25 May 2023 13:55:54 +0200 Subject: [PATCH 1/3] lint --- configure.py | 3 ++- lint.sh | 2 +- orders.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index 9d21285..2336fcc 100755 --- a/configure.py +++ b/configure.py @@ -205,7 +205,7 @@ class Projects(): logging.info(f"max util {max_util} for project {max_util_project}") logging.info(f"min util {min_util}") logging.info(f"languages {languages}") - tags = [ x.strip().lower() for x in tags ] + tags = [x.strip().lower() for x in tags] tags = list(filter(lambda a: a != "", tags)) def count_items(lst): @@ -223,6 +223,7 @@ class Projects(): logging.info("top 10 tags") count_items(tags) + if __name__ == '__main__': parser = argparse.ArgumentParser(description="TinyTapeout configuration and docs") diff --git a/lint.sh b/lint.sh index b92498a..bfb6bcb 100755 --- a/lint.sh +++ b/lint.sh @@ -1 +1 @@ -flake8 --ignore E203,E123,E501,E221,E401,W605 configure.py project.py tt_tool.py orders.py documentation.py caravel.py +flake8 --ignore E203,E123,E501,E221,E401,W605 configure.py project.py tt_tool.py orders.py documentation.py caravel.py git_utils.py diff --git a/orders.py b/orders.py index 482d102..09c53e3 100644 --- a/orders.py +++ b/orders.py @@ -24,7 +24,7 @@ class Orders(): try: with open(self.config['extra_projects']) as fh: config = yaml.safe_load(fh) - except FileNotFoundError as e: + except FileNotFoundError: config = [] config.append({'project': {'url' : git_url, 'timestamp' : time.time()}}) @@ -75,7 +75,7 @@ class Orders(): while after_open_date: refunds = stripe.Refund.list(limit=10, starting_after=start_id) - for refund in refunds: + for refund in refunds: created = datetime.fromtimestamp(refund['created']) if created < self.open_date: after_open_date = False From bd524505bfd6c1d0e9a42330d67a1dde74298a9f Mon Sep 17 00:00:00 2001 From: Matt Venn Date: Thu, 25 May 2023 14:57:16 +0200 Subject: [PATCH 2/3] fix problem with wokwi files not being fetched. Add the wokwi truthtable testing that got lost in merge --- configure.py | 5 ----- git_utils.py | 6 ++++-- project.py | 43 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/configure.py b/configure.py index 2336fcc..9d1c2ab 100755 --- a/configure.py +++ b/configure.py @@ -99,11 +99,6 @@ class Projects(): project.post_clone_setup() logging.debug(project) - # fetch the wokwi source - if args.clone_all: - if not project.is_fill() and project.is_wokwi(): - project.fetch_wokwi_files() - if args.harden: if filler is False: project.create_user_config() diff --git a/git_utils.py b/git_utils.py index aa75837..495e4ad 100644 --- a/git_utils.py +++ b/git_utils.py @@ -3,7 +3,9 @@ from urllib.parse import urlparse import logging import requests import os -import zipfile, io +import zipfile +import io +import errno def unique(duplist): @@ -21,7 +23,7 @@ def fetch_file(url, filename): r = requests.get(url) if r.status_code != 200: logging.warning("couldn't download {}".format(url)) - exit(1) + raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename) with open(filename, 'wb') as fh: logging.info("written to {}".format(filename)) diff --git a/project.py b/project.py index aa94e97..a122775 100644 --- a/project.py +++ b/project.py @@ -293,15 +293,54 @@ class Project(): def fetch_wokwi_files(self): logging.info("fetching wokwi files") src_file = self.src_files[0] - url = "https://wokwi.com/api/projects/{}/verilog".format(self.wokwi_id) + url = f"https://wokwi.com/api/projects/{self.wokwi_id}/verilog" git_utils.fetch_file(url, os.path.join(self.local_dir, "src", src_file)) # also fetch the wokwi diagram - url = "https://wokwi.com/api/projects/{}/diagram.json".format(self.wokwi_id) + url = f"https://wokwi.com/api/projects/{self.wokwi_id}/diagram.json" diagram_file = "wokwi_diagram.json" git_utils.fetch_file(url, os.path.join(self.local_dir, "src", diagram_file)) + # attempt to download the *optional* truthtable for the project + truthtable_file = "truthtable.md" + url = f"https://wokwi.com/api/projects/{self.wokwi_id}/{truthtable_file}" + try: + git_utils.fetch_file(url, os.path.join(self.local_dir, "src", truthtable_file)) + logging.info(f'Wokwi project {self.wokwi_id} has a truthtable included, will test!') + self.install_wokwi_testing() + except FileNotFoundError: + pass + + def install_wokwi_testing(self, destination_dir='src', resource_dir=None): + if resource_dir is None or not len(resource_dir): + resource_dir = os.path.join(os.path.dirname(__file__), 'testing') + + # directories in testing/lib to copy over + pyLibsDir = os.path.join(resource_dir, 'lib') + + # src template dir + srcTplDir = os.path.join(resource_dir, 'src-tpl') + + for libfullpath in glob.glob(os.path.join(pyLibsDir, '*')): + logging.info(f'Copying {libfullpath} to {destination_dir}') + shutil.copytree( + libfullpath, + os.path.join(destination_dir, os.path.basename(libfullpath)), + dirs_exist_ok=True) + + for srcTemplate in glob.glob(os.path.join(srcTplDir, '*')): + with open(srcTemplate, 'r') as f: + contents = f.read() + customizedContents = re.sub('WOKWI_ID', str(self.wokwi_id), contents) + outputFname = os.path.basename(srcTemplate) + with open(os.path.join(destination_dir, outputFname), 'w') as outf: + logging.info(f'writing src tpl to {outputFname}') + outf.write(customizedContents) + outf.close() + def create_user_config(self): + if self.is_wokwi(): + self.fetch_wokwi_files() logging.info("creating include file") filename = 'user_config.tcl' with open(os.path.join(self.local_dir, 'src', filename), 'w') as fh: From 98030039df5b9c580796f7847530cd52802438d9 Mon Sep 17 00:00:00 2001 From: Matt Venn Date: Thu, 1 Jun 2023 10:10:07 +0200 Subject: [PATCH 3/3] fix broken cell library link --- project.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project.py b/project.py index a122775..3ca5446 100644 --- a/project.py +++ b/project.py @@ -12,8 +12,7 @@ import git_utils import git import shutil -# can't find a google version -CELL_URL = 'https://antmicro-skywater-pdk-docs.readthedocs.io/en/test-submodules-in-rtd/contents/libraries/sky130_fd_sc_ls/cells/' +CELL_URL = 'https://skywater-pdk.readthedocs.io/en/main/contents/libraries/sky130_fd_sc_hd/cells/' class Project():