Use system for terminal if it is allowed to
This commit is contained in:
parent
d79a1236a0
commit
15bd4335e8
@ -18,10 +18,15 @@ class terminal(Vte.Terminal):
|
|||||||
pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT, None)
|
pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT, None)
|
||||||
|
|
||||||
self.set_pty(pty)
|
self.set_pty(pty)
|
||||||
|
|
||||||
|
env = {
|
||||||
|
"TERM": "xterm-256color"
|
||||||
|
}
|
||||||
|
|
||||||
pty.spawn_async(
|
pty.spawn_async(
|
||||||
GLib.get_current_dir(),
|
GLib.get_current_dir(),
|
||||||
script,
|
script,
|
||||||
[],
|
[f"{key}={value}" for key, value in env.items()],
|
||||||
GLib.SpawnFlags.DEFAULT,
|
GLib.SpawnFlags.DEFAULT,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -437,13 +437,24 @@ def run_script_response(self, dialog, task, script, language_name):
|
|||||||
else:
|
else:
|
||||||
with open(os.path.join(data_dir, 'pyenv', 'requirements.txt'), 'w') as f:
|
with open(os.path.join(data_dir, 'pyenv', 'requirements.txt'), 'w') as f:
|
||||||
f.write('')
|
f.write('')
|
||||||
print(script)
|
|
||||||
script = ';\n'.join(script)
|
script = ';\n'.join(script)
|
||||||
|
|
||||||
script += '; echo "\n🦙 {}"'.format(_('Script exited'))
|
script += '; echo "\n🦙 {}"'.format(_('Script exited'))
|
||||||
|
if language_name == 'bash':
|
||||||
|
script = script.replace('sudo ', 'pkexec ')
|
||||||
if shutil.which('flatpak-spawn') and language_name == 'bash':
|
if shutil.which('flatpak-spawn') and language_name == 'bash':
|
||||||
|
sandbox = True
|
||||||
|
try:
|
||||||
|
process = subprocess.run(['flatpak-spawn', '--host', 'bash', '-c', 'echo "test"'], check=True)
|
||||||
|
sandbox = False
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
if sandbox:
|
||||||
script = 'echo "🦙 {}\n";'.format(_('The script is contained inside Flatpak')) + script
|
script = 'echo "🦙 {}\n";'.format(_('The script is contained inside Flatpak')) + script
|
||||||
|
self.run_terminal(['bash', '-c', script])
|
||||||
|
else:
|
||||||
|
self.run_terminal(['flatpak-spawn', '--host', 'bash', '-c', script])
|
||||||
|
else:
|
||||||
self.run_terminal(['bash', '-c', script])
|
self.run_terminal(['bash', '-c', script])
|
||||||
|
|
||||||
def run_script(self, script:str, language_name:str):
|
def run_script(self, script:str, language_name:str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user