Загрузка
- - -Идёт загрузка ......
-diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..777478f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./pkg.json diff --git a/src/__pycache__/handler.cpython-38.pyc b/src/__pycache__/handler.cpython-38.pyc index 76bb8ff..567c8c6 100644 Binary files a/src/__pycache__/handler.cpython-38.pyc and b/src/__pycache__/handler.cpython-38.pyc differ diff --git a/src/__pycache__/handler.cpython-39.pyc b/src/__pycache__/handler.cpython-39.pyc new file mode 100644 index 0000000..ea96cce Binary files /dev/null and b/src/__pycache__/handler.cpython-39.pyc differ diff --git a/src/__pycache__/route.cpython-38.pyc b/src/__pycache__/route.cpython-38.pyc index fe03059..8b6c77b 100644 Binary files a/src/__pycache__/route.cpython-38.pyc and b/src/__pycache__/route.cpython-38.pyc differ diff --git a/src/__pycache__/route.cpython-39.pyc b/src/__pycache__/route.cpython-39.pyc new file mode 100644 index 0000000..e365ad3 Binary files /dev/null and b/src/__pycache__/route.cpython-39.pyc differ diff --git a/src/handler.py b/src/handler.py index 05365d6..44fa52d 100755 --- a/src/handler.py +++ b/src/handler.py @@ -1,17 +1,20 @@ - -#!/usr/bin/env python3.7 - +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- import json #from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer from http.server import BaseHTTPRequestHandler import os -from io import BytesIO from utils.utils import get_list_overlays, load_config, write_config, sort_inatll_pkg, scan_config_portage -from package import Package +from package import search from findfsdb import on_find from src.route import Router +from io import BytesIO #repl = '\n' class Handler(BaseHTTPRequestHandler): + def get_data(self): + length = int(self.headers['content-length']) + data = self.rfile.read(length) + return(str(data)) def r_403(self): self.send_response(403) @@ -36,23 +39,22 @@ class Handler(BaseHTTPRequestHandler): self.r_t ="" #print(Router.parse_url(self)) #print("data:\t" + self.rfile.read()) - #request = Router.parse_url(self).decode('utf-8') + #request = Router.parse_url(self) if self.client_address[0] == '127.0.0.1' or self.client_address[0].startswith('10.0'): self.send_response(200) self.end_headers() if self.path =="/": - #content_len = int(self.headers(['Content-Length'])) - #post_body = self.rfile.read('content_len') - #data = json.loads(post_body) - #print(data) + #print("data:\t" + self.get_data()) + with open('./views/index.html', 'tr') as f: self.r_t=f.read() print(self.client_address) elif self.path == '/main': - print(self.rfile/read()) + #print(self.rfile.read()) with open("./README.txt", 'r') as f: self.r_t = str(f.read()) + #self.r_t = s elif self.path == '/ovelays': overlays = get_list_overlays() @@ -62,7 +64,7 @@ class Handler(BaseHTTPRequestHandler): self.r_t=json.dumps({"repositories": overlays}) - elif self.path == "/favicon.ico": + elif self.path == "": with open('./favicon.png', 'rb') as f: self.r_t = f.read() @@ -76,7 +78,7 @@ class Handler(BaseHTTPRequestHandler): elif self.path == '/get_dump_list': try: - with open('./pkgs.json', 'r') as fn: + with open('./pkgs.json', 'tr') as fn: data = fn.read() pkg_list = json.load s(data) @@ -86,10 +88,10 @@ class Handler(BaseHTTPRequestHandler): self.r_t = json.dumps({"dump_portage": pkg_list}) elif self.path.startswith("/?st_app="): - #config = load_config() - #param = self.path.replace("/?st_app=", "") - #list_param = param.split(',') - #print(list_param) + config = load_config() + param = self.path.replace("/?st_app=", "") + list_param = param.split(',') + print(list_param) for i in list_param: if i.startswith('port'): port = int(i.split('=')[1]) @@ -115,9 +117,9 @@ class Handler(BaseHTTPRequestHandler): #for p in p_list: #print(p) if len(param.split("/")) == 2: - pk_list.append(Package().search(param.split("/")[1])) + pk_list.append(search(param.split("/")[1])) else: - pk_list.append(Package().search(param)) + pk_list.append(search(param)) #print(pk) search_result = {"Package_result": pk_list} self.r_t = str(json.dumps(search_result)) @@ -133,7 +135,7 @@ class Handler(BaseHTTPRequestHandler): elif '.py?' in self.path: print("loading") - self.path = "/static/app" + str(self.path.split('?')[0]) + self.path = str(self.path.split('?')[0]) print(self.path) self.r_static() @@ -146,26 +148,20 @@ class Handler(BaseHTTPRequestHandler): # Send the html message #self.wfile.write(bytes(self.r_t, "utf-8")) try: - return self.wfile.write(self.r_t) + return self.wfile.write(BytesIO(self.r_t).getvalue()) except TypeError: #print("TypeError") - return self.wfile.write(bytes(self.r_t, 'utf-8')) + return self.wfile.write(bytes(self.r_t, 'UTF-8')) else: self.r_403() def r_static(self): if os.path.exists('./views/' + self.path): - #self.send_response(200) - #self.end_headers() + self.send_response(200) + self.end_headers() with open('./views/' + self.path, 'tr') as f: self.r_t=f.read() else: self.send_response(404) self.end_headers() - def do_POST(self): - self._set_headers() - content_len = int(self.headers.getheader('content-length', 0)) - post_body = self.rfile.read(content_len) - data = json.loads(post_body) - print(data) diff --git a/utils/__pycache__/utils.cpython-38.pyc b/utils/__pycache__/utils.cpython-38.pyc index 3ac42db..3f78d2e 100644 Binary files a/utils/__pycache__/utils.cpython-38.pyc and b/utils/__pycache__/utils.cpython-38.pyc differ diff --git a/utils/__pycache__/utils.cpython-39.pyc b/utils/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..466f183 Binary files /dev/null and b/utils/__pycache__/utils.cpython-39.pyc differ diff --git a/utils/utils.py b/utils/utils.py index 2d70011..aebba7d 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -22,8 +22,8 @@ def read_configs(filename): #получаем список оверлеев def get_list_overlays(): - overlays ="" - url = "https://api.gentoo.org/overlays/repositories.xml" + overlays =[] + url = "https://qa-reports.gentoo.org/output/repos/repositories.xml" # "https://api.gentoo.org/overlays/repositories.xml" response = request.urlopen(url) overlays = [] overlay = {} @@ -35,10 +35,10 @@ def get_list_overlays(): homepage = "" for child in root.findall('repo'): name = child.find('name').text - #try: - description = child.find('description').text - #except AttributeError: - # description = "У overlay нет описания" + try: + description = child.find('description').text + except AttributeError: + description = "У overlay нет описания" try: homepage = child.find('homepage').text except AttributeError: @@ -48,8 +48,8 @@ def get_list_overlays(): overlays.append(overlay) #print(str(overlays)) print(len(overlays)) - #f=open('./overlays.json', 'a') - #f.write(json.dumps({"repositories": overlays})) + with open('./overlays.json', 'a') as f: + f.write(json.dumps({"repositories": overlays})) #f.close() return overlays diff --git a/view/static/js b/view/static/js deleted file mode 160000 index 8ec0464..0000000 --- a/view/static/js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8ec046485ccdcfcee73c114fc9e3186882ed6ccf diff --git a/views/404.html b/views/404.html deleted file mode 100755 index d77f3ca..0000000 --- a/views/404.html +++ /dev/null @@ -1,14 +0,0 @@ - - -
- -Идёт загрузка ......
--
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa
Design weblayoutLorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper
-Johnathan Deo
-(123) 456 7890
-johnathan@admin.com
-London
-Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt.Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
-Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
-It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa
Design weblayoutLorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper
-