Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,43 +3,26 @@ import subprocess
|
|
| 3 |
|
| 4 |
def install_package(package_name):
|
| 5 |
command = f"pip install {package_name}"
|
| 6 |
-
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
else:
|
| 11 |
-
return False, stderr.decode()
|
| 12 |
|
| 13 |
def main():
|
| 14 |
st.title("Пакетный менеджер")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
submit_button = st.form_submit_button("Выполнить")
|
| 19 |
|
| 20 |
-
|
| 21 |
-
if
|
| 22 |
-
package_name =
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
else:
|
| 27 |
-
st.error(f"Ошибка при установке пакета '{package_name}':\n{output}")
|
| 28 |
-
|
| 29 |
-
st.subheader("Консоль")
|
| 30 |
-
|
| 31 |
-
console_output = st.empty()
|
| 32 |
|
| 33 |
if st.button("Очистить"):
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
if st.button("Выполнить"):
|
| 37 |
-
command = console_output.text_area("Введите команду", key="console_input")
|
| 38 |
-
if command:
|
| 39 |
-
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 40 |
-
stdout, stderr = process.communicate()
|
| 41 |
-
output = stdout.decode() + stderr.decode()
|
| 42 |
-
console_output.text(output)
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
main()
|
|
|
|
| 3 |
|
| 4 |
def install_package(package_name):
|
| 5 |
command = f"pip install {package_name}"
|
| 6 |
+
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
| 7 |
+
for line in process.stdout:
|
| 8 |
+
st.text(line.rstrip())
|
| 9 |
+
process.wait()
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def main():
|
| 12 |
st.title("Пакетный менеджер")
|
| 13 |
|
| 14 |
+
command_input = st.text_area("Введите команду", key="command_input")
|
| 15 |
+
commands = command_input.split('\n')
|
|
|
|
| 16 |
|
| 17 |
+
for command in commands:
|
| 18 |
+
if command.startswith("установи "):
|
| 19 |
+
package_name = command.split("установи ")[1]
|
| 20 |
+
st.text(f"Выполняется установка пакета: {package_name}")
|
| 21 |
+
install_package(package_name)
|
| 22 |
+
st.text(f"Установка пакета {package_name} завершена")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
if st.button("Очистить"):
|
| 25 |
+
st.text("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
main()
|