Skip to content

Commit

Permalink
Add start_FABulator command to be able to run FABulator from the FABu…
Browse files Browse the repository at this point in the history
…lous shell
  • Loading branch information
JakobTernes committed Aug 16, 2024
1 parent f6a7c12 commit 3fe3e26
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
38 changes: 36 additions & 2 deletions FABulous/FABulous.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def do_gen_fabric(self, *ignored):
logger.info("Fabric generation complete")

def do_gen_geometry(self, *vargs):
"""Generates geometry of fabric for the FABulous editor by checking if fabric
"""Generates geometry of fabric for FABulator by checking if fabric
is loaded, and calling 'genGeometry' and passing on padding value. Default
padding is '8'.
Expand Down Expand Up @@ -869,10 +869,44 @@ def do_gen_geometry(self, *vargs):
if 4 <= padding <= 32:
self.fabricGen.genGeometry(padding)
logger.info("Geometry generation complete")
logger.info(f"{geomFile} can now be imported into the FABulous Editor")
logger.info(f"{geomFile} can now be imported into FABulator")
else:
logger.error("padding has to be between 4 and 32 inclusively!")

def do_start_FABulator(self, *ignored):
"""Starts FABulator if an installation can be found.
If no installation can be found, a warning is produced.
Usage:
start_FABulator
Parameters
----------
*ignored : tuple
Ignores additional arguments.
"""
logger.info("Checking for FABulator installation")
fabulatorRoot = os.getenv("FABULATOR_ROOT")
if fabulatorRoot is None:
logger.warning("FABULATOR_ROOT environment variable not set.")
logger.warning(
"Install FABulator and set the FABULATOR_ROOT environment variable to use this feature."
)
elif not os.path.exists(fabulatorRoot):
logger.warning(
f"FABULATOR_ROOT environment variable set to {fabulatorRoot} but the directory does not exist."
)
else:
logger.info(f"Found FABulator installation at {fabulatorRoot}")
logger.info(f"Trying to start FABulator...")

startupCmd = ["mvn", "-f", f"{fabulatorRoot}/pom.xml", "javafx:run"]
try:
sp.Popen(startupCmd)
except sp.SubprocessError:
logger.error("Startup of FABulator failed.")

def do_gen_bitStream_spec(self, *ignored):
"""Generates bitstream specification of the fabric by calling
'genBitStreamspec' and saving the specification to a binary and CSV file.
Expand Down
2 changes: 1 addition & 1 deletion FABulous/geometry_generator/geometry_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def generateGeometry(self, padding: int = 8) -> None:

def saveToCSV(self, fileName: str) -> None:
"""Saves the generated geometry into a file specified by the given file name.
This file can then be imported into the FABulous Editor.
This file can then be imported into FABulator.
"""
self.fabricGeometry.saveToCSV(fileName)

0 comments on commit 3fe3e26

Please sign in to comment.