Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
05086839
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
36
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05086839
编写于
7月 16, 2020
作者:
G
gongzt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Supplement of abnormal information when initializing and saving data
上级
6bcfa427
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
67 deletion
+64
-67
packageship/packageship/application/initsystem/data_import.py
...ageship/packageship/application/initsystem/data_import.py
+63
-64
packageship/packageship/application/models/package.py
packageship/packageship/application/models/package.py
+1
-1
packageship/setup.py
packageship/setup.py
+0
-2
未找到文件。
packageship/packageship/application/initsystem/data_import.py
浏览文件 @
05086839
...
...
@@ -58,8 +58,10 @@ class InitDataBase():
self
.
db_type
=
'mysql'
if
self
.
db_type
not
in
[
'mysql'
,
'sqlite'
]:
LOGGER
.
logger
.
error
(
"database type configuration error"
)
raise
Error
(
'database type configuration error'
)
_msg
=
"The database type is incorrectly configured.
\
The system temporarily supports only sqlite and mysql databases"
LOGGER
.
logger
.
error
(
_msg
)
raise
Error
(
_msg
)
self
.
_sqlite_db
=
None
def
__read_config_file
(
self
):
...
...
@@ -76,7 +78,8 @@ class InitDataBase():
if
not
os
.
path
.
exists
(
self
.
config_file_path
):
raise
FileNotFoundError
(
'system initialization configuration file does not exist'
)
'system initialization configuration file
\
does not exist: %s'
%
self
.
config_file_path
)
# load yaml configuration file
with
open
(
self
.
config_file_path
,
'r'
,
encoding
=
'utf-8'
)
as
file_context
:
init_database_config
=
yaml
.
load
(
...
...
@@ -100,7 +103,8 @@ class InitDataBase():
"""
if
getattr
(
self
,
'config_file_datas'
,
None
)
is
None
or
\
self
.
config_file_datas
is
None
:
raise
ContentNoneException
(
'Initialization file content is empty'
)
raise
ContentNoneException
(
'The content of the database initialization
\
configuration file is empty'
)
if
self
.
__exists_repeat_database
():
raise
DatabaseRepeatException
(
...
...
@@ -120,19 +124,23 @@ class InitDataBase():
db_name
=
'maintenance.information'
,
tables
=
[
'maintenance_info'
],
is_datum
=
True
).
create_database
()
# Obtain the maintenance information of the previous data of the system
self
.
_get_maintenance_info
()
for
database
in
self
.
config_file_datas
:
if
not
database
.
get
(
'dbname'
):
LOGGER
.
logger
.
error
(
'The database name in the database initialization configuration file is empty'
)
continue
priority
=
database
.
get
(
'priority'
)
if
not
isinstance
(
priority
,
int
)
or
priority
<
0
or
priority
>
100
:
LOGGER
.
logger
.
error
(
'The priority value type in the database initialization
\
configuration file is incorrect'
)
continue
status
=
database
.
get
(
'status'
)
if
status
not
in
[
'enable'
,
'disable'
]:
if
database
.
get
(
'status'
)
not
in
[
'enable'
,
'disable'
]:
LOGGER
.
logger
.
error
(
'The database status value in the database
\
initialization configuration file is incorrect'
)
continue
# Initialization data
self
.
_init_data
(
database
)
...
...
@@ -192,8 +200,16 @@ class InitDataBase():
raise
ContentNoneException
(
'The path to the sqlite file in the database initialization configuration
\
is incorrect '
)
# # 3. Obtain temporary source package files and binary package files
self
.
__save_data
(
src_db_file
,
bin_db_file
,
db_name
)
# 3. Obtain temporary source package files and binary package files
if
self
.
__save_data
(
src_db_file
,
bin_db_file
,
db_name
):
# Update the configuration file of the database
database_content
=
{
'database_name'
:
database
.
get
(
'dbname'
),
'priority'
:
database
.
get
(
'priority'
),
'status'
:
database
.
get
(
'status'
)
}
InitDataBase
.
__updata_settings_file
(
database_content
=
database_content
)
except
(
SQLAlchemyError
,
ContentNoneException
,
TypeError
,
Error
)
as
error_msg
:
# Delete the specified database
...
...
@@ -205,15 +221,6 @@ class InitDataBase():
self
.
_sqlite_db
.
drop_database
()
except
(
IOError
,
Error
)
as
exception_msg
:
LOGGER
.
logger
.
error
(
exception_msg
)
else
:
# Update the configuration file of the database
database_content
=
{
'database_name'
:
database
.
get
(
'dbname'
),
'priority'
:
database
.
get
(
'priority'
),
'status'
:
database
.
get
(
'status'
)
}
InitDataBase
.
__updata_settings_file
(
database_content
=
database_content
)
@
staticmethod
def
__columns
(
cursor
):
...
...
@@ -264,20 +271,26 @@ class InitDataBase():
Raises:
"""
with
DBHelper
(
db_name
=
src_db_file
,
db_type
=
'sqlite:///'
,
import_database
=
True
)
\
as
database
:
self
.
_database
=
database
# Save data related to source package
self
.
_save_src_packages
(
db_name
)
self
.
_save_src_requires
(
db_name
)
with
DBHelper
(
db_name
=
bin_db_file
,
db_type
=
'sqlite:///'
,
import_database
=
True
)
\
as
database
:
self
.
_database
=
database
# Save binary package related data
self
.
_save_bin_packages
(
db_name
)
self
.
_save_bin_requires
(
db_name
)
self
.
_save_bin_provides
(
db_name
)
try
:
with
DBHelper
(
db_name
=
src_db_file
,
db_type
=
'sqlite:///'
,
import_database
=
True
)
\
as
database
:
self
.
_database
=
database
# Save data related to source package
self
.
_save_src_packages
(
db_name
)
self
.
_save_src_requires
(
db_name
)
with
DBHelper
(
db_name
=
bin_db_file
,
db_type
=
'sqlite:///'
,
import_database
=
True
)
\
as
database
:
self
.
_database
=
database
# Save binary package related data
self
.
_save_bin_packages
(
db_name
)
self
.
_save_bin_requires
(
db_name
)
self
.
_save_bin_provides
(
db_name
)
except
(
SQLAlchemyError
,
ContentNoneException
)
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
return
False
else
:
return
True
def
_save_src_packages
(
self
,
db_name
):
"""
...
...
@@ -302,11 +315,9 @@ class InitDataBase():
src_package_item
.
get
(
'name'
),
src_package_item
.
get
(
'version'
))
packages_datas
[
index
][
'maintaniner'
]
=
maintaniner
packages_datas
[
index
][
'maintainlevel'
]
=
maintainlevel
try
:
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
packages_datas
,
src_pack
)
except
SQLAlchemyError
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
packages_datas
,
src_pack
)
def
_save_src_requires
(
self
,
db_name
):
"""
...
...
@@ -323,14 +334,10 @@ class InitDataBase():
self
.
sql
=
" select * from requires "
requires_datas
=
self
.
__get_data
()
if
requires_datas
is
None
:
LOGGER
.
logger
.
warning
(
'{db_name}: The package data that the source package depends on is
\
empty'
.
format
(
db_name
=
db_name
))
try
:
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
requires_datas
,
src_requires
)
except
SQLAlchemyError
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
raise
ContentNoneException
(
'{db_name}: The package data that the source package
\
depends on is empty'
.
format
(
db_name
=
db_name
))
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
requires_datas
,
src_requires
)
def
_save_bin_packages
(
self
,
db_name
):
"""
...
...
@@ -358,11 +365,9 @@ class InitDataBase():
LOGGER
.
logger
.
warning
(
exception_msg
)
finally
:
bin_packaegs
[
index
][
'src_name'
]
=
src_package_name
try
:
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
bin_packaegs
,
bin_pack
)
except
SQLAlchemyError
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
bin_packaegs
,
bin_pack
)
def
_save_bin_requires
(
self
,
db_name
):
"""
...
...
@@ -381,11 +386,9 @@ class InitDataBase():
raise
ContentNoneException
(
'{db_name}:There is no relevant data in the provided binary
\
dependency package'
.
format
(
db_name
=
db_name
))
try
:
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
requires_datas
,
bin_requires
)
except
SQLAlchemyError
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
requires_datas
,
bin_requires
)
def
_save_bin_provides
(
self
,
db_name
):
"""
...
...
@@ -403,12 +406,10 @@ class InitDataBase():
if
provides_datas
is
None
:
raise
ContentNoneException
(
'{db_name}:There is no relevant data in the provided
\
binary component'
.
format
(
db_name
=
db_name
))
try
:
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
provides_datas
,
bin_provides
)
except
SQLAlchemyError
as
sql_error
:
LOGGER
.
logger
.
error
(
sql_error
)
binary component '
.
format
(
db_name
=
db_name
))
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
provides_datas
,
bin_provides
)
def
_get_maintenance_info
(
self
):
"""
...
...
@@ -420,8 +421,6 @@ class InitDataBase():
SQLAlchemyError: An error occurred while executing the sql statement
"""
try
:
if
not
hasattr
(
self
,
'mainter_infos'
):
self
.
mainter_infos
=
dict
()
with
DBHelper
(
db_name
=
'maintenance.information'
)
as
database
:
for
info
in
database
.
session
.
query
(
maintenance_info
).
all
():
if
info
.
name
not
in
self
.
mainter_infos
.
keys
():
...
...
packageship/packageship/application/models/package.py
浏览文件 @
05086839
...
...
@@ -2,7 +2,7 @@
"""
Description: Database entity model mapping
"""
from
sqlalchemy
import
Column
,
Integer
,
String
,
ForeignKey
from
sqlalchemy
import
Column
,
Integer
,
String
from
packageship.libs.dbutils.sqlalchemy_helper
import
DBHelper
...
...
packageship/setup.py
浏览文件 @
05086839
...
...
@@ -30,9 +30,7 @@ setup(
'packageship.application.apps.package.function.searchdb'
,
'packageship.application.apps.package.function.self_depend'
,
'packageship.application.initsystem.data_import'
,
'packageship.application.initsystem.datamerge'
,
'packageship.application.models.package'
,
'packageship.application.models.temporarydb'
,
'packageship.application.settings'
,
'packageship.libs.__init__'
,
'packageship.libs.configutils.readconfig'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录