Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : python-client
---------------------------------------------------------------
commit 6e04d7eceaa038f93344af5d0649ae7486cd3faa
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Aug 15 17:24:55 2014 +0200
[python-copr,copr-cli] fixing, cleanup
---------------------------------------------------------------
cli/copr_cli/main.py | 10 ++--------
python/copr_client/client.py | 11 +++++------
python/copr_client/responses.py | 34 +++++++++++++++++++++-------------
3 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py
index a390ceb..33244f9 100644
--- a/cli/copr_cli/main.py
+++ b/cli/copr_cli/main.py
@@ -13,18 +13,12 @@ from collections import defaultdict
from copr_client import CoprClient
import copr_client.exceptions as copr_exceptions
-# client = CoprClient.create_from_file_config()
-client = CoprClient(dict(
- login="Y29wcg==##fragphakffjdnlehuegu",
- username="vgologuz",
- token="srkqukvupebdipjfqyncohhvftiksi",
- copr_url="http://copr-fe-dev.cloud.fedoraproject.org"
-))
+client = CoprClient.create_from_file_config()
def _watch_builds(build_ids):
print("Watching build(s): (this may be safely interrupted)")
- prevstatus = defaultdict()
+ prevstatus = defaultdict(lambda: None)
failed_ids = []
watched_ids = build_ids[:]
diff --git a/python/copr_client/client.py b/python/copr_client/client.py
index 56d34a2..082b200 100644
--- a/python/copr_client/client.py
+++ b/python/copr_client/client.py
@@ -253,7 +253,8 @@ class CoprClient(object):
instructions=None, repos=None):
"""
- Modifies main project settings
+ Modifies main project settings.
+
:param projectname:
:param description:
:param instructions:
@@ -278,16 +279,14 @@ class CoprClient(object):
def create_new_build(self, projectname, pkgs,
timeout=None, memory=None, chroots=None):
"""
+ Creates new build in `projectname` copr.
:param projectname: name of copr project (without user namespace)
:param pkgs: list of packages to include in build
-
- :param timeout: ?? build timeout
-
+ :param timeout: ?build timeout
:param memory: amount of required memory for build process
:param wait: if True function wait for packages to be build
- :param result:
- :param chroots:
+ :param chroots: build only with given chroots
"""
diff --git a/python/copr_client/responses.py b/python/copr_client/responses.py
index 0dea83d..45012ce 100644
--- a/python/copr_client/responses.py
+++ b/python/copr_client/responses.py
@@ -53,7 +53,7 @@ class ProjectWrapper(object):
self.username = username
self.projectname = projectname
- self.description = description or "<No description provided>"
+ self.description = description
self.instructions = instructions
self.yum_repos = yum_repos or {}
self.additional_repos = additional_repos or {}
@@ -64,7 +64,7 @@ class ProjectWrapper(object):
out.append(" Description: {0}".format(self.description))
if self.yum_repos:
- out.append(" Yum repo(s)")
+ out.append(" Yum repo(s):")
for k in sorted(self.yum_repos.keys()):
out.append(" {0}: {1}".format(k, self.yum_repos[k]))
if self.additional_repos:
@@ -101,7 +101,7 @@ class GetProjectsListResponse(BaseResponse):
]
-class CreateProjectResponse(BaseResponse, ProjectMixin):
+class CreateProjectResponse(ProjectMixin, BaseResponse):
_simple_fields = ["message", "output"]
def __init__(self, client, response,
@@ -124,7 +124,7 @@ class CreateProjectResponse(BaseResponse, ProjectMixin):
return unicode(self.message)
-class ModifyProjectResponse(BaseResponse, ProjectMixin):
+class ModifyProjectResponse(ProjectMixin, BaseResponse):
def __init__(self, client, response,
name, description=None,
instructions=None, repos=None):
@@ -135,7 +135,7 @@ class ModifyProjectResponse(BaseResponse, ProjectMixin):
self.repos = repos
-class ProjectDetailsResponse(BaseResponse, ProjectMixin):
+class ProjectDetailsResponse(ProjectMixin, BaseResponse):
_simple_fields = ["detail", "output"]
def __init__(self, client, response, name):
@@ -154,7 +154,7 @@ class ProjectDetailsResponse(BaseResponse, ProjectMixin):
return self.get_project_details()
-class DeleteProjectResponse(BaseResponse, ProjectMixin):
+class DeleteProjectResponse(ProjectMixin, BaseResponse):
_simple_fields = ["message", "output"]
def __init__(self, client, response, name):
@@ -189,14 +189,14 @@ class BuildMixin(object):
def __str__(self):
if not self.response:
- return super(BuildStatusResponse, self).__str__()
+ return super(BuildMixin, self).__str__()
elif self.response["output"] == "ok":
return self.response["status"]
else:
return self.response["error"]
-class BuildStatusResponse(BaseResponse, BuildMixin):
+class BuildStatusResponse(BuildMixin, BaseResponse):
_simple_fields = ["status", "output", "error"]
def __init__(self, client, response, build_id):
@@ -207,7 +207,7 @@ class BuildStatusResponse(BaseResponse, BuildMixin):
return self.get_build_status()
-class BuildDetailsResponse(BaseResponse, BuildMixin):
+class BuildDetailsResponse(BuildMixin, BaseResponse):
_simple_fields = [
'status', 'error', 'submitted_by', 'results',
'src_pkg', 'started_on',
'submitted_on', 'owner', 'chroots', 'project',
'built_pkgs',
@@ -222,7 +222,7 @@ class BuildDetailsResponse(BaseResponse, BuildMixin):
return self.get_build_details()
-class CancelBuildResponse(BaseResponse, BuildMixin):
+class CancelBuildResponse(BuildMixin, BaseResponse):
_simple_fields = ["message", "output", "error"]
def __init__(self, client, response, build_id):
@@ -232,8 +232,16 @@ class CancelBuildResponse(BaseResponse, BuildMixin):
def repeat_action(self):
return self.client.cancel_build(self.build_id)
+ # def __str__(self):
+ # if not self.response:
+ # return super(CancelBuildResponse, self).__str__()
+ # elif self.response["output"] == "ok":
+ # return self.response["status"]
+ # else:
+ # return self.response["error"]
+
-class BuildRequestResponse(BaseResponse, ProjectMixin):
+class BuildRequestResponse(ProjectMixin, BaseResponse):
_simple_fields = ["message", "output", "error",
"ids"]
def __init__(self, client, response,
@@ -268,7 +276,7 @@ class ProjectChrootMixin(ProjectMixin):
self.project_name, self.chroot, pkgs=pkgs)
-class ProjectChrootDetailsResponse(BaseResponse, ProjectChrootMixin):
+class ProjectChrootDetailsResponse(ProjectChrootMixin, BaseResponse):
def __init__(self, client, response, name, chroot):
super(ProjectChrootDetailsResponse, self).__init__(client, response)
self.project_name = name
@@ -278,7 +286,7 @@ class ProjectChrootDetailsResponse(BaseResponse, ProjectChrootMixin):
return self.get_project_details()
-class ModifyProjectChrootResponse(BaseResponse, ProjectChrootMixin):
+class ModifyProjectChrootResponse(ProjectChrootMixin, BaseResponse):
def __init__(self, client, response, name, chroot, pkgs):
super(ModifyProjectChrootResponse, self).__init__(client, response)
self.project_name = name