Skip to content

Commit

Permalink
add check to sim.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Jun 14, 2024
1 parent a179976 commit ad95a11
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
logs_and_video/
*.pyc
downloads*
downloads*
logs/
5 changes: 4 additions & 1 deletion scripts/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def check_submodules() -> None:
logging.error("submodules not exist. Run: 'git submodule update --init --recursive'")
sys.exit(1)

if __name__ == "__main__":
def check() -> None:
check_python_requirements()
check_submodules()

if __name__ == "__main__":
check()
7 changes: 6 additions & 1 deletion scripts/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
from command import SimCommand
from docker_wrapper import DockerWrapper
from model import SimModel
import check

REPO_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
VEHICLES_DIR = os.path.join(REPO_DIR, "configs", "vehicles")
BINARY_OUTPUT_PATH = os.path.join(REPO_DIR, "firmware.bin")
LOG_FILENAME = f"log_{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
LOG_PATH = os.path.join(REPO_DIR, "logs", LOG_FILENAME)
LOGS_DIR = os.path.join(REPO_DIR, "logs")
LOG_PATH = os.path.join(LOGS_DIR, LOG_FILENAME)

COMMANDS = [
SimCommand(name="build", alias='b', mode=None, info="Build the Docker image"),
Expand Down Expand Up @@ -79,6 +81,7 @@ def _kill(self) -> None:
DockerWrapper.kill_container_by_id(self._model.docker_info.id)

def _build(self) -> None:
check.check()
DockerWrapper.build(self._model.full_image_name)

class SimView:
Expand Down Expand Up @@ -107,6 +110,8 @@ def process(self, command: Optional[str]) -> None:


def main():
if not os.path.exists(LOGS_DIR):
os.makedirs(LOGS_DIR)
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
filename=LOG_PATH,
Expand Down

0 comments on commit ad95a11

Please sign in to comment.