-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(html_parser,simple_webdriver): 1、新增html_parser和simple_webdriver模…
…块;2、将affinity纳入源码,避免手工修改操作;
- Loading branch information
lhj
authored and
lhj
committed
Jul 15, 2021
1 parent
4490509
commit 5f58502
Showing
12 changed files
with
1,595 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Enfold Enterprise Server | ||
# Copyright(C), 2004-5, Enfold Systems, LLC - ALL RIGHTS RESERVED | ||
|
||
# Enfold Systems, LLC | ||
# 4617 Montrose Blvd., Suite C215 | ||
# Houston, Texas 77006 USA | ||
# p. +1 713.942.2377 | f. +1 832.201.8856 | ||
# www.enfoldsystems.com | ||
# info@enfoldsystems.com | ||
|
||
import sys | ||
|
||
if sys.platform in ('win32',): | ||
# Use win32process from pywin32 | ||
import win32api | ||
import win32con | ||
import win32process | ||
import pywintypes | ||
|
||
def _get_handle_for_pid(pid, ro=True): | ||
if pid == 0: | ||
pHandle = win32process.GetCurrentProcess() | ||
else: | ||
flags = win32con.PROCESS_QUERY_INFORMATION | ||
if not ro: | ||
flags |= win32con.PROCESS_SET_INFORMATION | ||
try: | ||
pHandle = win32api.OpenProcess(flags, 0, pid) | ||
except pywintypes.error as e: | ||
raise ValueError | ||
return pHandle | ||
|
||
def set_process_affinity_mask(pid, value): | ||
pHandle = _get_handle_for_pid(pid, False) | ||
current = win32process.GetProcessAffinityMask(pHandle)[0] | ||
try: | ||
win32process.SetProcessAffinityMask(pHandle, value) | ||
except win32process.error as e: | ||
raise ValueError | ||
return current | ||
|
||
def get_process_affinity_mask(pid): | ||
pHandle = _get_handle_for_pid(pid) | ||
try: | ||
return win32process.GetProcessAffinityMask(pHandle)[0] | ||
except win32process.error as e: | ||
raise ValueError | ||
|
||
elif sys.platform in ('linux2'): | ||
from _affinity import set_process_affinity_mask, get_process_affinity_mask | ||
|
||
else: | ||
def set_process_affinity_mask(pid, value): | ||
raise NotImplementedError | ||
|
||
def get_process_affinity_mask(pid): | ||
raise NotImplementedError |
Oops, something went wrong.