Skip to content

Commit

Permalink
At least --help works
Browse files Browse the repository at this point in the history
  • Loading branch information
chen3feng committed Sep 22, 2023
1 parent 315b21c commit 04553e0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions blade.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off

set python=python.exe
set blade_file=%~dp0src

%python% %blade_file% %*
2 changes: 1 addition & 1 deletion src/blade/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/blade/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BuildArchitecture(object):
'bits': '32',
},
'x86_64': {
'alias': ['amd64'],
'alias': ['amd64', 'x64'],
'bits': '64',
'models': {
'32': 'i386',
Expand Down
19 changes: 13 additions & 6 deletions src/blade/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import ast
import errno
import fcntl
import hashlib
import inspect
import json
Expand All @@ -28,6 +27,10 @@
import sys
import zipfile

try:
import fcntl
except ImportError:
fcntl = None

_IN_PY3 = sys.version_info[0] == 3

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit 04553e0

Please sign in to comment.