Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python virtual environment #3305

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[supervision] open terminal in the venv if it exists.
  • Loading branch information
Fabien-B authored and Fabien-B committed Oct 14, 2024
commit 3d7bd0c39f27ef0932a6576a2d7e85fcc5966556
19 changes: 19 additions & 0 deletions conf/system/term_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

source ~/.profile

if [ -d "$PAPARAZZI_HOME/pprzEnv" ]; then
source $PAPARAZZI_HOME/pprzEnv/bin/activate
fi

shell=$(echo $SHELL | cut -d / -f 3)

if [ "$shell" = "bash" ]; then
# enter bash specific commands here
echo $shell > /dev/null
elif [ "$shell" = "zsh" ]; then
# enter zsh specific commands here
echo $shell > /dev/null
else
# fallback commands
echo $shell > /dev/null
fi;
7 changes: 6 additions & 1 deletion sw/supervision/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ def get_build_version() -> str:
version = f.readline().strip()
return version

def get_shell():
p = subprocess.run(['getent', 'passwd', os.getenv('LOGNAME')], capture_output=True)
shell = p.stdout.decode().strip().split(':')[6]
return shell

def open_terminal(wd):
terminal_emulator = get_settings().value("terminal_emulator", "", str)
if terminal_emulator == "":
terminal_emulator = "x-terminal-emulator"
subprocess.Popen([terminal_emulator], cwd=wd)
shell = get_shell()
subprocess.Popen([terminal_emulator, '-e', shell, '--rcfile', 'conf/system/term_init.sh'], cwd=wd)

def get_settings() -> QSettings:
return QSettings(os.path.join(CONF_DIR, "pprz_center_settings.ini"), QSettings.IniFormat)
Expand Down