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 @@ - - - - - Page is not Found - - - -

404 page is NOT Found

- - - \ No newline at end of file diff --git a/views/README.txt b/views/README.txt deleted file mode 100755 index 5ff8ea2..0000000 --- a/views/README.txt +++ /dev/null @@ -1,23 +0,0 @@ - GRUSS ALLE - -ЧТО ЭТО ТАКОЕ: -Это проект Web GUI для пакетного менеджера Portage(Gentoo, Calcukate-linux). -Этот продукт предстовляет из себя клиент-серверное приложение. -Цели: -Предоставить удобный Гуй portage, для таких утройств как Планшеты, смартфоны. -Предоставить удаленный доступ к portagу на клиентской машине. -Снизить порог вхождения для новых пользователей на дистрибутивах имеющих в свой основе пакетный менеджер portageю - - - -КАК СОБРАТЬ И ЗАПУСТИТЬ: - -1.Нужен диструтив использущий дистрибутив использующий portage. -2.Скачайте дистрибутив проекта. -3.Введите в терминале: - cd web_pоrt && - git clone https://github.com/brython-dev/brython.git ./view/static/js/brython - скачайте Brython и распакуйте его в ./view/static/js/brython - -4.Запустите ./start -5.Откройте в браузере localhost:8080 \ No newline at end of file diff --git a/views/blank.html b/views/blank.html deleted file mode 100755 index 2977648..0000000 --- a/views/blank.html +++ /dev/null @@ -1,559 +0,0 @@ - - - - - - - - - - - Ample Admin Template - The Ultimate Multipurpose admin template - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - - - - - - - - - - - - - -
-
-
-
-

Starter Page

-
- - - -
- -
-
-
-
-

Blank Starter page

-
-
- - - - - - - - -
- -
2017 © Ample Admin brought to you by themedesigner.in
-
- - - -
- - - - - - - - - - - - - - - - - - diff --git a/views/index.html b/views/index.html deleted file mode 100755 index 3f03fe9..0000000 --- a/views/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - UI portage - - - - - - - - - - - - -
-
- - -
-

Идёт Обработка

- - -
- -
-
-
-

-
-
  • - - - -
  • -
    -
    - -
    - - - - - \ No newline at end of file diff --git a/views/index.html.old b/views/index.html.old deleted file mode 100755 index 07f3253..0000000 --- a/views/index.html.old +++ /dev/null @@ -1,140 +0,0 @@ - - - - - UI portage - - - - - - - - - - - - - -
    -
    - - -

    Загрузка

    - - -
    - -
    - -

    Идёт загрузка ......

    -
    - -
    -
    - - - - - - - -
    - -
    - - - - -
    - - - - - - -
    - - - \ No newline at end of file diff --git a/views/license.txt b/views/license.txt deleted file mode 100755 index a3857f7..0000000 --- a/views/license.txt +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/views/navigation-bar-by-jan-kadera.zip b/views/navigation-bar-by-jan-kadera.zip deleted file mode 100755 index 72d7c5f..0000000 Binary files a/views/navigation-bar-by-jan-kadera.zip and /dev/null differ diff --git a/views/profile.html b/views/profile.html deleted file mode 100755 index 2eb7ce0..0000000 --- a/views/profile.html +++ /dev/null @@ -1,773 +0,0 @@ - - - - - - - - - - - Ample Admin Template - The Ultimate Multipurpose admin template - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - -
    - - - - - - - - - - - - - - - -
    -
    -
    -
    -

    Profile page

    -
    - - - -
    -
    - - -
    -
    -
    -
    user -
    -
    - img -

    User Name

    -
    info@myadmin.com
    -
    -
    -
    -
    -

    -

    258

    -
    -

    -

    125

    -
    -

    -

    556

    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    assign a new task Design weblayout

    -
    user user user
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -
    -
    user
    -
    -

    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 weblayout
    -
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    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

    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    assign a new task Design weblayout

    -
    -
    -
    -
    -
    -
    -
    -
    Full Name -
    -

    Johnathan Deo

    -
    -
    Mobile -
    -

    (123) 456 7890

    -
    -
    Email -
    -

    johnathan@admin.com

    -
    -
    Location -
    -

    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.

    -

    Skill Set

    -
    -
    Wordpress 80%
    -
    -
    50% Complete
    -
    -
    HTML 5 90%
    -
    -
    50% Complete
    -
    -
    jQuery 50%
    -
    -
    50% Complete
    -
    -
    Photoshop 70%
    -
    -
    50% Complete
    -
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -
    -
    user
    -
    -

    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 weblayout
    -
    -
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    assign a new task Design weblayout

    -
    user user user
    -
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    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

    -
    -
    -
    -
    -
    -
    user
    -
    -
    John Doe 5 minutes ago -

    assign a new task Design weblayout

    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - -
    - -
    2017 © Ample Admin brought to you by themedesigner.in
    -
    - -
    - - - - - - - - - - - - - - - - - - diff --git a/views/vertical-css-menus201017.zip b/views/vertical-css-menus201017.zip deleted file mode 100755 index 6b07fbe..0000000 Binary files a/views/vertical-css-menus201017.zip and /dev/null differ