提交 ae010f94 编写于 作者: L LeoFang 提交者: Gitee

Merge branch 'master' of gitee.com:openeuler/openEuler-Advisor into master

......@@ -247,6 +247,20 @@ def check_gnome(info):
tags = clean_tags(tags, info)
return tags
def check_gitee(info):
resp = load_last_query_result(info)
repo_url = "https://gitee.com/" + info["src_repo"]
if resp == "":
resp = __check_git_helper(repo_url)
last_query = {}
last_query["time_stamp"] = datetime.now()
last_query["raw_data"] = resp
info["last_query"] = last_query
tags = __git_resp_to_tags(resp)
tags = clean_tags(tags, info)
return tags
def check_svn(info):
resp = load_last_query_result(info)
repo_url = info["src_repo"] + "/tags"
......
......@@ -54,7 +54,10 @@ def get_ver_tags(gt, repo, cwd_path=None):
else:
return None
vc_type = pkg_info["version_control"]
vc_type = pkg_info.get("version_control", None)
if vc_type is None:
print("Missing version_control in YAML file")
return None
if vc_type == "hg":
tags = check_upstream.check_hg(pkg_info)
elif vc_type == "github":
......@@ -69,6 +72,8 @@ def get_ver_tags(gt, repo, cwd_path=None):
tags = check_upstream.check_metacpan(pkg_info)
elif vc_type == "pypi":
tags = check_upstream.check_pypi(pkg_info)
elif vc_type == "gitee":
tags = check_upstream.check_gitee(pkg_info)
else:
print("Unsupport version control method {vc}".format(vc=vc_type))
return None
......@@ -90,6 +95,8 @@ if __name__ == "__main__":
args = parameters.parse_args()
print("Checking", args.repo)
user_gitee = gitee.Gitee()
spec_string = user_gitee.get_spec(args.repo)
if not spec_string:
......@@ -99,15 +106,34 @@ if __name__ == "__main__":
spec_file = Spec.from_string(spec_string)
cur_version = replace_macros(spec_file.version, spec_file)
print("Checking ", args.repo)
print("current version is ", cur_version)
if cur_version.startswith('v') or cur_version.startswith('V'):
cur_version = cur_version[1:]
print("Current version is", cur_version)
pkg_tags = get_ver_tags(user_gitee, args.repo, args.default)
print("known release tags:", pkg_tags)
if pkg_tags is None:
sys.exit(1)
if cur_version not in pkg_tags:
print("WARNING: Current {ver} doesn't exist in upstream. Please double check.".format(ver=cur_version))
ver_rec = version_recommend.VersionRecommend(pkg_tags, cur_version, 0)
print("Latest version is", ver_rec.latest_version)
print("Maintain version is", ver_rec.maintain_version)
if cur_version != ver_rec.latest_version:
if args.push:
user_gitee.post_issue(args.repo, "Upgrade to latest release", """Dear {repo} maintainer:
We found the latest version of {repo} is {ver}, while the current version in openEuler mainline is {cur_ver}.
Please consider upgrading.
Yours openEuler Advisor.
If you think this is not proper issue, Please visit https://gitee.com/openeuler/openEuler-Advisor.
Issues and feedbacks are welcome.""".format(repo=args.repo, ver=ver_rec.latest_version, cur_ver=cur_version))
......@@ -214,6 +214,9 @@ class VersionTypeXYZW(VersionType):
version_list.append(re.split(r'[._-]', version)) # 将 version 拆分为列表,方便后续比较
x = '0'
for version in version_list: # 第一轮比较取出最大的第一位
if int(version[0]) > 1000: # consider it an useless exception
continue
if self._compare(x, version[0]) < 0:
x = version[0]
......@@ -361,6 +364,8 @@ class VersionTypeXYZ(VersionType):
version_list.append(re.split(r'[._-]', version)) # 将 version 拆分为列表,方便后续比较
x = '0'
for version in version_list: # 第一轮比较取出最大的第一位
if int(version[0]) > 1000: # consider it an useless exception
continue
if self._compare(x, version[0]) < 0:
x = version[0]
......@@ -464,6 +469,9 @@ class VersionTypeXY(VersionType):
version_list.append(re.split(r'[._-]', version)) # 将 version 拆分为列表,方便后续比较
x = '0'
for version in version_list: # 第一轮比较取出最大的第一位
if int(version[0]) > 1000: # consider it an useless exception
continue
if self._compare(x, version[0]) < 0:
x = version[0]
......@@ -576,6 +584,9 @@ class VersionTypeX(VersionType):
version_list.append(re.split(r'[._-]', version)) # 将 version 拆分为列表,方便后续比较
x = '0'
for version in version_list: # 第一轮比较取出最大的第一位
if int(version[0]) > 1000: # consider it an useless exception
continue
if self._compare(x, version[0]) < 0:
x = version[0]
......@@ -941,7 +952,7 @@ class VersionTypeXYymmZ(VersionType):
return False
year = str(digital_list[1][:2])
month = str(digital_list[1][-2:])
if year > datetime.datetime.now().year[-2:]: # 年份不能大于当前年份,不用考虑20000 年前的情况
if year > str(datetime.datetime.now().year)[-2:]: # 年份不能大于当前年份,不用考虑2000 年前的情况
return False
if month > '12' or month == '0':
return False
......
---
version_control: gitlab.gnome
src_repo: gnome-icon-theme-extras
src_repo: Archive/gnome-icon-theme-extras
tag_prefix: "^v"
separator: "."
last_query:
......
---
version_control: gitlab.gnome
src_repo: gnome-icon-theme-symbolic
src_repo: Archive/gnome-icon-theme-symbolic
tag_prefix: "^v"
separator: "."
last_query:
......
......@@ -5,7 +5,7 @@ Blueprint collection trying to page
from packageship.application.apps.package import package, api as package_api
blue_point = [
(package, package_api)
(package, package_api),
]
__all__ = ['blue_point']
......@@ -42,6 +42,7 @@ class ResponseCode():
FILE_NOT_FOUND = "4006"
# Database operation module error status code
DELETE_DB_ERROR = "40051"
SERVICE_ERROR = "50000"
CONFIGFILE_PATH_EMPTY = "50001"
FAILED_CREATE_DATABASE_TABLE = "50002"
TYPE_ERROR = "50003"
......@@ -64,7 +65,8 @@ class ResponseCode():
TYPE_ERROR: "The source code and binary path types in the initialization file are abnormal",
DATA_MERGE_ERROR: "abnormal multi-file database integration",
FILE_NOT_FIND_ERROR: "system initialization configuration file does not exist",
DIS_CONNECTION_DB: "Unable to connect to the database, check the database configuration"}
DIS_CONNECTION_DB: "Unable to connect to the database, check the database configuration",
SERVICE_ERROR: "An exception occurred in the system, please try again later"}
@classmethod
def response_json(cls, code, data=None):
......
......@@ -211,6 +211,7 @@ class DBHelper():
self.session.add(entity)
except SQLAlchemyError as sql_error:
self.session.rollback()
raise Error(sql_error)
else:
self.session.commit()
......@@ -246,6 +247,7 @@ class DBHelper():
dicts
)
except SQLAlchemyError as sql_error:
self.session.rollback()
raise Error(sql_error)
else:
self.session.commit()
......@@ -24,11 +24,13 @@ def setup_log(config=None):
_level = 'INFO'
logging.basicConfig(level=_level)
path = READCONFIG.get_config('LOG', 'log_path')
if path is None:
log_name = READCONFIG.get_config('LOG', 'log_name')
if log_name is None:
log_name = 'log_info.log'
log_name = READCONFIG.get_config('LOG', 'log_name')
if not log_name:
log_name = 'log_info.log'
if not path:
path = os.path.join(LOG_FOLDER_PATH, log_name)
else:
path = os.path.join(path, log_name)
if not os.path.exists(path):
try:
os.makedirs(os.path.split(path)[0])
......@@ -53,17 +55,20 @@ class Log():
def __init__(self, name=__name__, path=None):
self.__name = name
self.__path = path
self.__file_handler = None
if self.__path is None:
log_name = READCONFIG.get_config('LOG', 'log_name')
if not log_name:
log_name = 'log_info.log'
if path:
self.__path = os.path.join(LOG_FOLDER_PATH, path)
else:
self.__path = READCONFIG.get_system('log_path')
log_name = READCONFIG.get_config('LOG', 'log_name')
if log_name is None:
log_name = 'log_info.log'
if self.__path is None:
if not self.__path:
self.__path = os.path.join(LOG_FOLDER_PATH, log_name)
else:
self.__path = os.path.join(LOG_FOLDER_PATH, path)
else:
self.__path = os.path.join(self.__path, log_name)
if not os.path.exists(self.__path):
try:
......
......@@ -25,6 +25,10 @@ write_ip_addr=127.0.0.1
query_ip_addr=127.0.0.1
; The address of the remote service, the command line can directly
; call the remote service to complete the data request
remote_host=https://api.openeuler.org/pkgmanage
[DATABASE]
......
......@@ -84,9 +84,10 @@ class BaseCommand():
wirte_port = self._read_config.get_system('write_port')
write_ip = self._read_config.get_system('write_ip_addr')
if not all([write_ip, wirte_port]):
raise Error(
"The system does not configure the relevant port and ip correctly")
_write_host = self.__http + write_ip + ":" + wirte_port
setattr(self, 'write_host', _write_host)
def load_read_host(self):
......@@ -101,10 +102,21 @@ class BaseCommand():
read_port = self._read_config.get_system('query_port')
read_ip = self._read_config.get_system('query_ip_addr')
if all([read_ip, read_port]):
_read_host = self.__http + read_ip + ":" + read_port
_read_host = self.__http + read_ip + ":" + read_port
setattr(self, 'read_host', _read_host)
setattr(self, 'read_host', _read_host)
def _set_read_host(self, remote=False):
"""
Set read domain name
"""
if remote:
_host = self._read_config.get_system('remote_host')
self.read_host = _host
if self.read_host is None:
raise Error(
"The system does not configure the relevant port and ip correctly")
class PkgshipCommand(BaseCommand):
......@@ -161,9 +173,9 @@ class PkgshipCommand(BaseCommand):
for command_params in self.params:
self.parse.add_argument( # pylint: disable=E1101
command_params[0],
type=eval(command_params[1]), # pylint: disable=W0123
help=command_params[2],
default=command_params[3])
default=command_params[3],
action=command_params[4])
@classmethod
def parser_args(cls):
......@@ -361,7 +373,8 @@ class RemoveCommand(PkgshipCommand):
super(RemoveCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'rm', help='delete database operation')
self.params = [('db', 'str', 'name of the database operated', '')]
self.params = [
('db', 'str', 'name of the database operated', '', 'store')]
def register(self):
"""
......@@ -425,7 +438,7 @@ class InitDatabaseCommand(PkgshipCommand):
self.parse = PkgshipCommand.subparsers.add_parser(
'init', help='initialization of the database')
self.params = [
('-filepath', 'str', 'name of the database operated', '')]
('-filepath', 'str', 'name of the database operated', '', 'store')]
def register(self):
"""
......@@ -486,7 +499,8 @@ class UpdateDatabaseCommand(PkgshipCommand):
self.parse = PkgshipCommand.subparsers.add_parser(
'updatedb', help='database update operation')
self.params = [('db', 'str', 'name of the database operated', '')]
self.params = [
('db', 'str', 'name of the database operated', '', 'store')]
def register(self):
"""
......@@ -533,7 +547,10 @@ class AllPackageCommand(PkgshipCommand):
'list', help='get all package data')
self.table = self.create_table(
['packagenames', 'database', 'version', 'license'])
self.params = [('-db', 'str', 'name of the database operated', '')]
self.params = [('-db', 'str', 'name of the database operated', '', 'store'),
('-remote', 'str', 'The address of the remote service',
False, 'store_true'),
]
def register(self):
"""
......@@ -558,6 +575,7 @@ class AllPackageCommand(PkgshipCommand):
Raises:
ConnectionError: Request connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + \
'/packages?dbName={dbName}'.format(dbName=params.db)
try:
......@@ -592,10 +610,10 @@ class UpdatePackageCommand(PkgshipCommand):
self.parse = PkgshipCommand.subparsers.add_parser(
'updatepkg', help='update package data')
self.params = [
('packagename', 'str', 'Source package name', ''),
('db', 'str', 'name of the database operated', ''),
('-m', 'str', 'Maintainers name', ''),
('-l', 'int', 'database priority', 1)
('packagename', 'str', 'Source package name', '', 'store'),
('db', 'str', 'name of the database operated', '', 'store'),
('-m', 'str', 'Maintainers name', '', 'store'),
('-l', 'int', 'database priority', 1, 'store'),
]
def register(self):
......@@ -664,7 +682,8 @@ class BuildDepCommand(PkgshipCommand):
'builddep', help='query the compilation dependencies of the specified package')
self.collection = True
self.params = [
('packagename', 'str', 'source package name', ''),
('packagename', 'str', 'source package name', '', 'store'),
('-remote', 'str', 'The address of the remote service', False, 'store_true')
]
self.collection_params = [
('-dbs', 'Operational database collection')
......@@ -698,6 +717,8 @@ class BuildDepCommand(PkgshipCommand):
Raises:
ConnectionError: Request connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + '/packages/findBuildDepend'
try:
response = requests.post(
......@@ -741,7 +762,8 @@ class InstallDepCommand(PkgshipCommand):
'installdep', help='query the installation dependencies of the specified package')
self.collection = True
self.params = [
('packagename', 'str', 'source package name', ''),
('packagename', 'str', 'source package name', '', 'store'),
('-remote', 'str', 'The address of the remote service', False, 'store_true')
]
self.collection_params = [
('-dbs', 'Operational database collection')
......@@ -829,6 +851,8 @@ class InstallDepCommand(PkgshipCommand):
Raises:
ConnectionError: requests connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + '/packages/findInstallDepend'
try:
response = requests.post(_url, data=json.dumps(
......@@ -877,10 +901,11 @@ class SelfBuildCommand(PkgshipCommand):
self.src_package_table = self.create_table([
'src name', 'version', 'database'])
self.params = [
('packagename', 'str', 'source package name', ''),
('-t', 'str', 'Source of data query', 'binary'),
('-w', 'str', 'whether to include other subpackages of binary', 0),
('-s', 'str', 'whether it is self-compiled', 0)
('packagename', 'str', 'source package name', '', 'store'),
('-t', 'str', 'Source of data query', 'binary', 'store'),
('-w', 'str', 'whether to include other subpackages of binary', 0, 'store'),
('-s', 'str', 'whether it is self-compiled', 0, 'store'),
('-remote', 'str', 'The address of the remote service', False, 'store_true')
]
self.collection_params = [
......@@ -1020,6 +1045,7 @@ class SelfBuildCommand(PkgshipCommand):
Raises:
ConnectionError: requests connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + '/packages/findSelfDepend'
try:
response = requests.post(_url,
......@@ -1067,9 +1093,10 @@ class BeDependCommand(PkgshipCommand):
self.parse = PkgshipCommand.subparsers.add_parser(
'bedepend', help='dependency query for the specified package')
self.params = [
('packagename', 'str', 'source package name', ''),
('db', 'str', 'name of the database operated', ''),
('-w', 'str', 'whether to include other subpackages of binary', 0),
('packagename', 'str', 'source package name', '', 'store'),
('db', 'str', 'name of the database operated', '', 'store'),
('-w', 'str', 'whether to include other subpackages of binary', 0, 'store'),
('-remote', 'str', 'The address of the remote service', False, 'store_true')
]
def register(self):
......@@ -1095,6 +1122,7 @@ class BeDependCommand(PkgshipCommand):
Raises:
ConnectionError: requests connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + '/packages/findBeDepend'
try:
response = requests.post(_url, data=json.dumps(
......@@ -1138,8 +1166,9 @@ class SingleCommand(PkgshipCommand):
self.parse = PkgshipCommand.subparsers.add_parser(
'single', help='query the information of a single package')
self.params = [
('packagename', 'str', 'source package name', ''),
('-db', 'str', 'name of the database operated', '')
('packagename', 'str', 'source package name', '', 'store'),
('-db', 'str', 'name of the database operated', '', 'store'),
('-remote', 'str', 'The address of the remote service', False, 'store_true')
]
def register(self):
......@@ -1195,6 +1224,7 @@ class SingleCommand(PkgshipCommand):
Raises:
ConnectionError: requests connection error
"""
self._set_read_host(params.remote)
_url = self.read_host + \
'/packages/packageInfo?dbName={db_name}&sourceName={packagename}' \
.format(db_name=params.db, packagename=params.packagename)
......
......@@ -3,7 +3,6 @@
Description: Entry for project initialization and service startupc
"""
import os
from flask_script import Manager
from packageship.libs.exception import Error
from packageship.libs.configutils.readconfig import ReadConfig
......
Name: pkgship
Version: 1.0
Release: 4
Release: 5
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so no.
License: Mulan 2.0
URL: https://gitee.com/openeuler/openEuler-Advisor
......@@ -61,6 +61,9 @@ rm -rf %{python3_sitelib}/packageship/build %{python3_sitelib}/packageship/dist
%changelog
* Mon Aug 10 2020 Zhengtang Gong <gongzhengtang@huawei.com> - 1.0-5
- Command line supports calling remote services
* Wed Aug 5 2020 Yiru Wang <wangyiru1@huawei.com> - 1.0-4
- change Requires rpm pakcages' name to latest one
......
......@@ -261,7 +261,21 @@ patch-tracking-cli query --server <LISTEN> --table issue
patch-tracking-cli query --server 127.0.0.1:5001 --table issue
```
### 4.4 码云查看 issue 及 PR
### 4.4 删除 Tracking 跟踪项数据
```shell script
patch-tracking-cli delete --server SERVER --user USER --password PWD --table TABLE --repo REPO [--branch BRANCH]
```
可以删除指定repo和branch的单条数据;也可直接删除指定repo下所有branch的数据。
例如:
```shell script
patch-tracking-cli delete --server 127.0.0.1:5001 --user admin --password Test@123 --repo testPatchTrack/testPatch1 --branch master
```
### 4.5 码云查看 issue 及 PR
登录Gitee上进行跟踪的软件项目,在该项目的Issues和Pull Requests页签下,可以查看到名为`[patch tracking] TIME`,例如` [patch tracking] 20200713101548`的条目。
......
......@@ -24,6 +24,7 @@ class ResponseCode:
DELETE_DB_ERROR = "6001"
CONFIGFILE_PATH_EMPTY = "6002"
DIS_CONNECTION_DB = "6003"
DELETE_DB_NOT_FOUND = "6005"
CODE_MSG_MAP = {
SUCCESS: "Successful Operation!",
......@@ -36,7 +37,8 @@ class ResponseCode:
GITEE_CONNECTION_ERROR: "Unable to connect to the gitee",
DELETE_DB_ERROR: "Failed to delete database",
CONFIGFILE_PATH_EMPTY: "Initialization profile does not exist or cannot be found",
DIS_CONNECTION_DB: "Unable to connect to the database, check the database configuration"
DIS_CONNECTION_DB: "Unable to connect to the database, check the database configuration",
DELETE_DB_NOT_FOUND: "The tracking you want to delete does not exist"
}
@classmethod
......
......@@ -30,14 +30,23 @@ def delete():
try:
if "branch" in keys:
if Tracking.query.filter(Tracking.repo == input_params['repo'], Tracking.branch == input_params['branch']):
if Tracking.query.filter(Tracking.repo == input_params['repo'],
Tracking.branch == input_params['branch']).first():
delete_tracking(input_params['repo'], input_params['branch'])
logger.info('Delete tracking repo: %s, branch: %s', input_params['repo'], input_params['branch'])
return ResponseCode.ret_message(code=ResponseCode.SUCCESS)
else:
logger.info('Delete tracking repo: %s, branch: %s not found.', input_params['repo'],
input_params['branch'])
return ResponseCode.ret_message(code=ResponseCode.DELETE_DB_NOT_FOUND)
else:
if Tracking.query.filter(Tracking.repo == input_params['repo']):
if Tracking.query.filter(Tracking.repo == input_params['repo']).first():
delete_tracking(input_params['repo'])
logger.info('Delete tracking repo: %s', input_params['repo'])
return ResponseCode.ret_message(code=ResponseCode.SUCCESS)
return ResponseCode.ret_message(code=ResponseCode.SUCCESS)
else:
logger.info('Delete tracking repo: %s not found.', input_params['repo'])
return ResponseCode.ret_message(code=ResponseCode.DELETE_DB_NOT_FOUND)
except SQLAlchemyError as err:
return ResponseCode.ret_message(code=ResponseCode.DELETE_DB_ERROR, data=err)
......
......@@ -2,6 +2,7 @@
flask app
"""
import logging.config
import os
import sys
from flask import Flask
from patch_tracking.api.issue import issue
......@@ -33,7 +34,8 @@ def check_settings_conf():
sys.exit()
app.config.from_pyfile("settings.conf")
settings_file = os.path.join(os.path.abspath(os.curdir), "settings.conf")
app.config.from_pyfile(settings_file)
check_settings_conf()
GITHUB_ACCESS_TOKEN = app.config['GITHUB_ACCESS_TOKEN']
......
......@@ -21,10 +21,7 @@ def query_table(args):
if args.table == "tracking":
url = '/'.join(['https:/', server, 'tracking'])
if args.branch and args.repo:
params = {'repo': args.repo, 'branch': args.branch}
else:
params = {'repo': args.repo}
params = {'repo': args.repo, 'branch': args.branch}
try:
ret = requests.get(url, params=params, verify=False)
if ret.status_code == 200 and ret.json()['code'] == '2001':
......@@ -119,6 +116,9 @@ def params_input_track(params, file_path=None):
"""
load tracking from command line arguments
"""
if not check_add_param(params):
return 'error', 'Check input params error'
if add_param_check_url(params, file_path) == 'error':
return 'error', 'Check input params error.'
......@@ -156,6 +156,19 @@ def params_input_track(params, file_path=None):
return 'error', 'Unexpected Error.'
def check_add_param(params):
success = True
required_params = ["repo", "branch", "scm_repo", "scm_branch", "version_control", "enabled"]
miss_params = list()
for param in required_params:
if param not in params or not params[param]:
miss_params.append(param)
success = False
if not success:
print("patch_tracking_cli add: error: the following arguments are required: --{}".format(", --".join(miss_params)))
return success
def add(args):
"""
add tracking
......@@ -212,20 +225,19 @@ def delete(args):
if ret.status_code == 200 and ret.json()['code'] == '2001':
print('Tracking delete successfully.')
return
elif ret.status_code == 200 and ret.json()['code'] == '6005':
print('Delete Nothing. Tracking not exist.')
return
print("Tracking delete failed. Error: %s", ret)
print("Tracking delete failed. Error: {}".format(ret.text))
except Exception as exception:
print('Error: Connect server error: %s', str(exception))
print('Connect server error: ' + str(exception))
def query(args):
"""
query table data
"""
if args.branch and not args.repo:
print(query_usage)
return
query table data
"""
status, ret = query_table(args)
if status == "success":
df = pandas.DataFrame.from_dict(ret.json()["data"], orient="columns")
......@@ -266,16 +278,16 @@ def dir_input_track(dir_path, args):
load tracking from dir
"""
if os.path.exists(dir_path) and os.path.isdir(dir_path):
for root, _, files in os.walk(dir_path):
if not files:
print('error: dir path empty')
return
for file in files:
if os.path.splitext(file)[-1] == ".yaml":
file_path = os.path.join(root, file)
file_input_track(file_path, args)
else:
print('Please input yaml file. Error in {}'.format(file))
dir_files = os.listdir(dir_path)
if not dir_files:
print('error: dir path empty')
return
for file in dir_files:
if os.path.isfile(os.path.join(dir_path, file)) and os.path.splitext(file)[-1] == ".yaml":
file_path = os.path.join(dir_path, file)
file_input_track(file_path, args)
else:
print('Please input yaml file. Error in {}'.format(file))
else:
print('error: dir path error. Params error in {}'.format(dir_path))
......@@ -304,7 +316,7 @@ add_usage = """
%(prog)s --server SERVER --user USER --password PASSWORD --file FILE
%(prog)s --server SERVER --user USER --password PASSWORD --dir DIR"""
parser_add = subparsers.add_parser(
'add', parents=[common_parser, authentication_parser], help="add tracking", usage=add_usage
'add', parents=[common_parser, authentication_parser], help="add tracking", usage=add_usage, allow_abbrev=False
)
parser_add.set_defaults(func=add)
parser_add.add_argument("--version_control", choices=['github'], help="upstream version control system")
......@@ -319,7 +331,7 @@ parser_add.add_argument('--dir', help='import patch tracking from files in direc
# delete
del_usage = """
%(prog)s --server SERVER --table TABLE --repo REPO [--branch BRANCH]"""
parser_delete = subparsers.add_parser('delete', parents=[common_parser, authentication_parser], help="delete tracking")
parser_delete = subparsers.add_parser('delete', parents=[common_parser, authentication_parser], help="delete tracking", allow_abbrev=False)
parser_delete.set_defaults(func=delete)
parser_delete.add_argument("--repo", required=True, help="source package repository")
parser_delete.add_argument("--branch", help="source package branch")
......@@ -327,7 +339,7 @@ parser_delete.add_argument("--branch", help="source package branch")
# query
query_usage = """
%(prog)s --server SERVER --table {tracking,issue} [--repo REPO] [--branch BRANCH]"""
parser_query = subparsers.add_parser('query', parents=[common_parser], help="query tracking/issue")
parser_query = subparsers.add_parser('query', parents=[common_parser], help="query tracking/issue", allow_abbrev=False)
parser_query.set_defaults(func=query)
parser_query.add_argument("--table", required=True, choices=["tracking", "issue"], help="query tracking or issue")
parser_query.add_argument("--repo", help="source package repository")
......
# server settings
LISTEN = "127.0.0.1:5001"
# GitHub API settings
GITHUB_ACCESS_TOKEN = "<GITHUB_ACCESS_TOKEN>"
# Gitee API settings
GITEE_ACCESS_TOKEN = "<GITEE_ACCESS_TOKEN>"
# Time interval
SCAN_DB_INTERVAL = 3600
# username
USER = "<USER>"
# password
PASSWORD = "<PASSWORD>"
......@@ -167,12 +167,12 @@ class TestTracking(unittest.TestCase):
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
self.assertEqual(
ResponseCode.INPUT_PARAMETERS_ERROR, resp_dict.get("code"), msg="Error in status code return"
ResponseCode.SUCCESS, resp_dict.get("code"), msg="Error in status code return"
)
self.assertIn("msg", resp_dict, msg="Error in data format return")
self.assertEqual(
ResponseCode.CODE_MSG_MAP.get(ResponseCode.INPUT_PARAMETERS_ERROR),
ResponseCode.CODE_MSG_MAP.get(ResponseCode.SUCCESS),
resp_dict.get("msg"),
msg="Error in status code return"
)
......@@ -395,6 +395,38 @@ class TestTracking(unittest.TestCase):
self.assertIn("data", resp_dict, msg="Error in data format return")
self.assertEqual(resp_dict.get("data"), None, msg="Error in data information return")
def test_delete_data(self):
"""
The POST interface inserts data
:return:
"""
data = {
"version_control": "github",
"scm_repo": "test_delete",
"scm_branch": "test_delete",
"scm_commit": "test_delete",
"repo": "test_delete1",
"branch": "test_delete1",
"enabled": 0
}
self.client.post("/tracking", json=data, content_type="application/json", headers=self.auth)
resp = self.client.delete("/tracking?repo=test_delete1&branch=test_delete1", content_type="application/json", headers=self.auth)
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
self.assertEqual(ResponseCode.SUCCESS, resp_dict.get("code"), msg="Error in status code return")
def test_delete_not_found(self):
"""
The POST interface inserts data
:return:
"""
resp = self.client.delete("/tracking?repo=not_found1&branch=not_found1", content_type="application/json", headers=self.auth)
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
self.assertEqual(ResponseCode.DELETE_DB_NOT_FOUND, resp_dict.get("code"), msg="Error in status code return")
if __name__ == '__main__':
unittest.main()
version_control: git
src_repo: https://git.busybox.net/buildroot
tag_prefix: ^
separator: .
version_control: git
src_repo: https://src.fedoraproject.org/rpms/ca-certificates.git
tag_prefix:
separator:
version_control: NA
src_repo: NA
tag_prefix: ca-certificates-
separator: "[-_]"
git_url: https://src.fedoraproject.org/rpms/ca-certificates.git
version_control: github
src_repo: cronie-crond/crontabs
tag_prefix: crontabs-
separator: ""
separator: "."
version_control: git
src_repo: https://git.code.sf.net/p/dump/code
tag_prefix: "^v"
separator: "."
separator: "b"
version_control: github
src_repo: libexpat/libexpat
tag_prefix: ^v
separator: .
tag_prefix: "^R_"
separator: _
version_control: gitlab.gnome
src_repo: farstream
version_control: git
src_repo: https://gitlab.freedesktop.org/farstream/farstream.git
tag_prefix: ^
separator: .
此差异已折叠。
version_control: github
src_repo: kubernetes/kubernetes
tag_prefix: "^v"
separator: "."
version_control: git
src_repo: https://gitlab.gnome.org/GNOME/libdmapsharing.git
tag_prefix: LIBDMAPSHARING
separator: _
tag_prefix: "^LIBDMAPSHARING_"
separator: "_"
version_control: github
src_repo: libevent/libevent
tag_prefix: ^v
tag_prefix: ^release-
separator: .
---
version_control: gitlab.gnome
src_repo: libgsf
tag_prefix: LIBGSF
tag_prefix: LIBGSF_
separator: _
last_query:
time_stamp: 2020-04-24 13:57:08.807496280 +00:00
......
version_control: git
src_repo: https://git.code.sf.net/p/mikmod/mikmod
tag_prefix: ^
tag_prefix: ^libmikmod-
separator: .
version_control: git
src_repo: https://git.netfilter.org/libnftnl
tag_prefix: ^libbftnl-
tag_prefix: ^libnftnl-
separator: .
git_url: https://github.com/erikd/libsamplerate
version_control: NA
src_repo: erikd/libsamplerate
tag_prefix: NA
separator: NA
version_control: github
src_repo: xiph/lcecast-libshout
src_repo: xiph/Icecast-libshout
tag_prefix: ^v
separator: .
version_control: github
src_repo: coreruleset/coreruleset
tag_prefix: ^
tag_prefix: ^v
separator: .
version_control: svn
src_repo: https://scm.gforge.inria.fr/anonscm/svn/mpfr/tags
src_repo: https://scm.gforge.inria.fr/anonscm/svn/mpfr
tag_prefix:
separator: .
......@@ -2,5 +2,5 @@
version_control: github
src_repo: python/cpython
tag_prefix: "^v?3*|^v"
seperator: "."
separator: "."
url: https://github.com/python/cpython.git
......@@ -2,5 +2,5 @@
version_control: github
src_repo: python/cpython
tag_prefix: "^v"
seperator: "."
separator: "."
url: https://github.com/python/cpython.git
version_control: github
src_repo: rust-lang/rust
tag_prefix: release-
separator: "."
version_control: github
src_repo: javaee/metro-stax-ex
tag_prefix: ^stax-ex-
separator: .
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册