From 380d278810033f2c91a51cd6fb692b355d068b66 Mon Sep 17 00:00:00 2001 From: Yiru Wang Mac Date: Sat, 29 Aug 2020 18:47:55 +0800 Subject: [PATCH 1/6] change setup.py and spec file for building --- packageship/packageship/pkgshipd | 2 ++ packageship/pkgship.spec | 7 +++++-- packageship/setup.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packageship/packageship/pkgshipd b/packageship/packageship/pkgshipd index a2e39a4f..dd09f7aa 100755 --- a/packageship/packageship/pkgshipd +++ b/packageship/packageship/pkgshipd @@ -45,6 +45,7 @@ buffer-size=$buffer_size pidfile=$OUT_PATH/manage.pid http-timeout=$http_timeout harakiri=$harakiri +enable-threads=true daemonize=$daemonize" > $OUT_PATH/manage.ini fi @@ -72,6 +73,7 @@ buffer-size=$buffer_size pidfile=$OUT_PATH/selfpkg.pid http-timeout=$http_timeout harakiri=$harakiri +enable-threads=true daemonize=$daemonize" > $OUT_PATH/selfpkg.ini fi diff --git a/packageship/pkgship.spec b/packageship/pkgship.spec index f72bf571..16e10255 100644 --- a/packageship/pkgship.spec +++ b/packageship/pkgship.spec @@ -1,6 +1,6 @@ Name: pkgship -Version: 1.0.0 -Release: 7 +Version: 1.1.0 +Release: 0 Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so no. License: Mulan 2.0 URL: https://gitee.com/openeuler/openEuler-Advisor @@ -13,6 +13,7 @@ BuildRequires: python3-prettytable python3-requests python3-flask-session python Requires: python3-pip python3-flask-restful python3-flask python3 python3-pyyaml Requires: python3-sqlalchemy python3-prettytable python3-requests Requires: python3-pyinstaller python3-flask-session python3-flask-script python3-marshmallow python3-uWSGI +Requires: python3-pandas python3-dateutil python3-XlsxWriter python3-xlrd python3-Flask-APScheduler python3-retrying %description Pkgship implements rpm package dependence ,maintainer, patch query and so no. @@ -67,6 +68,8 @@ rm -rf %{python3_sitelib}/packageship/build %{python3_sitelib}/packageship/dist %changelog +* Sat Aug 29 2020 Yiru Wang - 1.1.0-0 +- Add the RPM package life cycle and issue summary features, adding the requires * Fri Aug 21 2020 Chengqiang Bao < baochengqiang1@huawei.com > - 1.0.0-7 - Fixed a problem with command line initialization of the Filepath parameter where relative paths are not supported and paths are too long diff --git a/packageship/setup.py b/packageship/setup.py index 08488d7d..9616ed5c 100644 --- a/packageship/setup.py +++ b/packageship/setup.py @@ -28,6 +28,7 @@ setup( 'packageship.application.apps.lifecycle.function.base', 'packageship.application.apps.lifecycle.function.download_yaml', 'packageship.application.apps.lifecycle.function.gitee', + 'packageship.application.apps.lifecycle.function.concurrent', 'packageship.application.apps.lifecycle.serialize', 'packageship.application.apps.lifecycle.url', 'packageship.application.apps.lifecycle.view', -- Gitee From 43710d301f738fed46e52344bc224d0a78d1f143 Mon Sep 17 00:00:00 2001 From: Yiru Wang Mac Date: Sat, 29 Aug 2020 18:56:38 +0800 Subject: [PATCH 2/6] add buildrep --- packageship/pkgship.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packageship/pkgship.spec b/packageship/pkgship.spec index 16e10255..637b5ed1 100644 --- a/packageship/pkgship.spec +++ b/packageship/pkgship.spec @@ -10,6 +10,7 @@ BuildArch: noarch BuildRequires: python3-flask-restful python3-flask python3 python3-pyyaml python3-sqlalchemy BuildRequires: python3-prettytable python3-requests python3-flask-session python3-flask-script python3-marshmallow +BuildRequires: python3-pandas python3-dateutil python3-XlsxWriter python3-xlrd python3-Flask-APScheduler Requires: python3-pip python3-flask-restful python3-flask python3 python3-pyyaml Requires: python3-sqlalchemy python3-prettytable python3-requests Requires: python3-pyinstaller python3-flask-session python3-flask-script python3-marshmallow python3-uWSGI -- Gitee From 8caec3b7936aa8391ce874529284a913151fadf0 Mon Sep 17 00:00:00 2001 From: Yiru Wang Mac Date: Sat, 29 Aug 2020 19:16:31 +0800 Subject: [PATCH 3/6] add buildreq python3-retrying --- packageship/pkgship.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packageship/pkgship.spec b/packageship/pkgship.spec index 637b5ed1..371dc5fc 100644 --- a/packageship/pkgship.spec +++ b/packageship/pkgship.spec @@ -10,7 +10,7 @@ BuildArch: noarch BuildRequires: python3-flask-restful python3-flask python3 python3-pyyaml python3-sqlalchemy BuildRequires: python3-prettytable python3-requests python3-flask-session python3-flask-script python3-marshmallow -BuildRequires: python3-pandas python3-dateutil python3-XlsxWriter python3-xlrd python3-Flask-APScheduler +BuildRequires: python3-pandas python3-dateutil python3-XlsxWriter python3-xlrd python3-Flask-APScheduler python3-retrying Requires: python3-pip python3-flask-restful python3-flask python3 python3-pyyaml Requires: python3-sqlalchemy python3-prettytable python3-requests Requires: python3-pyinstaller python3-flask-session python3-flask-script python3-marshmallow python3-uWSGI -- Gitee From 3627e8478e6df96e44ce0c7ae998ca315fee6842 Mon Sep 17 00:00:00 2001 From: Yiru Wang Mac Date: Wed, 2 Sep 2020 17:12:20 +0800 Subject: [PATCH 4/6] modify pkgshipd restart command --- packageship/packageship/pkgshipd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packageship/packageship/pkgshipd b/packageship/packageship/pkgshipd index c6e742f0..1dc7ff8c 100755 --- a/packageship/packageship/pkgshipd +++ b/packageship/packageship/pkgshipd @@ -150,9 +150,13 @@ elif [ $1 = restart ];then if [ $service = "all" ];then stop_service "manage" "reload" stop_service "selfpkg" "reload" + start_service "manage" + start_service "selfpkg" else stop_service $service "reload" + start_service $service fi + echo "===The run log is saved into: $daemonize===" else -- Gitee From 24ed29b107b72e399e8bddb23a5dd798fe3e3bb0 Mon Sep 17 00:00:00 2001 From: Yiru Wang Mac Date: Thu, 3 Sep 2020 20:18:57 +0800 Subject: [PATCH 5/6] delet restart command and add check config file func --- packageship/packageship/package.ini | 3 +- packageship/packageship/pkgshipd | 107 ++++++++++++++++++++++++---- 2 files changed, 93 insertions(+), 17 deletions(-) diff --git a/packageship/packageship/package.ini b/packageship/packageship/package.ini index e0f4f472..0889e647 100644 --- a/packageship/packageship/package.ini +++ b/packageship/packageship/package.ini @@ -55,8 +55,7 @@ buffer-size=65536 http-timeout=600 ; Server response time harakiri=600 -; Allow multiple threads to run in the system -enable-threads=true + [TIMEDTASK] diff --git a/packageship/packageship/pkgshipd b/packageship/packageship/pkgshipd index 1dc7ff8c..27530abc 100755 --- a/packageship/packageship/pkgshipd +++ b/packageship/packageship/pkgshipd @@ -10,6 +10,91 @@ if [ ! -f "$SYS_PATH/package.ini" ]; then exit 0 fi +function check_config_file(){ + echo "[INFO] Check validation of config file." + check_null + + echo "[INFO] Check validation of ip addresses." + write_port=$(get_config "$service" "write_port") + query_port=$(get_config "$service" "query_port") + write_ip_addr=$(get_config "$service" "write_ip_addr") + query_ip_addr=$(get_config "$service" "query_ip_addr") + check_addr $write_ip_addr $write_port + check_addr $query_ip_addr $query_port + echo "[INFO] IP addresses are all valid." + + echo "[INFO] Check validation of numbers." + hour=$(get_config "$service" "hour") + minute=$(get_config "$service" "minute") + backup_count=$(get_config "$service" "backup_count") + max_bytes=$(get_config "$service" "max_bytes") + check_num $hour "hour" + check_num $backup_count "backup_count" + check_num $max_bytes "max_bytes" + echo "[INFO] All numbers are valid." + + echo "[INFO] Check validation of words." + log_level=$(get_config "$service" "log_level") + open=$(get_config "$service" "open") + check_word $log_level "INFO|DEBUG|WARNING|ERROR|CRITICAL" "log_level" + check_word $open "True|False" "open" + echo "[INFO] All words are valid." + + echo "[INFO] Config file checked valid." + +} + +function check_addr(){ + ip=$1 + ret=1 + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + ip=(${ip//\./ }) + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + ret=$? + fi + if [ $ret -ne 0 ]; then + echo "[ERROR] Invaild ip of $1" + exit 1 + fi + if [[ $2 -gt 65534 || $2 -lt 1025 ]]; then + echo "[ERROR] Invalid port of $2" + exit 1 + fi +} + +function check_null(){ + list=`cat $SYS_PATH/package.ini | grep -E ^[a-z_-]+= | awk -F '=' '{if($2 == "")print $1}'` + num=0 + for val in $list + do + num=$[$num+1] + done + if [ $num -gt 1 ]; then + echo "[ERROR] CAN NOT find all config name in: $SYS_PATH/package.ini, Please check the file:" + for val in $list + do + echo $val + done + exit 1 + fi +} + +function check_num(){ + result=`echo $1 | grep '^[[:digit:]]*$'` + if [ $? -ne 0 ]; then + echo "[ERROR] $2 should be a number." + exit 1 + fi +} + +function check_word(){ + result=`echo $1 | grep -E "$2"` + if [ $? -ne 0 ]; then + echo "[ERROR] $3 should be $2." + exit 1 + fi +} + function get_config(){ cat $SYS_PATH/package.ini | grep -E ^$2 | sed s/[[:space:]]//g | awk 'BEGIN{FS="="}{print $2}' } @@ -109,7 +194,7 @@ function stop_service(){ if [ ! -n "$1" ] then - echo "Usages: sh pkgshipd.sh start|stop|restart [manage|selfpkg]" + echo "Usages: sh pkgshipd.sh start|stop [manage|selfpkg]" exit 0 fi @@ -122,6 +207,11 @@ else exit 0 fi +if [ $1 = "start" ] +then + check_config_file +fi + create_config_file $service if [ $? -ne 0 ];then exit 0 @@ -146,20 +236,7 @@ elif [ $1 = stop ];then fi echo "===The run log is saved into: $daemonize===" -elif [ $1 = restart ];then - if [ $service = "all" ];then - stop_service "manage" "reload" - stop_service "selfpkg" "reload" - start_service "manage" - start_service "selfpkg" - else - stop_service $service "reload" - start_service $service - fi - - echo "===The run log is saved into: $daemonize===" - else - echo "Usages: sh pkgshipd.sh start|stop|restart [manage|selfpkg]" + echo "Usages: sh pkgshipd.sh start|stop [manage|selfpkg]" fi -- Gitee From 943b8384ea7d209979175aca03b7e236158d5c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=84=E7=9A=AE=E5=B0=8F=E7=AC=BC=E5=8C=85?= Date: Thu, 3 Sep 2020 20:26:13 +0800 Subject: [PATCH 6/6] delete concurrent_log_handler module --- packageship/packageship/libs/log/loghelper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packageship/packageship/libs/log/loghelper.py b/packageship/packageship/libs/log/loghelper.py index fc53bb21..3b121223 100644 --- a/packageship/packageship/libs/log/loghelper.py +++ b/packageship/packageship/libs/log/loghelper.py @@ -5,7 +5,7 @@ Logging related import os import pathlib import logging -from concurrent_log_handler import ConcurrentRotatingFileHandler +from logging.handlers import RotatingFileHandler from packageship import system_config from packageship.libs.configutils.readconfig import ReadConfig @@ -44,7 +44,7 @@ def setup_log(config=None): except FileExistsError: pathlib.Path(path).touch() - file_log_handler = ConcurrentRotatingFileHandler( + file_log_handler = RotatingFileHandler( path, maxBytes=max_bytes, backupCount=backup_count) formatter = logging.Formatter( @@ -96,7 +96,7 @@ class Log(): self.max_bytes = 314572800 def __init_handler(self): - self.__file_handler = ConcurrentRotatingFileHandler( + self.__file_handler = RotatingFileHandler( self.__path, maxBytes=self.max_bytes, backupCount=self.backup_count, encoding="utf-8") def __set_handler(self): -- Gitee