summaryrefslogtreecommitdiff
path: root/src/backend/solvedeps.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-04-08 22:11:40 +0100
committerV3n3RiX <venerix@koprulu.sector>2023-04-08 22:11:40 +0100
commitfa19c308af220472681849a86e883094e38ee4cc (patch)
tree8e741484a75c2bb23871226c52f345627dbc9e4a /src/backend/solvedeps.py
parentb359e187fc12c76c3d941b0f1f4b7a48e538cccd (diff)
solvedeps : make sure it stops with keyboard interrupt
Diffstat (limited to 'src/backend/solvedeps.py')
-rw-r--r--src/backend/solvedeps.py59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/backend/solvedeps.py b/src/backend/solvedeps.py
index d388196..3f2053d 100644
--- a/src/backend/solvedeps.py
+++ b/src/backend/solvedeps.py
@@ -3,10 +3,19 @@
import animation
import os
import pickle
+import signal
import subprocess
+import sys
import sisyphus.getfs
+def sigint_handler(signal, frame):
+ sys.exit(0)
+
+
+signal.signal(signal.SIGINT, sigint_handler)
+
+
@animation.wait('resolving dependencies')
def start(pkgname=None):
bin_list = []
@@ -22,28 +31,36 @@ def start(pkgname=None):
p_exe = subprocess.Popen(
['emerge'] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = p_exe.communicate()
+ try:
+ stdout, stderr = p_exe.communicate()
- for p_out in stderr.decode('utf-8').splitlines():
- if any(key in p_out for key in ["The following keyword changes are necessary to proceed:",
- "The following mask changes are necessary to proceed:",
- "The following USE changes are necessary to proceed:",
- "The following REQUIRED_USE flag constraints are unsatisfied:",
- "One of the following masked packages is required to complete your request:"]):
- need_cfg = int(1)
+ for p_out in stderr.decode('utf-8').splitlines():
+ if any(key in p_out for key in ["The following keyword changes are necessary to proceed:",
+ "The following mask changes are necessary to proceed:",
+ "The following USE changes are necessary to proceed:",
+ "The following REQUIRED_USE flag constraints are unsatisfied:",
+ "One of the following masked packages is required to complete your request:"]):
+ need_cfg = int(1)
- for p_out in stdout.decode('utf-8').splitlines():
- if "[binary" in p_out:
- is_bin = p_out.split("]")[1].split("[")[0].strip(" ")
- bin_list.append(is_bin)
+ for p_out in stdout.decode('utf-8').splitlines():
+ if "[binary" in p_out:
+ is_bin = p_out.split("]")[1].split("[")[0].strip(" ")
+ bin_list.append(is_bin)
- if "[ebuild" in p_out:
- is_src = p_out.split("]")[1].split("[")[0].strip(" ")
- src_list.append(is_src)
+ if "[ebuild" in p_out:
+ is_src = p_out.split("]")[1].split("[")[0].strip(" ")
+ src_list.append(is_src)
- if pkgname:
- pickle.dump([bin_list, src_list, need_cfg], open(os.path.join(
- sisyphus.getfs.p_mtd_dir, "sisyphus_pkgdeps.pickle"), "wb"))
- else:
- pickle.dump([bin_list, src_list, need_cfg], open(os.path.join(
- sisyphus.getfs.p_mtd_dir, "sisyphus_worlddeps.pickle"), "wb"))
+ if pkgname:
+ pickle.dump([bin_list, src_list, need_cfg], open(os.path.join(
+ sisyphus.getfs.p_mtd_dir, "sisyphus_pkgdeps.pickle"), "wb"))
+ else:
+ pickle.dump([bin_list, src_list, need_cfg], open(os.path.join(
+ sisyphus.getfs.p_mtd_dir, "sisyphus_worlddeps.pickle"), "wb"))
+ except KeyboardInterrupt:
+ p_exe.terminate()
+ try:
+ p_exe.wait(1)
+ except subprocess.TimeoutExpired:
+ p_exe.kill()
+ sys.exit()