Моя текущая проблема - я создаю приложение с python и HTML для использования форм HTML для сбора данных, которые затем превращаются в переменную в Python, а затем я использую подпроцесс POPEN для отправки Команда Azure CLI для azure арендатора. Когда я использую следующий код для команды, она возвращает ошибку.
Python Код
@app.route('/storageaccountcreate', methods = ['POST'])
def storageaccountcreate():
name = request.form['storageaccountname']
resourcegroup = request.form['resourcegroup']
subscription = request.form['subscription']
location = request.form['location']
sku = request.form['sku']
cmd = f"az storage account create -n {name} -g {resourcegroup} --subscription {subscription} -l {location} --sku {sku}"
#This is where the command is initiated using subprocess
command = Popen(cmd)
text = command.stdout.read().decode("ascii")
print(text)
with open("file.txt","w") as f:
f.write(text)
return (cmd)
Ошибка
[2020-04-06 19:36:46,828] ERROR in app: Exception on /storageaccountcreate [POST]
Traceback (most recent call last):
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\Users\PP284QZ\Desktop\repo\ms-identity-python-webapp-master\app.py", line 67, in storageaccountcreate
command = Popen(cmd)
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\PP284QZ\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
File "c:\Users\PP284QZ\.vscode\extensions\ms-python.python-2020.3.71659\pythonFiles\lib\python\debugpy\no_wheels\debugpy\_vendored\pydevd\_pydev_bundle\pydev_monkey.py", line 631, in new_CreateProcess
return getattr(_subprocess, original_name)(app_name, cmd_line, *args)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Кто-нибудь знает, что я здесь не так делаю? Заранее спасибо!