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 13:31:27 +0200
committerGitHub <noreply@github.com>2021-06-10 13:31:27 +0200
commit5ae3d11ab2b248181ec403641d376f3467028ab8 (patch)
treeeeb9a763859bca8dc27a67ba96a4e289bb1a17ae /archinstall/lib/general.py
parentdc10725bf93e4259fb2be030221cbe3a0527f85b (diff)
parent434ebb3419f6d614c753729498337abb738481be (diff)
Merge pull request #537 from archlinux/torxed-fix-517
Introduces the use of HTTP mirrors additionally
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 831b5451..b9dc66ab 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
@@ -231,6 +258,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)