1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import sys, os, re, shutil import helper def get_artifacts(path, libdir): artifacts = list() # ziph is zipfile handle for root, dirs, files in os.walk(path): if "doc_unzip" in root: for file in files: filename=os.path.join(root, file) dirname=re.split("doc_unzip[^\\\\]*", root)[1].lstrip("\\") print(dirname) destdir=os.path.join(libdir + ".doc", dirname) print("parsing file: %s (%s)" % (filename, destdir)) if not os.path.exists(destdir): os.mkdir(destdir) shutil.copy2(filename, destdir) artifacts.append(os.path.join(destdir, file)) return artifacts class SearchBuildDo(helper.SearchBuild): # Build rules for: # - *.library -> *.compiled-library def doit(self, filename): artifacts = list() if filename.endswith(".library"): destination = filename.replace(".library", ".compiled-library") artifacts.append(destination) print("%s -> %s\n" % (filename, destination)) proj = projects.open(filename) proj.save_as_compiled_library(destination) print(os.environ) artifacts = get_artifacts(os.path.join("c:", "users", "Public", "Application Data", "CODESYS", "Temporary Files"), filename) proj.close() return artifacts scriptpath = os.path.abspath(os.path.dirname(sys.argv[0])) sb = SearchBuildDo() sb.search(".library", ".") sb.save(".", ".drone-artifacts") |