Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit177b06a

Browse files
committed
I believe this should fix the build.
1 parent1163854 commit177b06a

File tree

2 files changed

+88
-119
lines changed

2 files changed

+88
-119
lines changed

‎builder/__init__.py‎

Lines changed: 87 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -186,157 +186,126 @@ def _busy_spinner(evnt):
186186
wait=random.randint(10,100)*0.001
187187

188188

189-
defspawn(cmd_,out_to_screen=True,spinner=False,env=None,cmpl=False,unix=False):
189+
defspawn(cmd_,out_to_screen=True,spinner=False,env=None,cmpl=False):
190190
ifenvisNone:
191191
env=os.environ
192192

193-
ifsys.platform.startswith('win'):
194-
prompt=b'>'
195-
else:
196-
prompt=b'$'
197-
198193
ifisinstance(cmd_[0],str):
199194
cmd_=' '.join(cmd_)
200195
else:
201196
cmd_=' && '.join(' '.join(c)forcincmd_)
202197

203-
defread():
204-
output_buffer=b''
205-
line=''
206-
r_beg=False
207-
newline=False
208-
last_line_len=0
209-
whilep.poll()isNone:
210-
o_char=p.stdout.read(1)
211-
whileo_char!=b'':
212-
output_buffer+=o_char
213-
ifout_to_screenandnotspinnerandcmpl:
214-
ifo_char==b'\n':
215-
newline=True
216-
o_char=p.stdout.read(1)
217-
continue
218-
elifo_char==b'[':
219-
ifnewline:
220-
ifr_beg:
221-
sys.stdout.write('\r')
222-
sys.stdout.write(' '*last_line_len)
223-
sys.stdout.write('\r')
224-
sys.stdout.flush()
225-
else:
226-
sys.stdout.write('\n')
227-
sys.stdout.flush()
228-
r_beg=True
229-
230-
last_line_len=0
231-
newline=False
198+
p=subprocess.Popen(
199+
cmd_,
200+
stdout=subprocess.PIPE,
201+
stderr=subprocess.PIPE,
202+
shell=True,
203+
env=env
204+
)
232205

233-
else:
234-
r_beg=False
235-
236-
ifnewline:
237-
last_line_len=0
238-
newline=False
239-
sys.stdout.write('\n')
240-
sys.stdout.flush()
241-
r_beg=False
242-
243-
last_line_len+=1
244-
try:
245-
sys.stdout.write(o_char.decode('utf-8'))
246-
exceptUnicodeDecodeError:
247-
sys.stdout.write(str(o_char)[2:-1])
248-
sys.stdout.flush()
206+
os.set_blocking(p.stdout.fileno(),False)
207+
os.set_blocking(p.stderr.fileno(),False)
249208

250-
elifout_to_screenandnotcmpl:
251-
try:
252-
line+=o_char.decode('utf-8')
253-
exceptUnicodeDecodeError:
254-
line+=str(o_char)[2:-1]
209+
event=threading.Event()
255210

256-
ifo_char==b'\n':
257-
sys.stdout.write(line)
258-
line=''
259-
sys.stdout.flush()
211+
ifspinner:
212+
t=threading.Thread(target=_busy_spinner,args=(event,))
213+
t.daemon=True
214+
t.start()
215+
else:
216+
t=None
260217

261-
#output_buffer+= o_char
262-
o_char=p.stdout.read(1)
218+
output_buffer= []
219+
last_line_len=-1
263220

264-
e_char=p.stderr.read(1)
265-
whilee_char!=b'':
266-
ifout_to_screenandnotspinner:
267-
try:
268-
sys.stderr.write(e_char.decode('utf-8'))
269-
exceptUnicodeDecodeError:
270-
sys.stderr.write(str(o_char)[2:-1])
271-
sys.stderr.flush()
272-
output_buffer+=e_char
273-
e_char=p.stderr.read(1)
221+
def_convert_line(lne):
222+
try:
223+
lne=lne.decode('utf-8')
224+
exceptUnicodeDecodeError:
225+
forcharinlne:
226+
if32<=char<=125orcharin (b'\r',b'\n'):
227+
continue
274228

