Compare commits

..

No commits in common. "b560ff1c1cab7ab54ba1b9f23b9a961f41b95d57" and "b509a852f12e52eeaed57e687a5cb9248cf472d4" have entirely different histories.

4 changed files with 25 additions and 19 deletions

View File

@ -7,14 +7,14 @@ hrefs = []
def main(): def main():
directory = os.path.dirname(os.path.realpath(__file__)) directory = "dist"
file_path = os.path.join(directory, "dist", "data.json") file_path = os.path.join(directory, "data.json")
scrap(urls[0]) scrap(urls[0])
data = [] data = []
try: try:
os.mkdir(os.path.join(directory, "dist")) os.mkdir("dist")
except FileExistsError: except FileExistsError:
pass pass
with open(file_path, "w", encoding="utf-8") as file: with open(file_path, "w", encoding="utf-8") as file:

View File

@ -1,10 +1,24 @@
import os import os
from run_command import run_command
def get_path(): def get_path():
current_path = os.path.dirname(os.path.abspath(__file__)) pwd = run_command("pwd")
path = "/".join(current_path.split("/")[:-1]) splitted = pwd.split("/")
return path splitted[-1] = splitted[-1].replace("\n", "")
if splitted.count("webscraper") > 1 and "webscraper" in splitted:
for i in range(len(splitted) - 1, -1, -1):
potential_path = "/".join(splitted[: i + 1])
if "webscraper" in potential_path:
script_path = f"{potential_path}/scripts"
if os.path.isdir(script_path):
return potential_path
else:
return "This is not a valid webscraper project."
else:
path = "/".join(splitted[: splitted.index("webscraper") + 1])
return path
def run_main(): def run_main():

View File

@ -19,23 +19,15 @@ def clearCondition(command: str) -> bool:
return command in ["c", "clear", "cls"] return command in ["c", "clear", "cls"]
def clearScreen():
print(run_command("clear"))
return None
def systemCommand(command: str) -> str: def systemCommand(command: str) -> str:
words = command[1:].split() words = command[1:].split()
if words[0] == "": if words[0] == "":
return "Command not found. Write 'h' for help." return "Command not found. Write 'h' for help."
try: print(
print( run_command(
run_command( f'docker exec -it webscraper {" ".join(words)}',
f'docker exec -it webscraper {" ".join(words)}',
)
) )
except Exception as e: )
print(f"An error occurred: {e}")
return None return None

View File

@ -15,7 +15,7 @@ def prompt():
print(help_list()) print(help_list())
continue continue
if clearCondition(command): if clearCondition(command):
clearScreen() run_command("clear")
continue continue
if command.startswith("$"): if command.startswith("$"):
systemCommand(command) systemCommand(command)