【发布时间】:2020-08-27 16:11:57
【问题描述】:
我在这个设置中卡住了将近一个星期。希望有人能指导我。
设置
-
我已经设置了一个运行 Flask python 代码的 IIS 服务器。 (使用 wfastcgi.py )
-
我已将应用程序池标识配置为我自己的帐户。 (管理员权限)
-
我已将此 Web 部署所需的所有文件权限更改为“所有人” - 完全控制(读取、写入、执行)。 (我了解安全风险,这是我的暂存环境。)
-
Web 服务器运行良好,我使用底部代码检查知道我的 python 权限是管理员。
def am_i_admin(): try: is_admin = os.getuid() == 0 except AttributeError: is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 if is_admin == True: return "ADMIN" else: return "USER"
问题陈述
-
我正在尝试在我的烧瓶 IIS 服务器上运行管理员 priv 代码,该代码允许同一网络中的用户执行;比如
subprocess.run(['ipconfig'], stdout=subprocess.PIPE) pyautogui.screenshot() #which take a screenshot of the web server and send over to the client. -
我在本地的 jupyter notebook 上运行,上面的功能运行良好。
-
但它在 IIS 烧瓶服务器上运行失败。
-
我也尝试在烧瓶服务器上设置 pyautogui(没有 IIS 的独立),它工作正常。
-
IIS 服务器有什么问题??或者还有更多我需要配置的东西。是否有我可以禁用的安全功能?
子流程错误信息:
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\my_app.py", line 58, in <module>
out = os.popen("ipconfig").read()
File "c:\users\aspnet\anaconda3\lib\os.py", line 990, in popen
bufsize=buffering)
File "c:\users\aspnet\anaconda3\lib\subprocess.py", line 753, in __init__
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "c:\users\aspnet\anaconda3\lib\subprocess.py", line 1090, in _get_handles
errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE)
OSError: [WinError 6] The handle is invalid
StdOut:
StdErr:
pyautogui 错误:
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\my_app.py", line 45, in <module>
pyautogui.screenshot()
File "c:\users\aspnet\anaconda3\lib\site-packages\pyscreeze\__init__.py", line 135, in wrapper
return wrappedFunction(*args, **kwargs)
File "c:\users\aspnet\anaconda3\lib\site-packages\pyscreeze\__init__.py", line 427, in _screenshot_win32
im = ImageGrab.grab()
File "c:\users\aspnet\anaconda3\lib\site-packages\PIL\ImageGrab.py", line 44, in grab
include_layered_windows, all_screens
OSError: screen grab failed
StdOut:
StdErr:
【问题讨论】: