diff --git a/Makefile b/Makefile index 06b8b16..e56b183 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ #!/bin/bash run: + #make cert && python server.py testToken: - python3 core/jwt.py + python core/jwt.py cert: openssl req -new -x509 -keyout localhost.pem -out localhost.pem -nodes -days 365 - diff --git a/README.md b/README.md index 5ca3ae4..6fad881 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,24 @@ -
-

GRUSS ALLE

- -ЧТО ЭТО ТАКОЕ: -

-Это проект WebGUI для пакетного менеджера Portage(Gentoo/Calculate-linux). -Этот продукт представляет из себя клиент-серверное приложение.

-Цели: -

-Предоставть удобный Гуй для portage, для таких утройств как Планшеты, смартфоны, -предаставить удаленный доступ к portage на клиенткой/удалеённой машине -Снизить порог вхождения для новых пользователей на дистрибутивах имеющих в свой основе пакетный менеджер Portage

- -КАК СОБРАТЬ И ЗАПУСТИТЬ: -
    -

    Нужен дистрибутив с пакетнным менеджером portage.

    -
  1. Скачайте дистрибутив сереного приложения проекта
  2. -
  3. Введите в терминале:
  4. - - git clone && cd webport - -
  5. Запустите make run
  6. -
  7. Скачайте клиент и запустите. -
  8. - - - -
-
+# Webport GRUSS ALLE + +## О ПРОЕКТЕ + +Это проект WebGUI для пакетного менеджера Portage (Gentoo/Calculate-linux). +Этот продукт представляет из себя клиент-серверное приложение. + +## ЦЕЛЬ ПРОЕКТА + +Предоставть удобный GUI-интерфейс для Portage, для таких утройств как планшеты, смартфоны, предоставить удалённый доступ к Portage на клиентской/удалённой машине, снизить порог вхождения для новых пользователей на дистрибутивах имеющих в своей основе пакетный менеджер Portage. + +## КАК СОБРАТЬ И ЗАПУСТИТЬ + +Нужен дистрибутив с пакетным менеджером Portage. +Скачайте дистрибутив серверного приложения проекта. + +1. Введите в терминале: +`git clone https://git.calculate-linux.org/serkus/webport.git && cd webport` +2. Запустите: +`make run` +3. Скачайте клиент и запустите: + +* Откройте клиент (если вы он у вас собран). +* Откройте в браузере страницу с адресом localhost:8080 или с IP-адресом и портом указанным в файле config.json (если вы установили как WebClient). diff --git a/README.txt b/README.txt index 47e34c8..8d50b7f 100644 --- a/README.txt +++ b/README.txt @@ -1,29 +1,34 @@
-

GRUSS ALLE

+

GRUSS ALLE

-ЧТО ЭТО ТАКОЕ: -

-Это проект Web GUI для пакетного менеджера Portage(Gentoo, Calcukate-linux). -Этот продукт предстовляет из себя клиент-серверное приложение.

-Цели: -

-Предоставть удобный Гуй portage, для таких утройств как Планшеты, смртфоны -Предоставить удаленный доступ к portag на клиенткой машине -Снизить порог вхождения для новых пользователей на дистрибутивах имеющих в свой основе пакетный менеджер portage

+О ПРОЕКТЕ: +

Это проект WebGUI для пакетного менеджера Portage (Gentoo/Calculate-linux). +Этот продукт представляет из себя клиент-серверное приложение.

+ЦЕЛЬ ПРОЕКТА: + +

Предоставть удобный GUI-интерфейс для Portage, для таких утройств как планшеты, смартфоны, +предоставить удалённый доступ к Portage на клиентской/удалённой машине, снизить порог вхождения для новых пользователей на дистрибутивах имеющих в своей основе пакетный менеджер Portage.

КАК СОБРАТЬ И ЗАПУСТИТЬ: +
    -

    Нужен диструтив использущий дастрибутив использующий portage.

    -
  1. Скачайте дистрибутив проекта
  2. +

    Нужен дистрибутив с пакетным менеджером Portage.

    +
  3. Скачайте дистрибутив серверного приложения проекта.
  4. Введите в терминале:
  5. - cd web_pоrt && - git clone https://github.com/brython-dev/brython.git ./view/static/js/brython - или скачайте Brython и раскакуйте его в ./view/static/js/brython + git clone https://git.calculate-linux.org/serkus/webport.git && cd webport -
  6. Запустите его ./start
  7. -
  8. Откройте в браузере localhost:8000
  9. +
  10. Запустите его ./start + + make run + +
  11. +
  12. Скачайте клиент и запустите: +
  13. Откройте клиент (если вы он у вас собран).
  14. +
  15. Откройте в браузере страницу с адресом localhost:8080 или с IP-адресом и + портом указанным в файле config.json (если вы установили как WebClient).
  16. +
