Skip to content

Commit

Permalink
implement assemblysteps --generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
capsulecorplab committed Oct 11, 2023
1 parent 40558f5 commit 435c393
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins {
def homePath = System.properties['user.home']
def src = "$projectDir"
def schemaDir = "$projectDir/dof-cubesat"
def dofhelpersDir = "$projectDir/dof-helpers"
def schemaBuildDir = "$schemaDir/build"
def installDir = "$homePath/.cubesat-cli"
def binDir = "$installDir/bin"
Expand All @@ -26,8 +27,13 @@ tasks.register('buildSchema', Exec) {
commandLine "bash", "-c", "cd $schemaDir && ./gradlew build"
}

tasks.register('installDofhelpersNodeModules', Exec) {
commandLine "bash", "-c", "cd $dofhelpersDir && npm ci"
}

tasks.register('copyFilesToInstallDir', Copy) {
dependsOn(buildSchema)
dependsOn(installDofhelpersNodeModules)
from "$src"
into "$installDir"
}
Expand Down
59 changes: 58 additions & 1 deletion cubesat_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def __init__(self):
self.dof_cubesat_schema_path = path.join(
self.dof_cubesat_path, "build/schema/dof-cubesat.yaml"
)
self.dof_helpers_path = path.join(self.fullpath, "dof-helpers")
self.dof_helpers_parse_component_path = path.join(
self.dof_helpers_path, "parseComponent.js"
)
self.dof_helpers_generate_assembly_instructions_path = path.join(
self.dof_helpers_path, "generateAssemblyInstructions.js"
)

with open(self.dof_cubesat_schema_path, "r") as file:
self.dof_cubesat_schema_as_str = file.read()
Expand Down Expand Up @@ -55,12 +62,17 @@ def setup_cli(self):
help="Validate a {0}".format(class_name),
action="store_true",
)
self.parsers[class_name].add_argument(
"-g",
"--generate",
help="Generate a {0}".format(class_name),
action="store_true",
)
self.parsers[class_name].add_argument(
"-f",
"--filename",
type=str,
nargs=1,
required=True,
help="Filename of {0}".format(class_name),
)

Expand Down Expand Up @@ -101,6 +113,9 @@ def setup_cli(self):
activitystep,
target_class="ActivityStep",
)
if args.generate == True:
if args.command == "assemblysteps":
self.generateAssemblySteps()

def validate(
self,
Expand Down Expand Up @@ -132,6 +147,48 @@ def validate(
]
)

def generateAssemblySteps(self):
run(
[
"mkdir",
"dist/",
]
)
run(
[
"node",
self.dof_helpers_parse_component_path,
]
)
run(
[
"node",
self.dof_helpers_generate_assembly_instructions_path,
]
)
run(["cp", "-r", "src/images", "dist/"])
run(["cp", "-r", "source/images", "dist/"])
run(
[
"asciidoctor",
"dist/assemblyInstructions.adoc",
"-o",
"dist/assemblyInstructions.html",
]
)
run(
[
"asciidoctor",
"dist/assemblyInstructions.adoc",
"-o",
"dist/assemblyInstructions.pdf",
"-r",
"asciidoctor-pdf",
"-b",
"pdf",
]
)


if __name__ == "__main__":
# Setup cubesat database instance
Expand Down

0 comments on commit 435c393

Please sign in to comment.