Mercurial > hg
comparison mercurial/win32.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 9f70512ae2cf |
children | 65f437c240f2 |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
383 finally: | 383 finally: |
384 _kernel32.CloseHandle(fh) | 384 _kernel32.CloseHandle(fh) |
385 | 385 |
386 | 386 |
387 def checkcertificatechain(cert, build=True): | 387 def checkcertificatechain(cert, build=True): |
388 '''Tests the given certificate to see if there is a complete chain to a | 388 """Tests the given certificate to see if there is a complete chain to a |
389 trusted root certificate. As a side effect, missing certificates are | 389 trusted root certificate. As a side effect, missing certificates are |
390 downloaded and installed unless ``build=False``. True is returned if a | 390 downloaded and installed unless ``build=False``. True is returned if a |
391 chain to a trusted root exists (even if built on the fly), otherwise | 391 chain to a trusted root exists (even if built on the fly), otherwise |
392 False. NB: A chain to a trusted root does NOT imply that the certificate | 392 False. NB: A chain to a trusted root does NOT imply that the certificate |
393 is valid. | 393 is valid. |
394 ''' | 394 """ |
395 | 395 |
396 chainctxptr = ctypes.POINTER(CERT_CHAIN_CONTEXT) | 396 chainctxptr = ctypes.POINTER(CERT_CHAIN_CONTEXT) |
397 | 397 |
398 pchainctx = chainctxptr() | 398 pchainctx = chainctxptr() |
399 chainpara = CERT_CHAIN_PARA( | 399 chainpara = CERT_CHAIN_PARA( |
486 err = _kernel32.GetLastError() | 486 err = _kernel32.GetLastError() |
487 return err == _ERROR_BROKEN_PIPE or err == _ERROR_NO_DATA | 487 return err == _ERROR_BROKEN_PIPE or err == _ERROR_NO_DATA |
488 | 488 |
489 | 489 |
490 def testpid(pid): | 490 def testpid(pid): |
491 '''return True if pid is still running or unable to | 491 """return True if pid is still running or unable to |
492 determine, False otherwise''' | 492 determine, False otherwise""" |
493 h = _kernel32.OpenProcess(_PROCESS_QUERY_INFORMATION, False, pid) | 493 h = _kernel32.OpenProcess(_PROCESS_QUERY_INFORMATION, False, pid) |
494 if h: | 494 if h: |
495 try: | 495 try: |
496 status = _DWORD() | 496 status = _DWORD() |
497 if _kernel32.GetExitCodeProcess(h, ctypes.byref(status)): | 497 if _kernel32.GetExitCodeProcess(h, ctypes.byref(status)): |
574 | 574 |
575 _signalhandler = [] | 575 _signalhandler = [] |
576 | 576 |
577 | 577 |
578 def setsignalhandler(): | 578 def setsignalhandler(): |
579 '''Register a termination handler for console events including | 579 """Register a termination handler for console events including |
580 CTRL+C. python signal handlers do not work well with socket | 580 CTRL+C. python signal handlers do not work well with socket |
581 operations. | 581 operations. |
582 ''' | 582 """ |
583 | 583 |
584 def handler(event): | 584 def handler(event): |
585 _kernel32.ExitProcess(1) | 585 _kernel32.ExitProcess(1) |
586 | 586 |
587 if _signalhandler: | 587 if _signalhandler: |
625 height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1 | 625 height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1 |
626 return width, height | 626 return width, height |
627 | 627 |
628 | 628 |
629 def enablevtmode(): | 629 def enablevtmode(): |
630 '''Enable virtual terminal mode for the associated console. Return True if | 630 """Enable virtual terminal mode for the associated console. Return True if |
631 enabled, else False.''' | 631 enabled, else False.""" |
632 | 632 |
633 ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 | 633 ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 |
634 | 634 |
635 handle = _kernel32.GetStdHandle( | 635 handle = _kernel32.GetStdHandle( |
636 _STD_OUTPUT_HANDLE | 636 _STD_OUTPUT_HANDLE |