Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-06-10 15:27:02 +0200
committerAnton Hvornum <anton@hvornum.se>2021-06-10 15:27:02 +0200
commit0946b73095dffe343f3ee8f622a565b77a6e8871 (patch)
tree116f2cddb95712aa0b11f2e9c6b0f43303840a3d /archinstall/lib/general.py
parente8d38ea1a75a33d820ac32c995a80c1bc833a44d (diff)
parentfcd0acfef261ad83f0d470957f94e6b046f66411 (diff)
Merging in latest changes from master.
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 6bb3b101..4d3257ba 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -2,14 +2,41 @@ import hashlib
import json
import logging
import os
-import pty
import shlex
import subprocess
import sys
import time
from datetime import datetime, date
-from select import epoll, EPOLLIN, EPOLLHUP
from typing import Union
+try:
+ from select import epoll, EPOLLIN, EPOLLHUP
+except:
+ import select
+ EPOLLIN = 0
+ EPOLLHUP = 0
+ class epoll():
+ """ #!if windows
+ Create a epoll() implementation that simulates the epoll() behavior.
+ This so that the rest of the code doesn't need to worry weither we're using select() or epoll().
+ """
+ def __init__(self):
+ self.sockets = {}
+ self.monitoring = {}
+
+ def unregister(self, fileno, *args, **kwargs):
+ try:
+ del(self.monitoring[fileno])
+ except:
+ pass
+
+ def register(self, fileno, *args, **kwargs):
+ self.monitoring[fileno] = True
+
+ def poll(self, timeout=0.05, *args, **kwargs):
+ try:
+ return [[fileno, 1] for fileno in select.select(list(self.monitoring.keys()), [], [], timeout)[0]]
+ except OSError:
+ return []
from .exceptions import *
from .output import log
@@ -203,27 +230,6 @@ class SysCommandWorker:
except UnicodeDecodeError:
return False
- output = output.strip('\r\n ')
- if len(output) <= 0:
- return False
-
- from .user_interaction import get_terminal_width
-
- # Move back to the beginning of the terminal
- sys.stdout.flush()
- sys.stdout.write("\033[%dG" % 0)
- sys.stdout.flush()
-
- # Clear the line
- sys.stdout.write(" " * get_terminal_width())
- sys.stdout.flush()
-
- # Move back to the beginning again
- sys.stdout.flush()
- sys.stdout.write("\033[%dG" % 0)
- sys.stdout.flush()
-
- # And print the new output we're peaking on:
sys.stdout.write(output)
sys.stdout.flush()
return True
@@ -253,6 +259,8 @@ class SysCommandWorker:
self.exit_code = 1
def execute(self) -> bool:
+ import pty
+
if (old_dir := os.getcwd()) != self.working_directory:
os.chdir(self.working_directory)