我有下面的代碼,我有一個用戶名列表,我嘗試和檢查,如果用戶使用net user \domain | find somegroup
是在一個特定的Windows用戶組。如何進行未來調用並等到Python完成?
的問題是,我可以針對每個用戶名約8羣組該命令,它是緩慢的。我想用期貨發送這些電話,甚至分開線程(如果它使速度更快)。
我只需要在年底前等待我做別的。我如何着手在Python中做這件事?
for one_username in user_list:
response = requests.get(somecontent)
bs_parsed = BeautifulSoup(response.content, 'html.parser')
find_all2 = bs_parsed.find("div", {"class": "QuickLinks"})
name = re.sub("\s\s+", ' ', find_all2.find("td", text="Name").find_next_sibling("td").text)
find_all = bs_parsed.find_all("div", {"class": "visible"})
all_perms = ""
d.setdefault(one_username + " (" + name + ")", [])
for value in find_all:
test = value.find("a", {"onmouseover": True})
if test is not None:
if "MyAppID" in test.text:
d[one_username + " (" + name + ")"].append(test.text)
for group in groups:
try:
d[one_username + " (" + name + ")"].append(check_output("net user /domain " + one_username + "| find \"" + group + "\"", shell=True, stderr=subprocess.STDOUT).strip().decode("utf-8"))
except Exception:
pass