try: query = utils.getQuery() logger.context = "download.py" if __name__ == "__main__": utils.log_header(logger, DESCRIPTION, options.get("verbose", False)) logger.debug("Options:", options.get("verbose", False)) for i in options: logger.debug(i + ": " + str(options[i]), options.get("verbose", False)) download_query(query, options, logger) # move all downloaded videos in videos directory repoDir = utils.repoPath() fs = os.listdir(repoDir) for f in fs: if utils.is_video(f): os.rename(f, "videos/" + f) logger.success("All files downloaded.", not options.get("silent", False)) except Exception as e: logger.handle_exception(e) raise e if __name__ == "__main__": logger = Logger("download.log", "download.py", False, True) logger.header(True, True, DESCRIPTION, 0, True) main(parse_args(), logger)
import serverly.err import serverly.plugins import serverly.stater import serverly.statistics import uvicorn from fileloghelper import Logger from serverly import default_sites from serverly.objects import Request, Response, StaticSite from serverly.utils import * description = "A really simple-to-use HTTP-server" address = ("localhost", 8080) name = "serverly" version = "0.4.6" logger = Logger("serverly.log", "serverly", False, True) logger.header(True, True, description, fileloghelper_version=True, program_version="serverly v" + version) error_response_templates = {} https_redirect_url: str = None async def _read_body(receive): """ Read and return the entire body from an incoming ASGI message. http://www.uvicorn.org/#http-scope """ body = b'' more_body = True while more_body: message = await receive() body += message.get('body', b'')
from http.server import HTTPServer, BaseHTTPRequestHandler import json import urllib.parse as parse from fileloghelper import Logger from download import download_list from utils import removeExtension, get_extension, get_filetype logger = Logger("server.log", "ytHelperServer", True, True) logger.header(True, True, "THE YT SERVER", 8) class ytHelperHandler(BaseHTTPRequestHandler): def do_GET(self): logger.debug("GET - " + self.path) parsed_url = parse.urlparse(self.path) if parsed_url.path == "/": content = open("index.html", "r").read() self.send_response(200) self.send_header("Content-type", "text/html") self.send_header("Content-Length", len(content)) self.end_headers() self.wfile.write(bytes(content, "utf-8")) return True elif parsed_url.path == "/get": token = parse.parse_qs(parsed_url.query).get("token", "")[0] with open("config.json", "r") as f: config = json.loads(f.read()) urls = config["urls"] try: tokendict = urls[token] except KeyError:
--- - 0: no errors - 1: partially constrained - 2: major/complete fail - 3: offline """ from fileloghelper import Logger import pymysql.cursors from pymysql.err import OperationalError from Stater.utils import get_server_params, encrypt from Stater.err import * import json logger = Logger("base.log", "register", True, True) logger.header(True, True, "Stater - base", 0, True, "moonshine") def exec_sql(sql_command="SELECT * FROM tasks", verbose=True, logger: Logger = None): """Execute sql_command on database and return None or whatever is returned from the database. If sql_command is not specified, all tasks will get returned""" result = None if logger != None and type(logger) == Logger: logger.set_context("exec_sql") elif verbose == True: logger = Logger("exec_sql.log", "exec_sql", True, True) try: connection = pymysql.connect(host='localhost', user='******', password='******', db='stater', charset='utf8mb4',