275-
ifoutput_buffer.endswith(prompt):
276-
break
229+
lne=lne.replace(char,b'')
230+
lne=lne.decode('utf-8')
277231

278-
ifnote_charandnoto_char:
279-
break
232+
returnlne
280233

281-
returnoutput_buffer
234+
try:
235+
whilep.poll()isNone:
236+
line=p.stdout.readline()
237+
iflineisnotNoneandline.strip():
238+
line=_convert_line(line.strip())
239+
output_buffer.append(line)
240+
241+
ifnotspinnerandout_to_screen:
242+
ifcmplandline.startswith('[')andlast_line_len!=-1:
243+
sys.stdout.write('\r')
244+
iflen(line)<last_line_len:
245+
padding=' '* (last_line_len-len(line))
246+
else:
247+
padding=''
282248

283-
ifunix:
284-
p=subprocess.Popen(
285-
cmd_,
286-
shell=True,
287-
env=env
288-
)
289-
p.communicate()
249+
sys.stdout.write(line+padding)
250+
last_line_len=len(line)
251+
else:
252+
last_line_len=-1
253+
sys.stdout.write(line+'\n')
290254

291-
returnp.returncode,None
292-
else:
293-
p=subprocess.Popen(
294-
cmd_,
295-
stdout=subprocess.PIPE,
296-
stderr=subprocess.PIPE,
297-
shell=True,
298-
env=env
299-
)
255+
sys.stdout.flush()
300256

301-
ifout_to_screen:
302-
print(cmd_)
257+
line=p.stderr.readline()
258+
whilelineisnotNoneandline.strip():
259+
ifnotspinnerandout_to_screenandcmplandlast_line_len!=-1:
260+
sys.stdout.write('\n')
261+
sys.stdout.flush()
262+
last_line_len=-1
303263

304-
event=threading.Event()
264+
line=_convert_line(line.strip())
265+
output_buffer.append(line)
305266

306-
ifspinner:
307-
t=threading.Thread(target=_busy_spinner,args=(event,))
308-
t.daemon=True
309-
t.start()
310-
else:
311-
t=None
267+
ifout_to_screenandnotspinner:
268+
sys.stderr.write(line+'\n')
269+
sys.stderr.flush()
312270

313-
o_buf=read()
271+
line=p.stderr.readline()
314272

315-
try:
316-
o_buf=o_buf.decode('utf-8')
317-
exceptUnicodeDecodeError:
318-
forcharino_buf:
319-
if32<=char<=125orcharin (b'\r',b'\n'):
320-
continue
321-
322-
o_buf=o_buf.replace(char,b'')
273+
exceptKeyboardInterrupt:
274+
iftisnotNone:
275+
event.set()
276+
t.join()
323277

324-
o_buf=o_buf.decode('utf-8')
278+
print()
279+
print(output_buffer)
325280

326281
ifnotp.stdout.closed:
327282
p.stdout.close()
328283

329284
ifnotp.stderr.closed:
330285
p.stderr.close()
331286

332-
iftisnotNone:
333-
event.set()
334-
t.join()
287+
raise
288+
289+
ifnotp.stdout.closed:
290+
p.stdout.close()
335291

336-
ifout_to_screenandspinner:
337-
print(o_buf)
292+
ifnotp.stderr.closed:
293+
p.stderr.close()
294+
295+
iftisnotNone:
296+
event.set()
297+
t.join()
298+
299+
output_buffer='\n'.join(output_buffer)
300+
301+
ifout_to_screen:
302+
ifspinner:
303+
print(output_buffer)
304+
elifcmplandlast_line_len!=-1:
305+
sys.stdout.write('\n')
306+
sys.stdout.flush()
338307

339-
returnp.returncode,o_buf
308+
returnp.returncode,output_buffer
340309

341310

342311
defclean():

‎builder/unix.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def compile(): # NOQA
178178
withopen(mpconfigvariant_common_path,'w')asf:
179179
f.write(mpconfigvariant_common)
180180

181-
return_code,_=spawn(compile_cmd,unix=True)
181+
return_code,_=spawn(compile_cmd)
182182
ifreturn_code!=0:
183183
sys.exit(return_code)
184184

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp