import base64 import os import pickle import sys from requests import get from requests.exceptions import ConnectionError from tcping import Ping def check_network(ip, port): try: req = get(f"{ip}").status_code return req in range(200, 300) except ConnectionError: return False # ping = Ping(ip, port, 20) # ping.ping(1) # return ping.result.rows[0].successed == 1 def get_os(): if sys.platform in ["linux", "windows", "win32"]: return sys.platform raise Exception("OS not supported") def alert(window, message, title="Munyal"): try: from tkinter import Button, Label, Toplevel child = Toplevel(window) child.title(title) label = Label(child, text=message) button = Button(child, text="Aceptar", command=child.destroy) label.pack() button.pack() except ModuleNotFoundError as e: print("!", Message, "!") def flatten_dirs_old(content, path="", action=""): output = [] for item in content: if item["is_file"]: item["name"] = path_join(path, item["name"]) output.append(item) else: if item["content"] and action == "add": output.extend( flatten_dirs(item["content"], path_join(path, item["name"]), action=action)) else: item["name"] = path_join(path, item["name"]) output.append(item) return output def path_join(*items): return os.path.join(*items).replace("\\", "/") if __name__ == "__main__": from dir_to_json import get_json import json folder = sys.argv[1] action = sys.argv[2] try: json_1 = get_json(folder) except Exception as e: print(e) print("error outside") sys.exit(1) print(json.dumps(list(flatten_dirs(json_1)), indent=2))