\ No newline at end of file diff --git a/client.py b/client.py index f85318d..edaaeb9 100644 --- a/client.py +++ b/client.py @@ -21,7 +21,7 @@ class MainWindow(QMainWindow): self.Bryton = QTextStream(fd).readAll() fd.close() else: - self.Brython= '' + self.Brython = '' QNetworkProxyFactory.setUseSystemConfiguration(True) @@ -82,7 +82,6 @@ class MainWindow(QMainWindow): self.adjustTitle() self.view.page().mainFrame().evaluateJavaScript(self.Brython) - def highlightAllLinks(self): code = """$('a').each( function () { @@ -127,7 +126,6 @@ class MainWindow(QMainWindow): code = "$('embed').remove()" self.view.page().mainFrame().evaluateJavaScript(code) - if __name__ == '__main__': import sys diff --git a/config.json b/config.json index 0dcefdc..65a2cc1 100644 --- a/config.json +++ b/config.json @@ -1 +1,5 @@ -{"PORT": 8000, "Lang": "ru", "THEME": "default"} \ No newline at end of file +{ + "PORT": 8000, + "Lang": "ru", + "THEME": "default" +} \ No newline at end of file diff --git a/core/Untitled-1 b/core/Untitled-1 deleted file mode 100644 index e0e458c..0000000 --- a/core/Untitled-1 +++ /dev/null @@ -1 +0,0 @@ -https://youtu.be/dIv4TY7-gqM \ No newline at end of file diff --git a/core/__pycache__/handler.cpython-36.pyc b/core/__pycache__/handler.cpython-36.pyc deleted file mode 100644 index 8248425..0000000 Binary files a/core/__pycache__/handler.cpython-36.pyc and /dev/null differ diff --git a/core/__pycache__/handler.cpython-38.pyc b/core/__pycache__/handler.cpython-38.pyc deleted file mode 100644 index cfea8e6..0000000 Binary files a/core/__pycache__/handler.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/handler.cpython-39.pyc b/core/__pycache__/handler.cpython-39.pyc deleted file mode 100644 index 1b1b4f4..0000000 Binary files a/core/__pycache__/handler.cpython-39.pyc and /dev/null differ diff --git a/core/__pycache__/jwt.cpython-39.pyc b/core/__pycache__/jwt.cpython-39.pyc deleted file mode 100644 index 070cb87..0000000 Binary files a/core/__pycache__/jwt.cpython-39.pyc and /dev/null differ diff --git a/core/__pycache__/route.cpython-36.pyc b/core/__pycache__/route.cpython-36.pyc deleted file mode 100644 index 0f8ec84..0000000 Binary files a/core/__pycache__/route.cpython-36.pyc and /dev/null differ diff --git a/core/__pycache__/route.cpython-38.pyc b/core/__pycache__/route.cpython-38.pyc deleted file mode 100644 index 8b6c77b..0000000 Binary files a/core/__pycache__/route.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/route.cpython-39.pyc b/core/__pycache__/route.cpython-39.pyc deleted file mode 100644 index b695fec..0000000 Binary files a/core/__pycache__/route.cpython-39.pyc and /dev/null differ diff --git a/core/handler.py b/core/handler.py index 6f63b11..80bff8d 100755 --- a/core/handler.py +++ b/core/handler.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: UTF-8 -*- import json -#from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer +# from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer from http.server import BaseHTTPRequestHandler import logging import os @@ -9,200 +9,198 @@ from utils.utils import get_list_overlays, load_config, write_config, sort_insta from utils.package import search from utils.findfsdb import on_find from core.route import Router +import logging from io import BytesIO #repl = '\n' def main(): - try: - with open('./pkgs.json', 'tr') as fn: - data = fn.read() - pkg_list = json.loads(data) - print(pkg_list) - return json.dumps(pkg_list) - except Exception(e): - print(e) - return "404" + try: + with open('./pkgs.json', 'tr') as fn: + data = fn.read() + pkg_list = json.loads(data) + print(pkg_list) + return json.dumps(pkg_list) + except Exception(e): + print(e) + return "404" def set_settings_app(params): - 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]) - elif i.startswith('Lang'): - Lang = i.split('=')[1] - - write_config(port, Lang) - print(config) - print(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]) + elif i.startswith('Lang'): + Lang = i.split('=')[1] + + write_config(port, Lang) + print(config) + print(param) def search(pkg): - #param = self.path.replace("/find?pkg=", "") #request['params']['name'] - Pk_list = [] - Search_result = {} - if len(param.split('/')) == 2: - param = param.split('/')[1] - P_list = on_find(param) - print(p_list) - if len(P_list) == 0: - print("Never Found") - self.r_t = str(json.dumps({"Package_result": p_list})) - else: - for p in p_list: - print(p) - if len(param.split("/")) == 2: - Pk_list.append(search(param.split("/")[1])) - else: - Pk_list.append(search(param)) - #print(pk) - Search_result = {"Package_result": Pk_list} - #self.r_t = str(json.dumps(search_result)) - return str(json.dumps(Search_result)) - #self.r_t = json.dumps(pkg_list) -def get_settings_app(): - return str(json.dumps(load_config())) + # param = self.path.replace("/find?pkg=", "") #request['params']['name'] + Pk_list = [] + Search_result = {} + if len(param.split('/')) == 2: + param = param.split('/')[1] + P_list = on_find(param) + print(p_list) + if len(P_list) == 0: + print("Never Found") + self.r_t = str(json.dumps({"Package_result": p_list})) + else: + for p in p_list: + print(p) + if len(param.split("/")) == 2: + Pk_list.append(search(param.split("/")[1])) + else: + Pk_list.append(search(param)) + # print(pk) + Search_result = {"Package_result": Pk_list} + # self.r_t = str(json.dumps(search_result)) + return str(json.dumps(Search_result)) + # self.r_t = json.dumps(pkg_list) +def get_settings_app(): + return str(json.dumps(load_config())) class Handler(BaseHTTPRequestHandler): - def _set_response(self): - self.send_response(200) - self.send_header['Access-Control-Allow-Origin', '*'] - self.send_header['Access-Control-Allow-Methods', 'GET'] - self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] - #self.send_header['Access-Control-Allow-Credentials', true] - self.end_headers() - - - def get_data(self): - #length = int(self.headers['content-length']) - data = self.rfile.read(length) - - def do_HEAD(self): - print("do_HEAD:\n") - print(str(self.path), str(self.headers)) - #self.send_header(['Access-Control-Allow-Origin', '*'], - #self.send_header(['Access-Control-Allow-Methods', 'GET'], - #self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type']) - #self.send_header(['Access-Control-Allow-Credentials', true]) - #self.end_headers() - - def do_REQUEST(self): - print("do_REQUEST:\n") - print(str(self.path), str(self.headers)) - self.r_t = str(self.path), str(self.headers) - #return self.response() - - def do_GET(self): - print("do_GET:\n") - print(str(self.path), str(self.headers)) - - - #print(Router.parse_url(self)) - #print("data:\t" + self.rfile.read()) - #request = Router.parse_url(self) - self.send_response(200) - self.p_list = [] - self.r_t = "" - #length = int(self.headers['content-length']) - #self.send_header(['Access-Control-Allow-Origin', '*'], - #self.send_header(['Access-Control-Allow-Methods', 'GET'], - #self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type']) - #self.send_header(['Access-Control-Allow-Credentials', true]) - #self.end_headers() - - #self.end_headers() - - if self.path =="/": - #print("data:\t" + self.get_data()) - """ - with open('./views/index.html', 'tr') as f: - self.r_t=f.read() - print(self.client_address) - """ - self.r_t = main() - self.response() - elif self.path == '/main': - #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() - #print(ovls) - if overlays: # == "": - overlays ="Error" - - self.r_t=json.dumps({"repositories": overlays}) - - elif self.path == "": - with open('./favicon.png', 'rb') as f: - self.r_t = f.read() - - elif self.path == '/logo.png': - pass - - elif self.path.startswith("/?st_app="): - 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]) - elif i.startswith('Lang'): - Lang = i.split('=')[1] - - write_config(port, Lang) - print(config) - print(param) - - elif self.path.startswith("/find?pkg="): - param = self.path.replace("/find?pkg=", "") #request['params']['name'] - pk_list = [] - search_result = {} - if len(param.split('/')) == 2: - param = param.split('/')[1] - p_list = on_find(param) - print(p_list) - if len(p_list) == 0: - print("Never Found") - self.r_t = str(json.dumps({"Package_result": p_list})) - else: - for p in p_list: - print(p) - if len(param.split("/")) == 2: - pk_list.append(search(param.split("/")[1])) - else: - pk_list.append(search(param)) - #print(pk) - search_result = {"Package_result": pk_list} - self.r_t = str(json.dumps(search_result)) - - elif self.path == "/get_settings_app": - - self.r_t = str(json.dumps(load_config())) - - elif self.path == '/get_portage': - - #self.r_t = str(sort_inatll_pkg()) - self.r_t = str(json.dumps(scan_config_portage())) - - else: - self.send_response(404) - - self.end_headers() - print(str(self.client_address[0]) +"\t" + str(404)) + def _set_response(self): + self.send_response(200) + self.send_header['Access-Control-Allow-Origin', '*'] + self.send_header['Access-Control-Allow-Methods', 'GET'] + self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] + # self.send_header['Access-Control-Allow-Credentials', true] + self.end_headers() + + def get_data(self): + length = int(self.headers['content-length']) + data = self.rfile.read(length) + + def do_HEAD(self): + print("do_HEAD:\n") + print(str(self.path), str(self.headers)) + # self.send_header(['Access-Control-Allow-Origin', '*'], + # self.send_header(['Access-Control-Allow-Methods', 'GET'], + # self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type']) + # self.send_header(['Access-Control-Allow-Credentials', true]) + # self.end_headers() + + def do_REQUEST(self): + print("do_REQUEST:\n") + print(str(self.path), str(self.headers)) + self.r_t = str(self.path), str(self.headers) + # return self.response() + + def do_GET(self): + print("do_GET:\n") + print(str(self.path), str(self.headers)) + + # print(Router.parse_url(self)) + # print("data:\t" + self.rfile.read()) + # request = Router.parse_url(self) + self.send_response(200) + self.p_list = [] + self.r_t = "" + # length = int(self.headers['content-length']) + # self.send_header(['Access-Control-Allow-Origin', '*'], + # self.send_header(['Access-Control-Allow-Methods', 'GET'], + # self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type']) + # self.send_header(['Access-Control-Allow-Credentials', true]) + # self.end_headers() + + if self.path == "/": + # print("data:\t" + self.get_data()) + """ + with open('./views/index.html', 'tr') as f: + self.r_t = f.read() + print(self.client_address) + """ + self.r_t = main() + self.response() + elif self.path == '/main': + #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() + #print(ovls) + if overlays: # == "": + overlays = "Error" + + self.r_t = json.dumps({"repositories": overlays}) + + elif self.path == "": + with open('./favicon.png', 'rb') as f: + self.r_t = f.read() + + elif self.path == '/logo.png': + pass + + elif self.path.startswith("/?st_app="): + 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]) + elif i.startswith('Lang'): + Lang = i.split('=')[1] + + write_config(port, Lang) + print(config) + print(param) + + elif self.path.startswith("/find?pkg="): + param = self.path.replace("/find?pkg=", "") #request['params']['name'] + pk_list = [] + search_result = {} + if len(param.split('/')) == 2: + param = param.split('/')[1] + p_list = on_find(param) + print(p_list) + if len(p_list) == 0: + print("Never Found") + self.r_t = str(json.dumps({"Package_result": p_list})) + else: + for p in p_list: + print(p) + if len(param.split("/")) == 2: + pk_list.append(search(param.split("/")[1])) + else: + pk_list.append(search(param)) + #print(pk) + search_result = {"Package_result": pk_list} + self.r_t = str(json.dumps(search_result)) + + elif self.path == "/get_settings_app": + + self.r_t = str(json.dumps(load_config())) + + elif self.path == '/get_portage': + + #self.r_t = str(sort_inatll_pkg()) + self.r_t = str(json.dumps(scan_config_portage())) + + else: + self.send_response(404) + + self.end_headers() + print(str(self.client_address[0]) +"\t" + str(404)) # Send the html message - #self.wfile.write(bytes(self.r_t, "utf-8")) - def response(self): - if self.r_t !=="": - #self._set_response() - try: - return self.wfile.write(BytesIO(self.r_t).getvalue()) - except TypeError: - #print("TypeError") - return self.wfile.write(bytes(self.r_t, 'UTF-8')) - else: - self.send_response(404) + # self.wfile.write(bytes(self.r_t, "utf-8")) + + def response(self): + if self.r_t != "": + #self._set_response() + try: + return self.wfile.write(BytesIO(self.r_t).getvalue()) + except TypeError: + #print("TypeError") + return self.wfile.write(bytes(self.r_t, 'UTF-8')) + else: + self.send_response(404) diff --git a/core/jwt.py b/core/jwt.py index 0f2ad5e..fba6b69 100644 --- a/core/jwt.py +++ b/core/jwt.py @@ -5,7 +5,7 @@ import secrets def genaratorSecretsToken(): return secrets.token_hex(4096) -if __name__ =='__main__': +if __name__ == '__main__': Token = genaratorSecretsToken() print(Token) #return Token \ No newline at end of file diff --git a/core/route.py b/core/route.py index 82dc85f..4d7c63c 100644 --- a/core/route.py +++ b/core/route.py @@ -8,144 +8,141 @@ from .jwt import genaratorSecretsToken import json class Router(): - def __init__(self): - routes = self.setRoutes() - super().__init__(self.setRoutes) - def add(self, url, **opts): - pass - - def find(self, url, handler): - if url in self.routes: - if "?" in url[-1]: - params.url.split("?") - return handler(params) - else: - return handler() - else: - return 1 - + def __init__(self): + routes = self.setRoutes() + super().__init__(self.setRoutes) + + def add(self, url, **opts): + pass + + def find(self, url, handler): + if url in self.routes: + if "?" in url[-1]: + params.url.split("?") + return handler(params) + else: + return handler() + else: + return 1 class RouterOld(BaseHTTPRequestHandler): - #def __init__(self): - #self.P_list = [] - #self.Response = "" - #self.Routes =[] - #self.r_t ="" - #length = int(self.headers['content-length']) - # Not work code - #self.send_header['Access-Control-Allow-Origin', '*'] - #self.send_header['Access-Control-Allow-Methods', 'GET'] - #self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] - #self.send_header['Access-Control-Allow-Credentials', true] - #self.end_headers() - #super().__init__(self, self.setRoutes()) - - def _set_response(self): - self.send_response(200) - self.send_header['Access-Control-Allow-Origin', '*'] - self.send_header['Access-Control-Allow-Methods', 'GET'] - self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] - #self.send_header['Access-Control-Allow-Credentials', true] - self.end_headers() - def do_GET(self): - #logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers)) - #print(str(self.path), str(self.headers)) - self.r_t = str(self.path), str(self.headers) - return self.response() - - def do_POST(self): - - logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers)) - self._set_response() - print(str(self.path), str(self.headers)) - - def do_HEAD(self): - pass - def do_REQUEST(self): - print("do_REQUEST:\n") - print(str(self.path), str(self.headers)) - self.r_t = str(self.path), str(self.headers) - return self.response() - - def _setRoutes(self, ListRoutes =[]): - self.Routes = ListRoutes - - def response(self): - try: - return self.wfile.write(BytesIO(self.r_t).getvalue()) - except TypeError: - #print("TypeError") - return self.wfile.write(bytes(self.r_t, 'UTF-8')) - - - def route(self, metod, url, handler): - print(url) - - if self.path in self.Routes.url: - if metod == 'GET' or metod == 'get': - self.get(url=url,handler=handler) - #return true - elif metod == 'POST' or metod == 'post': - self.post(url=url, handler=handler) - elif metod == 'HEAD' or metod == 'head': - self.head() - else: - self.r_404() - else: - return self.r_404() - #return false - def get(self, url, handler): - #do_GET() - return url - - def post(self, url, handler): - #do_POST() - return url - - def head(self): - #do_HEAD() - pass - - def __isAuth(selt, auth): - pass - - def getToken(self, authResult): - print(self.client_address) - #if self.__isAuth() is True: - genaratorSecretsToken() - #else: - # self.r_403() - - def parse_url(request): - print("request.rfile:\t" + str(request.rfile.read())) - #return json.loads(str(request.rfile.read())) - - def r_403(self): - self.send_response(403) - self.end_headers() - print(self.client_address) - - def r_404(self): - self.send_response(404) - self.end_headers() - print(self.client_address) - - def r_static(self): - if os.path.exists('./views/' + self.path): - self.send_response(200) - self.end_headers() - with open('./views/' + self.path, 'tr') as f: - self.Response=f.read() - - else: - self.send_response(404) - self.end_headers() - - - - + # def __init__(self): + # self.P_list = [] + # self.Response = "" + # self.Routes = [] + # length = int(self.headers['content-length']) + # Not work code + # self.send_header['Access-Control-Allow-Origin', '*'] + # self.send_header['Access-Control-Allow-Methods', 'GET'] + # self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] + # self.send_header['Access-Control-Allow-Credentials', true] + # self.end_headers() + # super().__init__(self.setRoutes) + + def _set_response(self): + self.send_response(200) + self.send_header['Access-Control-Allow-Origin', '*'] + self.send_header['Access-Control-Allow-Methods', 'GET'] + self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type'] + #self.send_header['Access-Control-Allow-Credentials', true] + self.end_headers() + + def do_GET(self): + # logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers)) + # print(str(self.path), str(self.headers)) + self.r_t = str(self.path), str(self.headers) + return self.response() + + def do_POST(self): + logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers)) + self._set_response() + print(str(self.path), str(self.headers)) + + def do_HEAD(self): + pass + + def do_REQUEST(self): + print("do_REQUEST:\n") + print(str(self.path), str(self.headers)) + self.r_t = str(self.path), str(self.headers) + return self.response() + + def _setRoutes(self, ListRoutes = []): + self.Routes = ListRoutes + + def response(self): + try: + return self.wfile.write(BytesIO(self.r_t).getvalue()) + except TypeError: + #print("TypeError") + return self.wfile.write(bytes(self.r_t, 'UTF-8')) + + def route(self, metod, url, handler): + print(url) + metod = metod.lower() + if self.path in self.Routes.url: + #if metod == 'GET' or metod == 'get': + if metod == 'get': + self.get(url = url, handler = handler) + #return true + elif metod == 'post': + self.post(url = url, handler= handler) + elif metod == 'head': + self.head() + else: + self.r_404() + else: + return self.r_404() + #return false + + def get(self, url, handler): + #do_GET() + return url + + def post(self, url, handler): + #do_POST() + return url + + def head(self): + #do_HEAD() + pass + + def __isAuth(selt, auth): + pass + + def getToken(self, authResult): + print(self.client_address) + #if self.__isAuth() is True: + genaratorSecretsToken() + #else: + # self.r_403() + + def parse_url(request): + print("request.rfile:\t" + str(request.rfile.read())) + #return json.loads(str(request.rfile.read())) + + def r_403(self): + self.send_response(403) + self.end_headers() + print(self.client_address) + + def r_404(self): + self.send_response(404) + self.end_headers() + print(self.client_address) + + def r_static(self): + if os.path.exists('./views/' + self.path): + self.send_response(200) + self.end_headers() + with open('./views/' + self.path, 'tr') as f: + self.Response = f.read() + else: + self.send_response(404) + self.end_headers() + """ - def do_GET(self): + def do_GET(self): pass def do_POST(self): diff --git a/recovers.txt b/recovers.txt index 096894f..e80251e 100644 --- a/recovers.txt +++ b/recovers.txt @@ -18,10 +18,10 @@ obs-studio kdenlive mplayer smplayer -[web-сервер] +[Web-сервер] nginx apache -[dev-util] +[Dev-util] pycharm-community [графика] gimp diff --git a/server.py b/server.py index f97ccf1..8577cbe 100755 --- a/server.py +++ b/server.py @@ -1,56 +1,56 @@ -# -*- coding: UTF-8 -*- #!/usr/bin/env pyton3 +# -*- coding: UTF-8 -*- '__autor__' =='serkus' -from http.server import HTTPServer, SimpleHTTPRequestHandler, BaseHTTPRequestHandler +from http.server import HTTPServer, SimpleHTTPRequestHandler, BaseHTTPRequestHandler import logging from core.handler import Handler as Handler -import os, sys, json, ssl +import os, sys, json, ssl from core.route import Router #PORT_NUMBER = 8000 from utils.findfsdb import create_db from utils.utils import load_config def https_server(): - https_server_address = ('', 4443) - httpd = HTTPServer(https_server_address, SimpleHTTPRequestHandler) - httpd.socket = ssl.wrap_socket(httpd.socket, - server_side=True, - certfile='localhost.pem', - ssl_version=ssl.PROTOCOL_TLS) - httpd.serve_forever() + https_server_address = ('', 4443) + httpd = HTTPServer(https_server_address, SimpleHTTPRequestHandler) + httpd.socket = ssl.wrap_socket(httpd.socket, + server_side = True, + certfile = 'localhost.pem', + ssl_version = ssl.PROTOCOL_TLS) + httpd.serve_forever() def run(): - create_db() - config = load_config() - if len(config) ==0: - print("конфиг пустой") - try: - print(config['PORT']) - except KeyError: - print("KeyError") - except KeyboardInterrupt: - pass - # Handler) - server = HTTPServer(('', config['PORT']),Handler) - #print ('Started HTTP Server on port ' , config['PORT']) - - server.socket = ssl.wrap_socket(server.socket, - server_side=True, - certfile='localhost.pem', - ssl_version=ssl.PROTOCOL_TLS) - print ('Started HTTP Server on port ' , config['PORT']) - print("https://localhost:" + str(config['PORT'])) - - try: - server.serve_forever() - except KeyboardInterrupt: - pass - httpd.server_close() - logging.info('Stopping httpd...\n') - -if __name__ == '__main__': - #https_server() - run() - https_server() - - \ No newline at end of file + create_db() + config = load_config() + if len(config) == 0: + print("Файл конфигурации пустой.") + try: + print(config['PORT']) + except KeyError: + print("KeyError") + except KeyboardInterrupt: + pass + + # server = HTTPServer(('', config['PORT']), Router) + server = HTTPServer(('', config['PORT']), Handler) + # print('Started HTTP Server on port', config['PORT']) + + server.socket = ssl.wrap_socket(server.socket, + server_side = True, + certfile = 'localhost.pem', + ssl_version = ssl.PROTOCOL_TLS) + print('Started HTTP Server on port', config['PORT']) + print("https://localhost:8000") + + try: + server.serve_forever() + except KeyboardInterrupt: + pass + server.server_close() + logging.info('Stopping httpd...\n') + +if __name__ == '__main__': + #https_server() + run() + https_server() + diff --git a/utils/GenRecovers.py b/utils/GenRecovers.py index 81710f0..211ced3 100644 --- a/utils/GenRecovers.py +++ b/utils/GenRecovers.py @@ -5,26 +5,27 @@ from utils.package import search from utils.getUses import get_local_USE def ScanRecoverFile(): - ScanResult =[] + ScanResult = [] if os.path.exists('./recovers.txt'): with open('./recovers.txt') as f: - ScanResult =f.read().split("\n") + ScanResult = f.read().split("\n") + res = GenRecoversFun(ScanResult) else: - print("Файла со список рекомедации нейден") - res = GenRecoversFun(ScanResult) + print("Файл со списком рекомедаций не найден.") + res = {} return res def GenRecoversFun(Reclist): - result ={} - cat= "" + result = {} + category = "" useDis = get_local_USE() for r in Reclist: if r.startswith("["): - cat = r.replace("[", "") and r.replace("]", "") - result[r.replace("[", "") and r.replace("]", "")]= [] + category = r.replace("[", "") and r.replace("]", "") + result[r.replace("[", "") and r.replace("]", "")] = [] else: try: - result[cat].append(search(r)) + result[category].append(search(r)) for u in search(r)['USE']: if u in useDis: print("u " + u +"\t"+ useDis[u]) @@ -32,6 +33,5 @@ def GenRecoversFun(Reclist): print(e) return result - if __name__ == '__main__': ScanRecoverFile() diff --git a/utils/Untitled-1 b/utils/Untitled-1 deleted file mode 100644 index 26f8e4b..0000000 --- a/utils/Untitled-1 +++ /dev/null @@ -1,397 +0,0 @@ -3dfx Enable support for Voodoo chipsets, also called as 3DFX and TDFX 22 -3dnow Adds support for 3dnow multimedia processor instructions 129 -a52 Enables support for decoding ATSC A/52 streams used in DVD 39 -aac Enables support for MPEG-4 AAC Audio 166 -aalib Adds support for media-libs/aalib (ASCII-Graphics Library) 108 -accessibility Adds support for accessibility (eg 'at-spi' library) 86 -acl Adds support for Access Control Lists 247 -acpi Adds support for Advanced Configuration and Power Interface 145 -adabas Adds support for the Adabas database engine 15 -adns Adds support for the adns DNS client library 35 -afs Adds OpenAFS support (distributed file system) 47 -aim Enable AIM IM protocol support 1 -alsa Adds support for media-libs/alsa-lib (Advanced Linux Sound Architecture) 1287 -altivec Adds support for optimizations for G4 and G5/ppc970 processors 441 -ao Use libao audio output library for sound playback 75 -apache2 Add Apache2 support 106 -apm Adds APM (Advanced Power Management) support 45 -aqua Include support for the Aqua / Carbon GUI 4451 -atm Enable Asynchronous Transfer Mode protocol support 43 -audiofile Adds support for libaudiofile where applicable 42 -avahi Add avahi/Zeroconf support 278 -bash-completion Enable bash-completion support 606 -bcmath Adds support for libbcmath 15 -berkdb Adds support for sys-libs/db (Berkeley DB for MySQL) 387 -bidi Enables bidirectional language support 71 -bindist Flag to enable or disable options for prebuilt (GRP) packages (eg. due to licensing issues) 206 -birdstep Adds support for the Birdstep Database Server 15 -blas Adds support for the virtual/blas numerical library 29 -bluetooth Enables Bluetooth Support 265 -bootstrap !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used during original system bootstrapping [make stage2] 220 -boundschecking Adds the bounds checking patch by Haj Ten Brugge, this will DISABLE the hardened PIE+SSP patches 7 -branding Enable Gentoo specific branding 54 -bsf Enable support for Apache Bean Scripting Framework (dev-java/bsf) 10 -build !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1] 1025 -bzip2 Use the bzlib compression library 273 -cairo Enable support for the cairo graphics library 212 -calendar Adds support for calendars (not using mcal!) 35 -canna Adds support for the Canna kana to kanji conversion engine 25 -caps Use Linux capabilities library to control privilege 203 -cdb Adds support for the CDB database engine from the author of qmail 42 -cdda Adds Compact Disk Digital Audio (Standard Audio CD) support 75 -cddb Access cddb servers to retrieve and submit information about compact disks 60 -cdinstall Copies files from the CD rather than asking the user to copy them, mostly used with games 64 -cdparanoia Enables cdparanoia (audio CD ripper) support 41 -cdr Adds support for CD writer hardware 45 -cgi Add CGI script support 66 -chasen Enable chasen (Japanese Morphological Analysis System) support 9 -cjk Adds support for Multi-byte character languages (Chinese, Japanese, Korean) 138 -clamav Adds support for Clam AntiVirus software (usually with a plugin) 38 -coreaudio Build the CoreAudio driver on Mac OS X systems 29 -cracklib Support for cracklib strong password checking 44 -crypt Add support for encryption -- using mcrypt or gpg where applicable 499 -cscope Enables cscope interface -- in vim for example 28 -css Enables reading of encrypted DVDs 23 -ctype Enables ctype functions 9 -cups Add support for CUPS (Common Unix Printing System) 456 -curl Adds support for client-side URL transfer library 287 -curlwrappers Adds support for using curl in streams 13 -custom-cflags Build with user-specified CFLAGS (unsupported) 350 -cvs Enable CVS (Concurrent Versions System) integration 67 -cxx Builds support for C++ (bindings, extra libraries, code generation, ...) 77 -db2 Enables support for IBM DB2 database server 18 -dbase Adds support for dbase file format 13 -dbi Enable dev-db/libdbi (database-independent abstraction layer) support 41 -dbm Adds support for generic DBM databases 16 -dbmaker Adds support for dbmaker database server 15 -dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc) 871 -dbx Adds database abstraction layer 13 -debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml 13768 -dedicated Adds support for dedicated game servers (some packages do not provide clients and servers at the same time) 354 -dga Adds DGA (Direct Graphic Access) support for X 88 -directfb Adds support for DirectFB layer (library for FB devices) 161 -djvu support DjVu, a PDF-like document format esp. suited for scanned documents 46 -doc Adds extra documentation (API, Javadoc, etc) 12028 -dri Enable direct rendering: used for accelerated 3D and some 2D, like DMA 53 -dts Enables DTS Coherent Acoustics decoder support 25 -dv Enables support for a codec used by many camcorders 54 -dvb Adds support for DVB (Digital Video Broadcasting) 68 -dvd Adds support for DVDs 64 -dvdr Adds support for DVD writer hardware (e.g. in xcdroast) 31 -eds Enables support for Evolution-Data-Server (EDS) 141 -emacs Adds support for GNU Emacs 559 -emboss Adds support for the European Molecular Biology Open Software Suite 24 -empress Adds support for the Empress database server 15 -empress-bcs Adds local access support for the Empress database server 15 -encode Adds support for encoding of audio or video files 69 -enscript Add enscript support to colourize code stored in the repository 16 -esd Adds support for media-sound/esound (Enlightened Sound Daemon) 488 -esoob Adds support for Easysoft OOD database 15 -evo Adds support for mail-client/evolution 32 -examples Install examples, usually source code 2686 -exif Adds support for reading EXIF headers from JPEG and TIFF images 186 -expat Enable the use of dev-libs/expat for XML parsing 92 -fam Enable FAM (File Alteration Monitor) support 173 -fastcgi Add support for the FastCGI interface 77 -fbcon Adds framebuffer support for the console, via the kernel 184 -ffmpeg Enable ffmpeg-based audio/video codec support 320 -fftw Use FFTW library for computing Fourier transforms 163 -firebird Adds support for the Firebird relational database 115 -firefox Build against Firefox instead of Seamonkey/Mozilla 22 -flac Adds support for FLAC: Free Lossless Audio Codec 343 -flatfile Adds dbm support for flat files 17 -fltk Adds support for the Fast Light Toolkit gui interface 59 -fontconfig Support for configuring and customizing font access via media-libs/fontconfig 102 -foomaticdb Adds support for the foomatic printing driver database 19 -fortran Adds support for fortran (formerly f77) 287 -freetds Adds support for the TDS protocol to connect to MSSQL/Sybase databases 47 -freewnn Adds support for FreeWnn kana to kanji conversion engine 15 -frontbase Adds support for the frontbase sql server 15 -ftp Adds FTP (File Transfer Protocol) support 70 -gcj Enable building with gcj (The GNU Compiler for the Javatm Programming Language) 215 -gd Adds support for media-libs/gd (to generate graphics on the fly) 119 -gd-external Use the external version of gd rather than the bundled one (possibly dangerous) 15 -gdbm Adds support for sys-libs/gdbm (GNU database libraries) 267 -geoip Add geoip support for country and city lookup based on IPs 75 -ggi Adds support for media-libs/libggi (non-X video api/drivers) 79 -gif Adds GIF image support 215 -gimp Build a plugin for the GIMP 50 -ginac Adds sci-mathematics/ginac (symbolic math) support 4 -glut Build an OpenGL plugin using the GLUT library 29 -gmp Adds support for dev-libs/gmp (GNU MP library) 135 -gnome Adds GNOME support 1085 -gnome-keyring Enable support for storing passwords via gnome-keyring 171 -gnuplot Enable support for gnuplot (data and function plotting) 44 -gnustep Adds integration with GNUstep environment 8 -gnutls Adds support for net-libs/gnutls (TLS 1.0 and SSL 3.0 support) 559 -gphoto2 Adds digital camera support 112 -gpm Adds support for sys-libs/gpm (Console-based mouse driver) 185 -gps Adds support for Global Positioning System 49 -graphviz Adds support for the Graphviz library 129 -gsl Use the GNU scientific library for calculations 55 -gsm Adds support for the gsm lossy speech compression codec 153 -gstreamer Adds support for media-libs/gstreamer (Streaming media) 295 -gtk Adds support for x11-libs/gtk+ (The GIMP Toolkit) 1414 -gtkhtml Adds support for gnome-extra/gtkhtml 33 -guile Adds support for the guile Scheme interpreter 82 -gzip Compress files with Lempel-Ziv coding (LZ77) 279 -hal Enable Hardware Abstraction Layer (HAL) support 438 -handbook Enable handbooks generation for KDE4. 13 -hardened activate default security enhancements for toolchain (gcc, glibc, binutils) 420 -hddtemp Enable monitoring of hdd temperature (app-admin/hddtemp) 25 -hdf5 Adds support for the Hierarchical Data Format v5 38 -ibm Add support for IBM ppc64 specific systems 41 -iconv Enable support for the iconv character set conversion library 212 -icq Enable ICQ IM protocol support 8 -icu Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu 104 -idn Enable support for Internationalized Domain Names 142 -ieee1394 Enable FireWire/iLink IEEE1394 support (dv, camera, ...) 111 -imagemagick Enables support for Imagemagick (image converter) 135 -imap Adds support for IMAP (Internet Mail Application Protocol) 62 -imlib Adds support for imlib, an image loading and rendering library 80 -inifile Adds dbm support for .ini files 15 -innodb Adds innodb support for mySQL (transaction support) 3 -interbase Adds support for Interbase database 17 -iodbc Adds support for iODBC library 58 -ipod Enable support for iPod device access 76 -ipv6 Adds support for IP version 6 1553 -jabber Enable jabber IM protocol support 89 -jack Adds support for the JACK Audio Connection Kit 649 -java Adds support for Java 743 -java6 Use Java 1.6 to build package with || ( reduced deps, 1.6 features, source/target 1.6 ) 14 -javascript Enables javascript support 50 -jbig enables jbig-kit support for tiff, Hylafax, ImageMagick, etc 38 -jingle Enables voice calls for jabber 36 -joystick Add support for joysticks in all packages 112 -jpeg Adds JPEG image support 807 -jpeg2k Support for JPEG 2000, a wavelet-based image compression format 179 -kde Adds support for kde-base/kde (K Desktop Enviroment) 465 -kdeenablefinal EXPERIMENTAL: KDE ebuilds will use the enable-final flag, yielding compilation speedups at the cost of heavy mem usage and potentially causing problems. We strongly discourage setting this 3110 -kdeprefix Makes a KDE prefixed install into /usr/kde/$ if enabled or into /usr (FHS compatible) otherwise 1965 -kerberos Adds kerberos support 590 -kolab Adds support for the Kolab groupware server 24 -kontact Enable support for the KDE personal information manager (kde-base/kdepim*) 9 -ladspa Enables the ability to support ladspa plugins 103 -lame Prefer using LAME libraries for MP3 encoding support 76 -lapack Adds support for the virtual/lapack numerical library 57 -lash Adds LASH Audio Session Handler support 68 -latex Adds support for LaTeX (typesetting package) 234 -lcms Adds lcms support (color management engine) 245 -ldap Adds LDAP support (Lightweight Directory Access Protocol) 1088 -libcaca Add support for colored ASCII-art graphics 66 -libedit Use the libedit library (replacement for readline) 76 -libgda Adds GNOME Data Access support 19 -libnotify Enable desktop notification support 416 -libsamplerate Build with support for converting sample rates using libsamplerate 120 -libwww Adds libwww support (General purpose WEB API) 37 -lirc Adds support for lirc (Linux's Infra-Red Remote Control) 209 -livecd !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used during livecd building 41 -lm_sensors Adds linux lm_sensors (hardware sensors) support 48 -lua Enable Lua scripting support 221 -lzo Enables support for lzo compression 98 -m17n-lib Enable m17n-lib support 32 -mad Adds support for mad (high-quality mp3 decoder library and cli frontend) 172 -maildir Adds support for maildir (~/.maildir) style mail spools 41 -mailwrapper Adds mailwrapper support to allow multiple MTAs to be installed 67 -matroska Adds support for the matroska container format (extensions .mkv, .mka and .mks) 51 -matrox Adds Matrox MGA support to mplayer 4 -mbox Adds support for mbox (/var/spool/mail) style mail spools 82 -mcve Support for the MCVE credit card payment system 12 -memlimit Adds memory usage limiting in supporting programs 4 -mhash Adds support for the mhash library 22 -migemo Enables migemo support for Japanese 26 -mikmod Adds libmikmod support to allow playing of SoundTracker-style music files 46 -milter Adds sendmail mail filter (milter) support 23 -mime Adds MIME support 8 -minimal Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features) 769 -mmap Adds mmap (memory map) support 23 -mmx Adds support for optimizations for Pentium MMX and Athlon class processors 474 -mng Adds support for libmng (MNG images) 105 -modplug Adds libmodplug support 64 -modules Build the kernel modules 42 -mono Build Mono bindings to support dotnet type stuff 97 -motif Adds support for the Motif toolkit 108 -mozilla Adds support for the Mozilla web-browser 26 -mp3 Add support for reading mp3 files 357 -mp4 Support for MP4 container format 36 -mpeg Adds libmpeg3 support to various packages 67 -mpi Adds MPI (Message Passing Interface) layer to the apps that support it 186 -mplayer Enable mplayer support for playback or encoding 77 -msn Enable MSN Messenger IM protocol support 56 -msql Adds support for the MSQL database server 14 -mssql Adds support for Microsoft SQL Server database 65 -mtp Enable support for Media Transfer Protocol 63 -mule Adds multi-language support to XEmacs 9 -multilib On 64bit systems, if you want to be able to compile 32bit and 64bit binaries 368 -musepack Enable support for the musepack audio codec 111 -musicbrainz Lookup audio metadata using MusicBrainz community service (musicbrainz.org) 54 -mysql Adds mySQL Database support 1154 -mysqli Adds support for the improved mySQL libraries 18 -nas Adds support for network audio sound 333 -ncurses Adds ncurses support (console display library) 655 -netboot Enables network booting 27 -netcdf Enable NetCDF data format support 19 -networkmanager Enable net-misc/networkmanager support 170 -neXt Enable neXt toolkit 14 -nis Support for NIS/YP services 116 -nls Adds Native Language Support (using gettext - GNU locale utilities) 4047 -nntp Add support for newsgroups (Network News Transfer Protocol) 80 -nocd Install all files required to run the application without a CD mounted 9 -nocxx Disable support for C++ (DON'T USE THIS UNLESS YOU KNOW WHAT YOU'RE DOING) 320 -nptl Enable support for Native POSIX Threads Library, the new threading module (requires linux-2.6 or better usually) 293 -nsplugin Build plugin for browsers supporting the Netscape plugin architecture (that is almost any modern browser) 187 -ocaml Adds support/bindings for the Ocaml language 22 -ocamlopt Enables ocamlopt support (ocaml native code compiler) -- Produces faster programs (Warning: you have to disable/enable it at a global scale) 0 -oci8 Adds Oracle 8 Database Support 42 -oci8-instant-client Use dev-db/oracle-instantclient-basic as Oracle provider instead of requiring a full Oracle server install 23 -odbc Adds ODBC Support (Open DataBase Connectivity) 366 -offensive Enables potentially offensive items in packages 48 -ofx Enable support for importing (and exporting) OFX (Open Financial eXchange) data files 43 -ogg Adds support for the Ogg container format (commonly used by Vorbis, Theora and flac) 208 -old-linux Add support for linux-2.4 and older 19 -openal Adds support for the Open Audio Library 221 -openexr Support for the OpenEXR graphics file format 115 -opengl Adds support for OpenGL (3D graphics) 1142 -openmp Build support for the OpenMP (support parallel computing), requires >=sys-devel/gcc-4.2 built with USE="openmp" 283 -oracle Enable Oracle Database support 62 -osc Enables support for Open Sound Control 26 -oscar Enable Oscar (AIM/ICQ) IM protocol support 19 -oss Adds support for OSS (Open Sound System) 661 -pam Adds support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip 747 -pch Enable precompiled header support for faster compilation at the expense of disk space and memory (>=sys-devel/gcc-3.4 only) 308 -pcmcia Adds support for PCMCIA slots/devices found on laptop computers 39 -pcntl Adds support for process creation functions 15 -pcre Adds support for Perl Compatible Regular Expressions 219 -pda Adds support for portable devices 47 -pdf Adds general support for PDF (Portable Document Format), this replaces the pdflib and cpdflib flags 174 -perl Adds support/bindings for the Perl language 654 -php Include support for the PHP language 80 -plasma Build optional plasma widgets that require kde-base/libplasma 45 -plotutils Add support for plotutils (library for 2-D vector graphics) 26 -png Adds support for libpng (PNG images) 724 -policykit Use sys-auth/policykit to gain privileges 150 -portaudio Adds support for the crossplatform portaudio audio API 124 -posix Adds support for POSIX-compatible functions 12 -postgres Adds support for the postgresql database 1021 -ppds Adds support for automatically generated ppd (printing driver) files 24 -prefix Defines if a Gentoo Prefix offset installation is used 0 -prelude Adds support/bindings for the Prelude Intrusion Detection System 32 -profile Adds support for software performance analysis (will likely vary from ebuild to ebuild) 1151 -pulseaudio Adds support for PulseAudio sound server 515 -python Adds support/bindings for the Python language 1286 -qdbm Adds support for the qdbm (Quick Database Manager) library 32 -qmail-spp Adds support for qmail SMTP plugins 11 -qt4 Adds support for the Qt GUI/Application Toolkit version 4.x 358 -quicktime Adds support for OpenQuickTime 56 -radius Adds support for RADIUS authentication 78 -raw Add support for raw image formats 53 -rdesktop Adds support for the remote desktop protocol, usually used to connect to Windows servers 16 -readline Enables support for libreadline, a GNU line-editing library that almost everyone wants 596 -recode Enables support for the GNU recode library 17 -rss Enables support for RSS feeds 78 -ruby Adds support/bindings for the Ruby language 253 -samba Adds support for SAMBA (Windows File and Printer sharing) 356 -sapdb Adds support for SAP DB 16 -sasl Adds support for the Simple Authentication and Security Layer 304 -savedconfig Use this to restore your config from /etc/portage/savedconfig $/$. Make sure your USE flags allow for appropriate dependencies 83 -scanner Adds support for scanner hardware (e.g. build the sane frontend in kdegraphics) 212 -sdl Adds support for Simple Direct Layer (media library) 519 -seamonkey Adds support for the Seamonkey web-browser 18 -selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur 1049 -semantic-desktop Cross-KDE support for semantic search and information retrieval 128 -session Adds persistent session support 50 -sharedext Adds support for building shared extensions in PHP 15 -sharedmem Adds support for shared memory use 17 -shorten Adds support for the shorten audio compressor 6 -simplexml support for SimpleXML 7 -skey Enable S/Key (Single use password) authentication support 42 -slang Adds support for the slang text display library (it's like ncurses, but different) 89 -slp Adds Service Locator Protocol support 50 -smartcard Enables smartcard support 44 -smp Enable support for multiprocessors or multicore systems 36 -sndfile Adds support for libsndfile 115 -snmp Adds support for the Simple Network Management Protocol if available 221 -soap Adds support for SOAP (Simple Object Access Protocol) 34 -sockets Adds support for tcp/ip sockets 30 -socks5 Adds support for the socks5 proxy 74 -solid Adds support for the Solid database engine 16 -source Zip the sources and install them 2135 -sox Adds support for Sound eXchange (SoX) 27 -speex Adds support for the speex audio codec (used for speech) 206 -spell Adds dictionary support 466 -sqlite Adds support for sqlite - embedded sql database 667 -sqlite3 Adds support for sqlite3 - embedded sql database 90 -sse fast floating point optimization for PentiumIII+ class chips 282 -sse2 faster floating point optimization for SSE2 capable chips 257 -ssl Adds support for Secure Socket Layer connections 2196 -startup-notification Enable application startup event feedback mechanism 135 -static !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically 1169 -static-libs Build static libraries 730 -subversion Enable subversion (version control system) support 124 -suid Enable setuid root program, with potential security risks 61 -svg Adds support for SVG (Scalable Vector Graphics) 251 -svga Adds support for SVGAlib (graphics library) 168 -sybase Adds support for the Sybase SQL Database Server 17 -sybase-ct Adds support for Sybase-CT 15 -symlink Force kernel ebuilds to automatically update the /usr/src/linux symlink 699 -syslog Enables support for syslog 119 -sysvipc Support for System V-compatible inter-process communication 15 -szip Use the szip compression library 17 -taglib Enable tagging support with taglib 74 -tcl Adds support the Tcl language 302 -tcpd Adds support for TCP wrappers 330 -test Workaround to pull in packages needed to run with FEATURES=test. Portage-2.1.2 handles this internally, so don't set it in make.conf/package.use anymore 6229 -theora Adds support for the Theora Video Compression Codec 174 -threads Adds threads support for various packages. Usually pthreads 773 -tidy Adds support for HTML Tidy 32 -tiff Adds support for the TIFF image format 373 -timidity Build with Timidity++ (MIDI sequencer) support 18 -tk Adds support for Tk GUI toolkit 376 -tokenizer Adds support for the PHP file parser 9 -truetype Adds support for FreeType and/or FreeType2 fonts 359 -uclibc Enable uclibc specific patches and build or link uclibc 27 -unicode Adds support for Unicode 502 -usb Adds USB support to applications that have optional USB support (e.g. cups) 267 -v4l Enables video4linux support 206 -v4l2 Enable video4linux2 support 135 -vanilla Do not add extra patches which change default behaviour; DO NOT USE THIS ON A GLOBAL SCALE as the severity of the meaning changes drastically 469 -vcd Video CD support 35 -vhosts Adds support for installing web-based applications into a virtual-hosting environment 743 -videos Install optional video files (used in some games) 29 -vim-syntax Pulls in related vim syntax scripts 267 -vnc Enable VNC (remote desktop viewer) support 49 -voodoo3 Adds support for 3Dfx's Voodoo3 video chipset, else defaults to Voodoo4/5 support if not in USE 2 -vorbis Adds support for the OggVorbis audio codec 496 -wavpack Add support for wavpack audio compression tools 94 -wddx Adds support for Web Distributed Data eXchange 15 -wifi Enable wireless network functions 88 -win32codecs use win32codecs package for dll avi decoding support (wmv and what not) 65 -wmf Adds support for the Windows Metafile vector image format 53 -wxwidgets Adds support for wxWidgets/wxGTK GUI toolkit 121 -X Adds support for X11 2268 -x264 Enable h264 encoding using x264 87 -xattr Adds support for extended attributes (filesystem-stored metadata) 135 -Xaw3d Adds support for the 3d athena widget set 74 -xcb Support the X C-language Binding, a replacement for Xlib 61 -xcomposite Enable support for the Xorg composite extension 147 -xemacs Add support for XEmacs 51 -xface Adds xface support used to allow a small image of xface format to be included in an email via the header 'X-Face' 36 -xft Build with support for XFT font renderer (x11-libs/libXft) 81 -xine Add support for the XINE movie libraries 82 -xinerama Add support for the xinerama X11 extension, which allows you to stretch your display across multiple monitors 783 -xinetd Add support for the xinetd super-server 128 -xml Add support for XML files 565 -xmlrpc Support for xml-rpc library 57 -xmp Enable support for Extensible Metadata Platform (Adobe XMP) 53 -xosd Sends display using the X On Screen Display library 39 -xpm Adds support for XPM graphics format 61 -xscreensaver Adds support for XScreenSaver extension 51 -xsl Check/Support flag for XSL library (version 1) 17 -xulrunner Build native browser integration against xulrunner instead of firefox or seamonkey 53 -xv Adds in optional support for the Xvideo extension (an X API for video playback) 91 -xvid Adds support for xvid.org's open-source mpeg-4 codec 57 -yahoo Enable Yahoo Messenger IM protocol support 28 -yaz Adds in optional support for the Z39.50 Protocol for Information Retrieval (YAZ) 18 -zeroconf Support for DNS Service Discovery (DNS-SD) 106 -zlib Adds support for zlib (de)compression 681 -zsh-completion Enable zsh completion support 86 \ No newline at end of file diff --git a/utils/__pycache__/GenRecovers.cpython-39.pyc b/utils/__pycache__/GenRecovers.cpython-39.pyc deleted file mode 100644 index b7fa776..0000000 Binary files a/utils/__pycache__/GenRecovers.cpython-39.pyc and /dev/null differ diff --git a/utils/__pycache__/findfsdb.cpython-39.pyc b/utils/__pycache__/findfsdb.cpython-39.pyc deleted file mode 100644 index 6d4f05f..0000000 Binary files a/utils/__pycache__/findfsdb.cpython-39.pyc and /dev/null differ diff --git a/utils/__pycache__/getUses.cpython-39.pyc b/utils/__pycache__/getUses.cpython-39.pyc deleted file mode 100644 index c2f1f43..0000000 Binary files a/utils/__pycache__/getUses.cpython-39.pyc and /dev/null differ diff --git a/utils/__pycache__/package.cpython-38.pyc b/utils/__pycache__/package.cpython-38.pyc deleted file mode 100644 index 8f66de8..0000000 Binary files a/utils/__pycache__/package.cpython-38.pyc and /dev/null differ diff --git a/utils/__pycache__/package.cpython-39.pyc b/utils/__pycache__/package.cpython-39.pyc deleted file mode 100644 index 9722eb6..0000000 Binary files a/utils/__pycache__/package.cpython-39.pyc and /dev/null differ diff --git a/utils/__pycache__/utils.cpython-36.pyc b/utils/__pycache__/utils.cpython-36.pyc deleted file mode 100644 index 2f0a093..0000000 Binary files a/utils/__pycache__/utils.cpython-36.pyc and /dev/null differ diff --git a/utils/__pycache__/utils.cpython-38.pyc b/utils/__pycache__/utils.cpython-38.pyc deleted file mode 100644 index 9428706..0000000 Binary files a/utils/__pycache__/utils.cpython-38.pyc and /dev/null differ diff --git a/utils/__pycache__/utils.cpython-39.pyc b/utils/__pycache__/utils.cpython-39.pyc deleted file mode 100644 index 51788e0..0000000 Binary files a/utils/__pycache__/utils.cpython-39.pyc and /dev/null differ diff --git a/utils/findfsdb.py b/utils/findfsdb.py index d881337..b0f7838 100755 --- a/utils/findfsdb.py +++ b/utils/findfsdb.py @@ -7,9 +7,9 @@ from utils.utils import get_list_overlays, sort_install_pkg from utils.GenRecovers import ScanRecoverFile from utils.getUses import get_global_USE, get_local_USE from utils.package import search -# создаём разширеную базу пактов с предлизительно структурой -#pkg_list ={"category": [{name: name_pkg, versions:[list_version]}]} -# и клладём это всё в json +# создаём раcширенную базу пакетов с приблизительной структурой +# pkg_list ={"category": [{name: name_pkg, versions:[list_version]}]} +# и кладём это всё в json # AliaseCategory ={ @@ -17,10 +17,10 @@ AliaseCategory ={ "app-dicts":"Словари", "app-editors":"Текстовые редакторы", "www-client":"Браузеры", - "www-servers": "Сервера", + "www-servers": "Веб-серверы", 'app-etitor':"Текстовые редакторы", "game":"Игры", - "dev-lang":" Языка програмироыввние", + "dev-lang":" Языкы программирования", "media-video": "Видео", "media-sound": "Аудио", "dev-erlang":"Erlang", @@ -41,32 +41,32 @@ AliaseCategory ={ "sci-mathematics":"Математика", "sci-physics":"Физика", "app-office":"Офис", - "mail-client":"Е-Почта", - "net-dns":"DNS", + "mail-client":"Клиент e-mail", + "net-dns":"DNS-сервера", "sys-apps":"Системное", "sys-kernel":"Ядра", "11-themes":"Темы", - "app-emulation":"Виртальнизация", + "app-emulation":"Виртуализация", "x11-drivers":"Видеодрайвера", "app-antivirus":"Антивирус", "games-fps":"Шутеры", "games-kids":"Детские игры", - "games-rpg":"RPG Игры ", + "games-rpg":"RPG Игры", "games-puzzle":"Головоломки", "games-strategy":"Стратегии", - } + def create_db(): overlays = get_list_overlays() recovers = ScanRecoverFile() - pkg_list ={} - listUses= dict(LocalUSE=get_local_USE(), GlobalUSE=get_global_USE()) #[0] LocalUSE=get_local_USE(), - InstallPkgs= sort_install_pkg() - portage_list ={} - port_dir =["/var/db/repos", "/usr/portage"] + pkg_list = {} + listUses = dict(LocalUSE = get_local_USE(), GlobalUSE = get_global_USE()) #[0] LocalUSE = get_local_USE(), + InstallPkgs = sort_install_pkg() + portage_list = {} + port_dir = ["/var/db/repos", "/usr/portage"] if not os.path.exists('./pkgs.json'): print("Create ramdb") - pkg_name ="" + pkg_name = "" all_pkgs = {} with open('./pkgs.json', 'a') as fn: for p in port_dir: @@ -74,9 +74,9 @@ def create_db(): for f in files: if f.endswith('.ebuild'): #print(d +"/" + f) - pkg_name ="" + pkg_name = "" try: - #ver=int(f.replace('.ebuild', '').split('-')[-1][0]) + #ver = int(f.replace('.ebuild', '').split('-')[-1][0]) for pn in f.replace('.ebuild', '').split('-')[:-1]: pkg_name = pkg_name + pn + "-" except TypeError: @@ -120,11 +120,11 @@ def on_find(p_v): if not os.path.exists('./pkgs.json'): create_db() p = [] - ret_p ="" + ret_p = "" ret = {} with open('./pkgs.json', 'r') as fn: data = fn.read() - #pkg_list= fn.read() + #pkg_list = fn.read() pkg_list = data.split("\n") for i in pkg_list: @@ -142,7 +142,7 @@ def on_find(p_v): if __name__ == '__main__': if not os.path.exists('./pkgs.txt'): create_db() - if len(sys.argv) >=2: + if len(sys.argv) >= 2: on_find(sys.argv[1]) else: print("No element to find") diff --git a/utils/getUses.py b/utils/getUses.py index 6df50b9..e3a6372 100644 --- a/utils/getUses.py +++ b/utils/getUses.py @@ -3,15 +3,15 @@ import os, sys def get_global_USE(): - ListUSE={} + ListUSE = {} path = '/usr/portage/profiles/use.desc' with open(path) as f: - lines =f.read().split("\n") + lines = f.read().split("\n") for line in lines: if line.startswith('#'): pass else: - try: + try: ListUSE[line.split(' -')[0]] = str(line) except Exception (e): print(str(e)) @@ -19,10 +19,10 @@ def get_global_USE(): def get_local_USE(): - ListUSE={} + ListUSE = {} path = '/usr/portage/profiles/use.local.desc' with open(path) as f: - lines =f.read().split("\n") + lines = f.read().split("\n") for line in lines: if line.startswith('#'): pass diff --git a/utils/package.py b/utils/package.py index 3bcb73c..21ecdc2 100644 --- a/utils/package.py +++ b/utils/package.py @@ -10,17 +10,17 @@ portge = portage.db[portage.root]["porttree"].dbapi # API PORTAGE IN SEARCH def search(r_p): - Cat =[] + Cat = [] pkg = {} - Category ="" + Category = "" Name = "" - version ="" - USE ="" + version = "" + USE = "" Description = "" - Home_page ="" + Home_page = "" repository = "" try: - pametrs = ["HOMEPAGE", "IUSE","DESCRIPTION", "repository", "LICENSE"] + parametrs = ["HOMEPAGE", "IUSE","DESCRIPTION", "repository", "LICENSE"] #print(r_p) p_list = portge.xmatch('match-all', r_p) m_list = portge.xmatch('match-visible', r_p) @@ -29,9 +29,9 @@ def search(r_p): #print(len(p_list)) if len(p_list) != 0: for l in p_list: - params = portge.aux_get(l, pametrs) + params = portge.aux_get(l, parametrs) if str(Cat) in Category and str(l).split('/')[1].split('-')[0] in Name: - version = version + " " + str(l.replace(Name +"-", "")) + version = version + " " + str(l.replace(Name + "-", "")) if not l in m_list: version = str(version) +"[M]" else: @@ -41,15 +41,15 @@ def search(r_p): Category= str(Cat) #Name =str(l).split('/')[1].split('-')[0] if len(r_p.split('/')) >=2: - print(">=2") + print("> = 2") Name = r_p else: Name = l.split("/")[0] +"/" + r_p - version = str(l.replace(Name +"-", "")) + version = str(l.replace(Name + "-", "")) if not l in m_list: version = str(version) + "[M]" else: - version = str(version) +"[U]" + version = str(version) + "[U]" USE = params[1] Description = params[2] @@ -64,6 +64,6 @@ def search(r_p): print(str(e)) p_list = " ERROR IN Package " - pkg = {"Category": Category, "Name": Name,"version": version.split(" "), "USE":USE.split(" "), "Description": Description, "Home_page":Home_page, 'repo': str(repository) } + pkg = {"Category": Category, "Name": Name, "version": version.split(" "), "USE": USE.split(" "), "Description": Description, "Home_page": Home_page, 'repo': str(repository) } print(pkg) return pkg diff --git a/utils/utils.py b/utils/utils.py index cb5acdb..2b3a50d 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -1,193 +1,196 @@ -# -*- coding: UTF-8 -*- #!/usr/bin/env python3 -'__autor__'== 'serkus' +# -*- coding: UTF-8 -*- +'__autor__' == 'serkus' import os, sys, json from urllib import request from utils.package import search -#import xml +# import xml import xml.etree.ElementTree as ET -#Проверяем пользователь ROOT или нет + +# Проверяем пользователь ROOT или нет def is_root(): - return os.geteuid() == 0 - -#Читаем Файл посторочно + return os.geteuid() == 0 + +# Читаем Файл построчно def read_configs(filename): - param = {} - if os.path.exists(filename): - with open(filename) as f: - for line in f: - print(line) - else: - print("Path is not Found") - -#получаем список оверлеев + param = {} + if os.path.exists(filename): + with open(filename) as f: + for line in f: + print(line) + else: + print("Path is not Found") + +# Получаем список включенных оверлеев def enable_overlays(): - path='/etc/portage/repos.conf/' - + path ='/etc/portage/repos.conf/' + +# Получаем список всех оверлеев def get_list_overlays(): - overlays =[] - OverlayList={} - url = "https://qa-reports.gentoo.org/output/repos/repositories.xml" # "https://api.gentoo.org/overlays/repositories.xml" - if(os.path.exists("./overlays.json")): - with open("./overlays.json", 'a') as fn: - try: - OverlayList = json.load(fn.read()) - except Exception as e: - print(e) - else: - overlays = [] - response = request.urlopen(url) - overlay = {} - includes =[] - catalogOverls ={} - root = ET.fromstring(response.read()) - #print(root.attrib) - name = "" - #print(root.tag) - description = "" - homepage = "" - feed ="" - for d, dirs, files in os.walk('/var/db/repos'): - if(d == "/var/db/repos"): - inc = dirs - else: - break - - for child in root.findall('repo'): - name = child.find('name').text - try: - description = child.find('description').text - except AttributeError: - description = "У overlay нет описания" - try: - homepage = child.find('homepage').text - except AttributeError: - homepage = "У overlay нет домашней странички" - - try: - feed = child.find('feed').text - except AttributeError: - feed = "У overlay нет ссылки и на дерево" - - overlay =dict(name=name, description=description, homepage=homepage, feed=feed) + overlays = [] + OverlayList = {} + url = "https://qa-reports.gentoo.org/output/repos/repositories.xml" # "https://api.gentoo.org/overlays/repositories.xml" + if(os.path.exists("./overlays.json")): + with open("./overlays.json", 'a') as fn: + try: + OverlayList = json.load(fn.read()) + except Exception as e: + print(e) + else: + overlays = [] + response = request.urlopen(url) + overlay = {} + includes = [] + catalogOverls = {} + root = ET.fromstring(response.read()) + #print(root.attrib) + name = "" + #print(root.tag) + description = "" + homepage = "" + feed ="" + for d, dirs, files in os.walk('/var/db/repos'): + if(d == "/var/db/repos"): + inc = dirs + else: + break + + for child in root.findall('repo'): + name = child.find('name').text + + try: + description = child.find('description').text + except AttributeError: + description = "У overlay нет описания" + + try: + homepage = child.find('homepage').text + except AttributeError: + homepage = "У overlay нет домашней страцы" + + try: + feed = child.find('feed').text + except AttributeError: + feed = "У overlay нет ссылки на дерево" + + overlay = dict(name = name, description = description, homepage = homepage, feed = feed) - if name in inc: - includes.append(overlay) - - overlays.append(overlay) - - if " for " in description: - if description.split(" for ")[1].split(" ")[0] not in catalogOverls: - catalogOverls[description.split(" for ")[1].split(" ")[0]] =[] - catalogOverls[description.split(" for ")[1].split(" ")[0]].append(overlay) - elif "Personal overlay" in description or "personal overlay" in description: - if "Personal " not in catalogOverls: - catalogOverls["Personal"] =[] - catalogOverls["Personal"].append(overlay) - else: - if "othes" not in catalogOverls: - catalogOverls["othes"] =[] - catalogOverls["othes"].append(overlay) - - - #print(str(overlays))s - #print(len(overlays)) - with open('./overlays.json', 'a') as f: - f.write(json.dumps({"repositories": dict(all=overlays, include=includes, categores=catalogOverls)})) - #f.close() - OverlayList = dict(all=overlays, include=includes,categores=catalogOverls) - #except Exception as e: - # print(e) - #return 1 - return OverlayList # dict(all=overlays, include=includes) + if name in inc: + includes.append(overlay) + + overlays.append(overlay) + + if " for " in description: + if description.split(" for ")[1].split(" ")[0] not in catalogOverls: + catalogOverls[description.split(" for ")[1].split(" ")[0]] = [] + catalogOverls[description.split(" for ")[1].split(" ")[0]].append(overlay) + elif "Personal overlay" in description or "personal overlay" in description: + if "Personal " not in catalogOverls: + catalogOverls["Personal"] = [] + catalogOverls["Personal"].append(overlay) + else: + if "othes" not in catalogOverls: + catalogOverls["othes"] = [] + catalogOverls["othes"].append(overlay) + + + #print(str(overlays))s + #print(len(overlays)) + with open('./overlays.json', 'a') as f: + f.write(json.dumps({"repositories": dict(all = overlays, include = includes, categores = catalogOverls)})) + #f.close() + OverlayList = dict(all = overlays, include = includes, categores = catalogOverls) + #except Exception as e: + # print(e) + #return 1 + return OverlayList # dict(all = overlays, include = includes) def xml_element_to_dict(elem): - "Convert XML Element to a simple dict" - inner = dict(elem.attrib) - children = list(map(xml_element_to_dict, list(elem))) - text = elem.text and elem.text.strip() - if text: - inner['@text'] = text - if children: - inner['@children'] = children - return {elem.tag: inner} + "Convert XML Element to a simple dict" + inner = dict(elem.attrib) + children = list(map(xml_element_to_dict, list(elem))) + text = elem.text and elem.text.strip() + if text: + inner['@text'] = text + if children: + inner['@children'] = children + return {elem.tag: inner} def xml2json(xmldata): - pass - #doc = ET.parse(xmldata) - #root = root = ET.fromstring(xmldata) + pass + #doc = ET.parse(xmldata) + #root = root = ET.fromstring(xmldata) -def write_config(port=8000, Lang='ru', theme="default"): - - conf = dict(PORT=port, Lang=Lang, THEME=theme) - with open('./config.json', 'w') as f: - json.dump(conf, f) - return conf +def write_config(port = 8000, Lang ='ru', theme = "default"): + conf = dict(PORT = port, Lang = Lang, THEME = theme) + with open('./config.json', 'w') as f: + json.dump(conf, f) + return conf def read_config(): - with open('./config.json', 'r') as f: - conf = json.load(f) - return conf + with open('./config.json', 'r') as f: + conf = json.load(f) + return conf def load_config(): - conf = {} - if not os.path.exists("./config.json"): - write_config() - else: - conf = read_config() - return conf - -#SORT IN INTALL PAKAGES -#'' + conf = {} + if not os.path.exists("./config.json"): + write_config() + else: + conf = read_config() + return conf + +# SORT IN INTALL PAKAGES +# '' def sort_install_pkg(): - #pkg =scan_config_portage() - INSTALL = {} - pkg_name ="" - path = '/var/db/pkg/' - for d, dirs, files in os.walk(path): - for f in files: - try: - #ver=int(f.replace('.ebuild', '').split('-')[-1][0]) - for pn in f.replace('.ebuild', '').split('-')[:-1]: - pkg_name = pkg_name + pn + "-" - #except TypeError: - # for pn in f.replace('.ebuild', '').split('-')[:-2]: - # pkg_name = pkg_name + pn + "-" - except Exception as e: - print(e) - #print(e) - #print(pkg_name) - if pkg_name not in INSTALL: - INSTALL[d.replace(path, "").split('/')[0]] =[] - INSTALL[d.replace(path,"").split('/')[0]].append(dict(name=pkg_name[:-1], ver=f.replace(pkg_name, ""))) - """ - else: - INSTALL[d.replace(path, - "").split('/')[0]].append(dict(name=pkg_name[:-1],ver=f.replace(pkg_name, "") + #pkg =scan_config_portage() + INSTALL = {} + pkg_name ="" + path = '/var/db/pkg/' + for d, dirs, files in os.walk(path): + for f in files: + try: + #ver = int(f.replace('.ebuild', '').split('-')[-1][0]) + for pn in f.replace('.ebuild', '').split('-')[:-1]: + pkg_name = pkg_name + pn + "-" + #except TypeError: + # for pn in f.replace('.ebuild', '').split('-')[:-2]: + # pkg_name = pkg_name + pn + "-" + except Exception as e: + print(e) + #print(e) + #print(pkg_name) + if pkg_name not in INSTALL: + INSTALL[d.replace(path, "").split('/')[0]] = [] + INSTALL[d.replace(path,"").split('/')[0]].append(dict(name = pkg_name[:-1], ver = f.replace(pkg_name, ""))) + """ + else: + INSTALL[d.replace(path, + "").split('/')[0]].append(dict(name = pkg_name[:-1],ver = f.replace(pkg_name, "") if d.replace(path, "").split('/')[0] not in INSTALL: - INSTALL[d.replace(path, "").split('/')[0]] =[] + INSTALL[d.replace(path, "").split('/')[0]] = [] INSTALL[d.replace(path, "").split('/')[0]].append(f.replace(".ebuild", "") ) INSTALL[d.replace(path, - "").split('/')[0]].append(f.replace(".ebuild", "")) #dict(name=pkg_name[:-1],ver=f.replace(pkg_name, "") + "").split('/')[0]].append(f.replace(".ebuild", "")) #dict(name = pkg_name[:-1],ver = f.replace(pkg_name, "") """ #print(str(len(INSTALL))) #return json.dumps({'install_pkgs':INSTALL}) - return INSTALL + return INSTALL def scan_config_portage(): - dirs_root =["/var/db/repos", "/usr/portage"] + dirs_root = ["/var/db/repos", "/usr/portage"] config = {} i = 0 dr = {} data = {} - pf={} + pf = {} for dir_root in dirs_root: for d, dirs, files in os.walk(dir_root): print(str(d)) - i=i+1 + i += 1 for fl in files: with open(d + "/" + fl) as f: pf[str(d.split('/')[-1]) + "/"+ fl]= f.read().split('\n')