summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-09-16 01:06:50 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-09-16 01:06:50 +0100
commit96423b52302a01fa3a4922961bd8e072a5c46e15 (patch)
treed31bdfd6415b4dec2cd427024435ef2ce47669ac
parentd5f7286a28caf0a7f628c09b515e7ed59a1a85fb (diff)
bugfix :
* subprocess.Popen child processes can "sometimes" generate a very large output, causing a deadlock (**cough** dependency solver **cough**) * use subprocess.Popen.communicate instead of subprocess.Popen.wait to avoid such issues * see : https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait
-rw-r--r--src/backend/autoremove.py8
-rw-r--r--src/backend/binhost.py4
-rw-r--r--src/backend/ebuildinstall.py16
-rw-r--r--src/backend/ebuildupgrade.py16
-rw-r--r--src/backend/forceuninstall.py4
-rw-r--r--src/backend/install.py8
-rw-r--r--src/backend/solvedeps.py4
-rw-r--r--src/backend/uninstall.py8
-rw-r--r--src/backend/upgrade.py8
9 files changed, 38 insertions, 38 deletions
diff --git a/src/backend/autoremove.py b/src/backend/autoremove.py
index 5c2ee7a..37ae7ee 100644
--- a/src/backend/autoremove.py
+++ b/src/backend/autoremove.py
@@ -10,19 +10,19 @@ import sisyphus.killportage
def start():
if sisyphus.check.root():
- portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'])
- portageExec.wait()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
sisyphus.database.syncLocal()
else:
sys.exit("\nYou need root permissions to do this, exiting!\n")
def startqt():
- portageExec = subprocess.Popen(['emerge', '--depclean'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--depclean'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
# kill portage if the program dies or it's terminated by the user
atexit.register(sisyphus.killportage.start, portageExec)
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
diff --git a/src/backend/binhost.py b/src/backend/binhost.py
index 91a6e53..3de4fca 100644
--- a/src/backend/binhost.py
+++ b/src/backend/binhost.py
@@ -5,11 +5,11 @@ import subprocess
def start():
isBinhost = []
- portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--info', '--verbose'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if "PORTAGE_BINHOST" in portageOutput.rstrip():
isBinhost = str(portageOutput.rstrip().split("=")[1].strip('\"'))
- portageExec.wait()
return isBinhost
diff --git a/src/backend/ebuildinstall.py b/src/backend/ebuildinstall.py
index 11253c1..d194ac2 100644
--- a/src/backend/ebuildinstall.py
+++ b/src/backend/ebuildinstall.py
@@ -40,14 +40,14 @@ def start(pkgname):
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
@@ -73,33 +73,34 @@ def start(pkgname):
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
else:
print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + " ".join(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- portageExec = subprocess.Popen(['emerge', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
else:
- portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
@@ -107,7 +108,6 @@ def start(pkgname):
if not "binary" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
else:
sys.exit("\nYou need root permissions to do this, exiting!\n")
diff --git a/src/backend/ebuildupgrade.py b/src/backend/ebuildupgrade.py
index 2d4bc45..ae5d39b 100644
--- a/src/backend/ebuildupgrade.py
+++ b/src/backend/ebuildupgrade.py
@@ -40,14 +40,14 @@ def start():
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
@@ -73,33 +73,34 @@ def start():
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
else:
print("\n" + "These are the source packages that would be merged, in order:" + "\n\n" + " ".join(areSources) + "\n\n" + "Total:" + " " + str(len(areSources)) + " " + "source package(s)" + "\n")
if input("Would you like to proceed?" + " " + "[y/N]" + " ").lower().strip()[:1] == "y":
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
else:
- portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "Local copy of remote index is up-to-date and will be used." in portageOutput.rstrip():
@@ -107,7 +108,6 @@ def start():
if not "binary" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sys.exit("\n" + "Cannot proceed; Apply the above changes to your portage configuration files and try again; Quitting." + "\n")
else:
sys.exit("\nYou need root permissions to do this, exiting!\n")
diff --git a/src/backend/forceuninstall.py b/src/backend/forceuninstall.py
index b027004..9329695 100644
--- a/src/backend/forceuninstall.py
+++ b/src/backend/forceuninstall.py
@@ -7,8 +7,8 @@ import sisyphus.database
def start(pkgname):
if sisyphus.check.root():
- portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname))
- portageExec.wait()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--unmerge', '--ask'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
sisyphus.database.syncLocal()
else:
sys.exit("\nYou need root permissions to do this, exiting!\n")
diff --git a/src/backend/install.py b/src/backend/install.py
index f6aeb67..c9b2d67 100644
--- a/src/backend/install.py
+++ b/src/backend/install.py
@@ -42,14 +42,14 @@ def start(pkgname):
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
@@ -83,7 +83,8 @@ def startqt(pkgname):
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgname, stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
# kill portage if the program dies or it's terminated by the user
atexit.register(sisyphus.killportage.start, portageExec)
@@ -92,5 +93,4 @@ def startqt(pkgname):
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
diff --git a/src/backend/solvedeps.py b/src/backend/solvedeps.py
index 85d245a..f0af4c0 100644
--- a/src/backend/solvedeps.py
+++ b/src/backend/solvedeps.py
@@ -10,6 +10,7 @@ def package(pkgname):
areSources = []
needsConfig = int()
portageExec = subprocess.Popen(['emerge', '--quiet', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
@@ -33,7 +34,6 @@ def package(pkgname):
isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
areSources.append(isSource)
- portageExec.wait()
return areBinaries,areSources,needsConfig
@animation.wait('resolving dependencies')
@@ -42,6 +42,7 @@ def world():
areSources = []
needsConfig = int()
portageExec = subprocess.Popen(['emerge', '--quiet', '--update', '--deep', '--newuse', '--pretend', '--getbinpkg', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stderr, encoding="utf-8"):
if "The following keyword changes are necessary to proceed:" in portageOutput.rstrip():
@@ -65,5 +66,4 @@ def world():
isSource = str(portageOutput.rstrip().split("]")[1].split("[")[0].strip("\ "))
areSources.append(isSource)
- portageExec.wait()
return areBinaries,areSources,needsConfig
diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py
index 9d76067..b8981ca 100644
--- a/src/backend/uninstall.py
+++ b/src/backend/uninstall.py
@@ -10,19 +10,19 @@ import sisyphus.killportage
def start(pkgname):
if sisyphus.check.root():
- portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + list(pkgname))
- portageExec.wait()
+ portageExec = subprocess.Popen(['emerge', '--quiet', '--depclean', '--ask'] + list(pkgname), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
sisyphus.database.syncLocal()
else:
sys.exit("\nYou need root permissions to do this, exiting!\n")
def startqt(pkgname):
- portageExec = subprocess.Popen(['emerge', '--depclean'] + pkgname, stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--depclean'] + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
# kill portage if the program dies or it's terminated by the user
atexit.register(sisyphus.killportage.start, portageExec)
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py
index a6a540a..54fcd5c 100644
--- a/src/backend/upgrade.py
+++ b/src/backend/upgrade.py
@@ -42,14 +42,14 @@ def start():
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
if not "These are the packages that would be merged, in order:" in portageOutput.rstrip():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
sys.exit("\n" + "Ok; Quitting." + "\n")
@@ -87,7 +87,8 @@ def startqt():
if os.path.exists(binary.rstrip().split("/")[1]):
os.remove(binary.rstrip().split("/")[1])
- portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE)
+ portageExec = subprocess.Popen(['emerge', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--backtrack=100', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n', '@world'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = portageExec.communicate()
# kill portage if the program dies or it's terminated by the user
atexit.register(sisyphus.killportage.start, portageExec)
@@ -96,7 +97,6 @@ def startqt():
if not "Calculating dependencies" in portageOutput.rstrip():
print(portageOutput.rstrip())
- portageExec.wait()
sisyphus.database.syncLocal()
else:
print("\n" + "No package upgrades found; Quitting." + "\n")