From 04553e045561f55735c7d98e38bb2a2b0455354f Mon Sep 17 00:00:00 2001 From: CHEN FENG Date: Fri, 22 Sep 2023 16:49:08 +0800 Subject: [PATCH] At least --help works --- blade.bat | 6 ++++++ src/blade/test_scheduler.py | 2 +- src/blade/toolchain.py | 2 +- src/blade/util.py | 19 +++++++++++++------ 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 blade.bat diff --git a/blade.bat b/blade.bat new file mode 100644 index 00000000..3fe0051f --- /dev/null +++ b/blade.bat @@ -0,0 +1,6 @@ +@echo off + +set python=python.exe +set blade_file=%~dp0src + +%python% %blade_file% %* diff --git a/src/blade/test_scheduler.py b/src/blade/test_scheduler.py index 29b1a0b6..98c187eb 100644 --- a/src/blade/test_scheduler.py +++ b/src/blade/test_scheduler.py @@ -36,7 +36,7 @@ def _signal_map(): if not name.startswith('SIG') or name.startswith('SIG_'): continue # SIGIOT and SIGABRT has the same value under linux and mac, but SIGABRT is more common. - if signal.SIGABRT == signal.SIGIOT and name == 'SIGIOT': + if name == 'SIGIOT' and signal.SIGABRT == signal.SIGIOT: continue result[-getattr(signal, name)] = name diff --git a/src/blade/toolchain.py b/src/blade/toolchain.py index 1ba1930d..303c07be 100644 --- a/src/blade/toolchain.py +++ b/src/blade/toolchain.py @@ -34,7 +34,7 @@ class BuildArchitecture(object): 'bits': '32', }, 'x86_64': { - 'alias': ['amd64'], + 'alias': ['amd64', 'x64'], 'bits': '64', 'models': { '32': 'i386', diff --git a/src/blade/util.py b/src/blade/util.py index 0f8ff0d6..05ef1c7e 100644 --- a/src/blade/util.py +++ b/src/blade/util.py @@ -17,7 +17,6 @@ import ast import errno -import fcntl import hashlib import inspect import json @@ -28,6 +27,10 @@ import sys import zipfile +try: + import fcntl +except ImportError: + fcntl = None _IN_PY3 = sys.version_info[0] == 3 @@ -74,10 +77,11 @@ def md5sum(obj): def lock_file(filename): """lock file.""" try: - fd = os.open(filename, os.O_CREAT | os.O_RDWR) - old_fd_flags = fcntl.fcntl(fd, fcntl.F_GETFD) - fcntl.fcntl(fd, fcntl.F_SETFD, old_fd_flags | fcntl.FD_CLOEXEC) - fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + fd = os.open(filename, os.O_CREAT | os.O_RDWR | os.O_EXCL) + if fcntl: + old_fd_flags = fcntl.fcntl(fd, fcntl.F_GETFD) + fcntl.fcntl(fd, fcntl.F_SETFD, old_fd_flags | fcntl.FD_CLOEXEC) + fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) return fd, 0 except IOError as ex_value: return -1, ex_value.errno @@ -86,7 +90,8 @@ def lock_file(filename): def unlock_file(fd): """unlock file.""" try: - fcntl.flock(fd, fcntl.LOCK_UN) + if fcntl: + fcntl.flock(fd, fcntl.LOCK_UN) os.close(fd) except IOError: pass @@ -134,6 +139,8 @@ def get_cwd(): So in practice we simply use system('pwd') to get current working directory. """ + if os.name == 'nt': + return os.getcwd() p = subprocess.Popen(['pwd'], stdout=subprocess.PIPE, shell=True) return to_string(p.communicate()[0].strip())