Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
fb603897
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
30
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,体验更适合开发者的 AI 搜索 >>
提交
fb603897
编写于
9月 01, 2020
作者:
G
gongzt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
生命周期中针对disable的版本库不在创建表
上级
0518d4b3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
21 deletion
+33
-21
packageship/packageship/application/initsystem/data_import.py
...ageship/packageship/application/initsystem/data_import.py
+33
-21
未找到文件。
packageship/packageship/application/initsystem/data_import.py
浏览文件 @
fb603897
...
...
@@ -14,12 +14,12 @@ from packageship.libs.exception import DatabaseRepeatException
from
packageship.libs.exception
import
Error
from
packageship.libs.configutils.readconfig
import
ReadConfig
from
packageship.libs.log
import
Log
from
packageship.application.models.package
import
SrcP
ack
from
packageship.application.models.package
import
BinP
ack
from
packageship.application.models.package
import
BinR
equires
from
packageship.application.models.package
import
SrcR
equires
from
packageship.application.models.package
import
BinP
rovides
from
packageship.application.models.package
import
P
ackages
from
packageship.application.models.package
import
src_p
ack
from
packageship.application.models.package
import
bin_p
ack
from
packageship.application.models.package
import
bin_r
equires
from
packageship.application.models.package
import
src_r
equires
from
packageship.application.models.package
import
bin_p
rovides
from
packageship.application.models.package
import
p
ackages
from
packageship
import
system_config
LOGGER
=
Log
(
__name__
)
...
...
@@ -136,6 +136,11 @@ class InitDataBase():
LOGGER
.
logger
.
error
(
'The priority value type in the database initialization
\
configuration file is incorrect'
)
continue
lifecycle_status_val
=
database_config
.
get
(
'lifecycle'
)
if
lifecycle_status_val
not
in
(
'enable'
,
'disable'
):
LOGGER
.
logger
.
error
(
'The status value of the life cycle in the initialization
\
configuration file can only be enable or disable'
)
continue
# Initialization data
self
.
_init_data
(
database_config
)
...
...
@@ -195,7 +200,12 @@ class InitDataBase():
raise
FileNotFoundError
(
"sqlite file {src} or {bin} does not exist, please
\
check and try again"
.
format
(
src
=
src_db_file
,
bin
=
bin_db_file
))
# 3. Obtain temporary source package files and binary package files
if
self
.
__save_data
(
src_db_file
,
bin_db_file
,
self
.
database_name
,
_db_name
):
_lifecycle_status_val
=
database_config
.
get
(
'lifecycle'
)
if
self
.
__save_data
(
src_db_file
,
bin_db_file
,
self
.
database_name
,
_db_name
,
_lifecycle_status_val
):
# Update the configuration file of the database
database_content
=
{
'database_name'
:
_db_name
,
...
...
@@ -209,7 +219,6 @@ class InitDataBase():
LOGGER
.
logger
.
error
(
error_msg
)
# Delete the specified database
self
.
__del_database
(
_db_name
)
# Delete tables created in the life cycle
def
__del_database
(
self
,
db_name
):
try
:
...
...
@@ -257,7 +266,7 @@ class InitDataBase():
LOGGER
.
logger
.
error
(
sql_error
)
return
None
def
__save_data
(
self
,
src_db_file
,
bin_db_file
,
db_name
,
table_name
):
def
__save_data
(
self
,
src_db_file
,
bin_db_file
,
db_name
,
table_name
,
lifecycle_status_val
):
"""
integration of multiple data files
...
...
@@ -274,7 +283,8 @@ class InitDataBase():
as
database
:
self
.
_database
=
database
# Save data related to source package
self
.
_save_src_packages
(
db_name
,
table_name
)
self
.
_save_src_packages
(
db_name
,
table_name
,
lifecycle_status_val
)
self
.
_save_src_requires
(
db_name
)
with
DBHelper
(
db_name
=
bin_db_file
,
db_type
=
'sqlite:///'
,
complete_route_db
=
True
)
\
...
...
@@ -291,7 +301,7 @@ class InitDataBase():
else
:
return
True
def
_save_src_packages
(
self
,
db_name
,
table_name
):
def
_save_src_packages
(
self
,
db_name
,
table_name
,
lifecycle_status_val
):
"""
Save the source package data
...
...
@@ -310,25 +320,26 @@ class InitDataBase():
'{db_name}:There is no relevant data in the source
\
package provided '
.
format
(
db_name
=
db_name
))
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
packages_datas
,
SrcP
ack
)
self
.
_storage_packages
(
table_name
,
packages_datas
)
database
.
batch_add
(
packages_datas
,
src_p
ack
)
if
lifecycle_status_val
==
'enable'
:
InitDataBase
.
_storage_packages
(
table_name
,
packages_datas
)
@
staticmethod
def
__meta_model
(
table_name
):
"""
The mapping relationship of the orm model
"""
model
=
type
(
"packages"
,
(
P
ackages
,
DBHelper
.
BASE
),
{
model
=
type
(
"packages"
,
(
p
ackages
,
DBHelper
.
BASE
),
{
'__tablename__'
:
table_name
})
return
model
def
_storage_packages
(
self
,
table_name
,
package_data
):
@
staticmethod
def
_storage_packages
(
table_name
,
package_data
):
"""
Bulk storage of source code package data
"""
add_packages
=
[]
cls_model
=
InitDataBase
.
__meta_model
(
table_name
)
cls_model
=
packages
.
package_meta
(
table_name
)
pkg_keys
=
(
'name'
,
'url'
,
'rpm_license'
,
'version'
,
'release'
,
'summary'
,
'description'
)
with
DBHelper
(
db_name
=
"lifecycle"
)
as
database
:
...
...
@@ -354,6 +365,7 @@ class InitDataBase():
if
add_packages
:
database
.
batch_add
(
add_packages
,
cls_model
)
database
.
session
.
commit
()
def
_save_src_requires
(
self
,
db_name
):
"""
...
...
@@ -373,7 +385,7 @@ class InitDataBase():
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
,
SrcR
equires
)
database
.
batch_add
(
requires_datas
,
src_r
equires
)
def
_save_bin_packages
(
self
,
db_name
):
"""
...
...
@@ -403,7 +415,7 @@ class InitDataBase():
bin_packaegs
[
index
][
'src_name'
]
=
src_package_name
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
bin_packaegs
,
BinP
ack
)
database
.
batch_add
(
bin_packaegs
,
bin_p
ack
)
def
_save_bin_requires
(
self
,
db_name
):
"""
...
...
@@ -424,7 +436,7 @@ class InitDataBase():
dependency package'
.
format
(
db_name
=
db_name
))
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
requires_datas
,
BinR
equires
)
database
.
batch_add
(
requires_datas
,
bin_r
equires
)
def
_save_bin_provides
(
self
,
db_name
):
"""
...
...
@@ -445,7 +457,7 @@ class InitDataBase():
binary component '
.
format
(
db_name
=
db_name
))
with
DBHelper
(
db_name
=
db_name
)
as
database
:
database
.
batch_add
(
provides_datas
,
BinP
rovides
)
database
.
batch_add
(
provides_datas
,
bin_p
rovides
)
def
__exists_repeat_database
(
self
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录