Using .run instead of .system now

This commit is contained in:
Profitroll 2022-12-30 21:03:04 +01:00
parent fa8bdc0e1f
commit 19b83c0631

View File

@ -1,7 +1,7 @@
#-*- coding: utf-8 -*- #-*- coding: utf-8 -*-
import os from subprocess import run
import traceback from traceback import format_exc
from functions import * from functions import *
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@ -16,12 +16,12 @@ async def getWaterLeft(cardid, filename, app=None):
try: try:
os.system(f'touch data/pages/{str(filename)}.html') run(["touch", f"data/pages/{str(filename)}.html"])
if config["use_compiled_page_saver"]: if config["use_compiled_page_saver"]:
os.system(f'PageSaver/pageSaver "https://bwtaqua.com.ua/card-topup/?id={cardid}" > data/pages/{str(filename)}.html') run(["PageSaver/pageSaver", f"\"https://bwtaqua.com.ua/card-topup/?id={cardid}\"", ">", f"data/pages/{str(filename)}.html"])
else: else:
os.system(f'node ./PageSaver/pageSaver.js "https://bwtaqua.com.ua/card-topup/?id={cardid}" > data/pages/{str(filename)}.html') run(["node", "PageSaver/pageSaver.js", f"\"https://bwtaqua.com.ua/card-topup/?id={cardid}\"", ">", f"data/pages/{str(filename)}.html"])
with open(f'data/pages/{str(filename)}.html') as f: with open(f'data/pages/{str(filename)}.html') as f:
html_file = f.read() html_file = f.read()
@ -38,7 +38,7 @@ async def getWaterLeft(cardid, filename, app=None):
appendLog(f"Exception occured: {exp} (user: {str(filename)}, cardid: {cardid})") appendLog(f"Exception occured: {exp} (user: {str(filename)}, cardid: {cardid})")
if app != None: if app != None:
await app.send_message(config["owner_id"], f"**Exception occured:**\n • User: `{str(filename)}`\n • Card: [{cardid}]({url})\n • Exception: `{exp}`\n • Traceback: `{traceback.format_exc()}`", disable_web_page_preview=True) await app.send_message(config["owner_id"], f"**Exception occured:**\n • User: `{str(filename)}`\n • Card: [{cardid}]({url})\n • Exception: `{exp}`\n • Traceback: `{format_exc()}`", disable_web_page_preview=True)
else: else:
print(f'Exception occured and could not send to user: {exp}') print(f'Exception occured and could not send to user: {exp}')