support msys2-python

This commit is contained in:
ed 2021-04-21 18:28:44 +02:00
parent 04f1b2cf3a
commit e4801d9b06
5 changed files with 13 additions and 10 deletions

View file

@ -16,6 +16,8 @@ if platform.system() == "Windows":
VT100 = not WINDOWS or WINDOWS >= [10, 0, 14393] VT100 = not WINDOWS or WINDOWS >= [10, 0, 14393]
# introduced in anniversary update # introduced in anniversary update
ANYWIN = WINDOWS or sys.platform in ["msys"]
MACOS = platform.system() == "Darwin" MACOS = platform.system() == "Darwin"

View file

@ -13,7 +13,7 @@ import ctypes
from datetime import datetime from datetime import datetime
import calendar import calendar
from .__init__ import E, PY2, WINDOWS from .__init__ import E, PY2, WINDOWS, ANYWIN
from .util import * # noqa # pylint: disable=unused-wildcard-import from .util import * # noqa # pylint: disable=unused-wildcard-import
from .szip import StreamZip from .szip import StreamZip
from .star import StreamTar from .star import StreamTar
@ -626,7 +626,7 @@ class HttpCli(object):
self.loud_reply(x, status=500) self.loud_reply(x, status=500)
return False return False
if not WINDOWS and num_left == 0: if not ANYWIN and num_left == 0:
times = (int(time.time()), int(lastmod)) times = (int(time.time()), int(lastmod))
self.log("no more chunks, setting times {}".format(times)) self.log("no more chunks, setting times {}".format(times))
try: try:

View file

@ -16,7 +16,7 @@ import traceback
import subprocess as sp import subprocess as sp
from copy import deepcopy from copy import deepcopy
from .__init__ import WINDOWS from .__init__ import WINDOWS, ANYWIN
from .util import ( from .util import (
Pebkac, Pebkac,
Queue, Queue,
@ -79,7 +79,7 @@ class Up2k(object):
if self.sqlite_ver < (3, 9): if self.sqlite_ver < (3, 9):
self.no_expr_idx = True self.no_expr_idx = True
if WINDOWS: if ANYWIN:
# usually fails to set lastmod too quickly # usually fails to set lastmod too quickly
self.lastmod_q = Queue() self.lastmod_q = Queue()
thr = threading.Thread(target=self._lastmodder) thr = threading.Thread(target=self._lastmodder)
@ -1110,7 +1110,7 @@ class Up2k(object):
atomic_move(src, dst) atomic_move(src, dst)
if WINDOWS: if ANYWIN:
self.lastmod_q.put([dst, (int(time.time()), int(job["lmod"]))]) self.lastmod_q.put([dst, (int(time.time()), int(job["lmod"]))])
# legit api sware 2 me mum # legit api sware 2 me mum

View file

@ -16,7 +16,7 @@ import mimetypes
import contextlib import contextlib
import subprocess as sp # nosec import subprocess as sp # nosec
from .__init__ import PY2, WINDOWS from .__init__ import PY2, WINDOWS, ANYWIN
from .stolen import surrogateescape from .stolen import surrogateescape
FAKE_MP = False FAKE_MP = False
@ -580,8 +580,8 @@ def sanitize_fn(fn, ok=""):
if "/" not in ok: if "/" not in ok:
fn = fn.replace("\\", "/").split("/")[-1] fn = fn.replace("\\", "/").split("/")[-1]
if WINDOWS: if ANYWIN:
for bad, good in [x for x in [ remap = [
["<", ""], ["<", ""],
[">", ""], [">", ""],
[":", ""], [":", ""],
@ -591,7 +591,8 @@ def sanitize_fn(fn, ok=""):
["|", ""], ["|", ""],
["?", ""], ["?", ""],
["*", ""], ["*", ""],
] if x[0] not in ok]: ]
for bad, good in [x for x in remap if x[0] not in ok]:
fn = fn.replace(bad, good) fn = fn.replace(bad, good)
bad = ["con", "prn", "aux", "nul"] bad = ["con", "prn", "aux", "nul"]

View file

@ -26,7 +26,7 @@ CKSUM = None
STAMP = None STAMP = None
PY2 = sys.version_info[0] == 2 PY2 = sys.version_info[0] == 2
WINDOWS = sys.platform == "win32" WINDOWS = sys.platform in ["win32", "msys"]
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
me = os.path.abspath(os.path.realpath(__file__)) me = os.path.abspath(os.path.realpath(__file__))
cpp = None cpp = None