提交 a4ee6a6a 编写于 作者: G gongzt

Standardize code, modify file encoding, instance attribute definition location

上级 57a3e214
'''
Initialization of data import
    Import the data in the sqlite database into the mysql database
Import the data in the sqlite database into the mysql database
'''
import os
import pathlib
......@@ -56,6 +56,14 @@ class InitDataBase():
if self.db_type not in ['mysql', 'sqlite']:
LOGGER.logger.error("database type configuration error")
raise Exception('database type configuration error')
self._bin_provides_dicts = None
self._bin_requires_dicts = None
self._bin_package_name = None
self._bin_package_dicts = None
self._src_requires_dicts = None
self._src_packages = None
self._src_package_names = None
self._sqlite_db = None
def __read_config_file(self):
'''
......@@ -593,7 +601,7 @@ class InitDataBase():
Args:
Returns:
**Kwargsdata related to configuration file nodes
**Kwargs: data related to configuration file nodes
database_name: Name database
priority: priority
Raises:
......@@ -844,7 +852,7 @@ class SqliteDatabaseOperations():
_db_file = os.path.join(
self.database_file_folder, self.db_name)
if os.path.exists(_db_file+'.db'):
if os.path.exists(_db_file + '.db'):
os.remove(_db_file + '.db')
# create a sqlite database
......@@ -872,7 +880,7 @@ class SqliteDatabaseOperations():
try:
db_path = os.path.join(
self.database_file_folder, self.db_name+'.db')
self.database_file_folder, self.db_name + '.db')
if os.path.exists(db_path):
os.remove(db_path)
except IOError as exception_msg:
......@@ -899,7 +907,7 @@ class SqliteDatabaseOperations():
_db_file = os.path.join(
self.database_file_folder, self.db_name)
if not os.path.exists(_db_file+'.db'):
if not os.path.exists(_db_file + '.db'):
# create a sqlite database
with DBHelper(db_name=_db_file) as database:
tables = ['maintenance_info']
......
......@@ -29,6 +29,11 @@ class MergeData():
self.db_file = db_file
self.db_type = 'sqlite:///'
self.datum_database = 'maintenance.information'
self.src_requires_dicts = None
self.src_package_datas = None
self.bin_provides_dicts = None
self.bin_package_datas = None
self.mainter_infos = None
@staticmethod
def __columns(cursor):
......
......@@ -426,7 +426,7 @@ class InitDatabaseCommand(PkgshipCommand):
response = requests.post(self.write_host +
'/initsystem', data=json.dumps({'configfile': file_path}),
headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -527,7 +527,7 @@ class AllPackageCommand(PkgshipCommand):
'/packages?dbName={dbName}'.format(dbName=params.db)
try:
response = requests.get(_url)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -591,7 +591,7 @@ class UpdatePackageCommand(PkgshipCommand):
'maintainer': params.m,
'maintainlevel': params.l}),
headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -663,7 +663,7 @@ class BuildDepCommand(PkgshipCommand):
_url, data=json.dumps({'sourceName': params.packagename,
'db_list': params.dbs}),
headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -792,7 +792,7 @@ class InstallDepCommand(PkgshipCommand):
'binaryName': params.packagename,
'db_list': params.dbs
}, ensure_ascii=True), headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -969,7 +969,7 @@ class SelfBuildCommand(PkgshipCommand):
'selfbuild': str(params.s),
'withsubpack': str(params.w)}),
headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -1040,7 +1040,7 @@ class BeDependCommand(PkgshipCommand):
'withsubpack': str(params.w)
}
), headers=self.headers)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......@@ -1134,7 +1134,7 @@ class SingleCommand(PkgshipCommand):
.format(db_name=params.db, packagename=params.packagename)
try:
response = requests.get(_url)
except ConnectionError as conn_error:
except ConnErr as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册