SRPM Caching
by Nathaniel McCallum
So apparently copr caches SRPMs based on the URL. If you create a new
build using the same URL as a previous failed build it doesn't download
the new SRPM. I suspect that the behavior should be to never cache for
failed builds.
Alternatively, if you want to cache in that case, you should cache not
based on URL but based on the Etag header. This ensures that if the
contents change, you will always get the new SRPM.
Nathaniel
11 years, 1 month
[copr] master: Handle expired API token and rename list function to listcoprs (c9293f7)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit c9293f7fadfb01abe7b7a974b06873925bbd56aa
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sun Mar 10 09:56:15 2013 +0100
Handle expired API token and rename list function to listcoprs
>---------------------------------------------------------------
copr_cli/main.py | 2 +-
copr_cli/subcommands.py | 29 ++++++++++++++++++++++++-----
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/copr_cli/main.py b/copr_cli/main.py
index 8dc35e4..449a3fa 100644
--- a/copr_cli/main.py
+++ b/copr_cli/main.py
@@ -40,7 +40,7 @@ def action_list(args):
:param args: argparse arguments provided by the user
"""
- subcommands.list(args.username)
+ subcommands.listcoprs(args.username)
def setup_parser():
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py
index 2931ca6..dc76dfb 100644
--- a/copr_cli/subcommands.py
+++ b/copr_cli/subcommands.py
@@ -41,7 +41,7 @@ def get_api_url():
return '%s/api' % copr_url
-def list(username=None):
+def listcoprs(username=None):
""" List all the copr of a user. """
user = {}
if not username:
@@ -55,6 +55,16 @@ def list(username=None):
user['username'] = username
req = requests.get(url, params=user)
+
+ if '<title>Sign in Coprs</title>' in req.text:
+ print 'Invalid API token'
+ return
+
+ output = json.loads(req.text)
+ if req.status_code != 200:
+ print 'Something went wrong:\n {0}'.format(output['error'])
+ return
+
output = json.loads(req.text)
columns = []
values = []
@@ -140,11 +150,15 @@ def create(name, chroots=[], description=None, instructions=None,
req = requests.post(URL,
auth=(user['username'], user['token']),
data=data)
+ if '<title>Sign in Coprs</title>' in req.text:
+ print 'Invalid API token'
+ return
+
output = json.loads(req.text)
- if output['output'] == 'ok':
- print output['message']
+ if req.status_code != 200:
+ print 'Something went wrong:\n {0}'.format(output['error'])
else:
- print 'Something went wrong:\n {0}'.format(output['error'])
+ print output['message']
def build(copr, pkgs, memory, timeout):
@@ -164,8 +178,13 @@ def build(copr, pkgs, memory, timeout):
req = requests.post(URL,
auth=(user['username'], user['token']),
data=data)
+
+ if '<title>Sign in Coprs</title>' in req.text:
+ print 'Invalid API token'
+ return
+
output = json.loads(req.text)
if req.status_code != 200:
- print 'Something went wrong:\n {0}'.format(output['error'])
+ print 'Something went wrong:\n {0}'.format(output['error'])
else:
print output['message']
11 years, 1 month
[copr] master: Add a README file with basic instruction on how to setup the CLI (259f6ed)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 259f6eda23ae3ffd9c442efa738a2185710b6185
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sun Mar 10 09:35:57 2013 +0100
Add a README file with basic instruction on how to setup the CLI
>---------------------------------------------------------------
copr_cli/README.rst | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/copr_cli/README.rst b/copr_cli/README.rst
new file mode 100644
index 0000000..962076b
--- /dev/null
+++ b/copr_cli/README.rst
@@ -0,0 +1,51 @@
+Copr CLI
+========
+
+Copr is designed to be a lightweight buildsystem that allows contributors
+to create packages, put them in repositories, and make it easy for users
+to install the packages onto their system. Within the Fedora Project it
+is used to allow packagers to create third party repositories.
+
+This part is a command line interface to use copr.
+
+About this project:
+-------------------
+- Webiste: https://fedorahosted.org/copr/
+- Git: http://git.fedorahosted.org/cgit/copr.git
+- Test instance: http://copr-fe.cloud.fedoraproject.org/
+
+
+Dependencies:
+-------------
+.. _python-requests: http://docs.python-requests.org/en/latest/
+.. _python-argparse: https://pypi.python.org/pypi/argparse
+
+The CLI depends on:
+
+- python (should work on 2.5, not tested)
+- `python-argparse`_ (for python < 2.7)
+- `python-requests`_
+
+Usage:
+------
+
+.. _test instance: http://copr-fe.cloud.fedoraproject.org/
+
+- Create an account on copr `test instance`_
+- Go to the API page: http://copr-fe.cloud.fedoraproject.org/api
+- Retrieve your API token
+- Create the file ``~/.config/copr``
+- In this file add the following content
+
+::
+
+ [copr-cli]
+ username = <insert here your username>
+ token = <insert here your API token>
+
+
+You should then be able to use copr-cli to list, create and build on copr.
+
+.. note:: You can use directly copr-cli to list someone's copr repo but to create
+ a copr or build packages into an existing repo you need to authenticate
+ via the API token.
11 years, 1 month
[copr] master: No need of auth when listing someone's copr (2a93e76)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2a93e762f114851f67e6403fdb854441c0d39245
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sun Mar 10 09:31:56 2013 +0100
No need of auth when listing someone's copr
>---------------------------------------------------------------
copr_cli/subcommands.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py
index 5da9c76..2931ca6 100644
--- a/copr_cli/subcommands.py
+++ b/copr_cli/subcommands.py
@@ -43,13 +43,16 @@ def get_api_url():
def list(username=None):
""" List all the copr of a user. """
- user = get_user()
+ user = {}
+ if not username:
+ user = get_user()
+ del(user['token'])
+
copr_api_url = get_api_url()
url = '{0}/owned/'.format(copr_api_url)
if username:
user['username'] = username
- del(user['token'])
req = requests.get(url, params=user)
output = json.loads(req.text)
11 years, 1 month
[copr] master: Handle reasonably the case where the config file is missing or incorrect (ccc2493)
by Pierre-YvesChibon
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit ccc2493f5a014e10547b30fa5248034845f7e80c
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Fri Feb 22 23:40:19 2013 +0100
Handle reasonably the case where the config file is missing or incorrect
If the configuration file in ~/.config/copr is missing or incorrect,
raise an error and catch it later to do something smart with it.
>---------------------------------------------------------------
copr_cli/copr_exceptions.py | 21 +++++++++++++++++++++
copr_cli/main.py | 10 +++++++---
copr_cli/subcommands.py | 21 +++++++++++++++++----
3 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/copr_cli/copr_exceptions.py b/copr_cli/copr_exceptions.py
new file mode 100644
index 0000000..555ff27
--- /dev/null
+++ b/copr_cli/copr_exceptions.py
@@ -0,0 +1,21 @@
+#-*- coding: UTF-8 -*-
+
+"""
+Exceptions for copr-cli
+"""
+
+class CoprCliException(Exception):
+ """ Basic exception class for copr-cli. """
+ pass
+
+
+class CoprCliNoConfException(CoprCliException):
+ """ Exception thrown when no config file is found. """
+ pass
+
+
+class CoprCliConfigException(CoprCliException):
+ """ Exception thrown when the config file is incomplete or
+ malformated.
+ """
+ pass
diff --git a/copr_cli/main.py b/copr_cli/main.py
index 0a68128..8dc35e4 100644
--- a/copr_cli/main.py
+++ b/copr_cli/main.py
@@ -4,6 +4,7 @@ import argparse
import sys
import subcommands
+import copr_exceptions
__version__ = '0.1.0'
__description__ = "CLI tool to run copr"
@@ -114,9 +115,12 @@ def main(argv=sys.argv[1:]):
except argparse.ArgumentTypeError, e:
print "\nError: {0}".format(e)
sys.exit(2)
- except Exception, e:
- print 'Error: {0}'.format(e)
- sys.exit(100)
+ except copr_exceptions.CoprCliException, e:
+ print "\nError: {0}".format(e)
+ sys.exit(3)
+ #except Exception, e:
+ #print 'Error: {0}'.format(e)
+ #sys.exit(100)
if __name__ == '__main__':
diff --git a/copr_cli/subcommands.py b/copr_cli/subcommands.py
index 1d561ee..5da9c76 100644
--- a/copr_cli/subcommands.py
+++ b/copr_cli/subcommands.py
@@ -1,5 +1,10 @@
#-*- coding: UTF-8 -*-
+"""
+Function actually doing the work of calling the API and handling the
+output.
+"""
+
import ConfigParser
import json
import os
@@ -7,14 +12,22 @@ import sys
import requests
+import copr_exceptions
+
def get_user():
""" Retrieve the user information from the config file. """
config = ConfigParser.ConfigParser()
- config.read(os.path.join(os.path.expanduser('~'), '.config',
- 'copr'))
- username = config.get('copr-cli', 'username', None)
- token = config.get('copr-cli', 'token', None)
+ if not config.read(os.path.join(os.path.expanduser('~'), '.config',
+ 'copr')):
+ raise copr_exceptions.CoprCliNoConfException(
+ 'No configuration file "~/.config/copr" found.')
+ try:
+ username = config.get('copr-cli', 'username', None)
+ token = config.get('copr-cli', 'token', None)
+ except ConfigParser.Error, err:
+ raise copr_exceptions.CoprCliConfigException(
+ 'Bad configuration file: %s' % err)
return {'username': username, 'token': token}
11 years, 1 month
Usage of Copr.repos
by Tomas Radej
Hi,
Can some of you guys please tell me what the Copr.repos class member is
used for?
I understand that it contains .repo files, but where will these come
from and where will they go? Are they .repos for pointing to
coprs/chroots created within the copr application, or will they be used
as external repos submitted by users for build time or even something
else?
Does the variable hold URLs or a list of strings or something else? Now
I dont't really know what the variable does and/or if I'm supposed
to touch it when implementing the generation of repo files for
coprs/chroots (TRAC ticket 21 [1]).
Thanks a lot, TR
[1] https://fedorahosted.org/copr/ticket/21
--
Tomas Radej <tradej(a)redhat.com>
11 years, 1 month
Discussion: Usage of Repos Outside of Copr
by Bohuslav Kabrda
Hi all,
the previous mail [1] from Tomas Radej made me wondering, whether we should allow adding arbitrary repos to copr. Most importantly, anyone can build package A that is totally ok in copr, but make it depend on "evil" package B from an outside repo. So when a user would try to install all the dependencies of package A, that would also require installing package B (and user might just trust that B is ok, add the outside repo and go on). So from my point of view, we can't add third party repos to generated .repo files, that's for sure.
But that brings a question whether it even makes sense to add these to copr repos. Because they would only be good for building packages, but users would never be able to reach them.
So here is my proposal:
- For now, keep the posibility of adding arbitrary repos to copr, but never make them available through .repo files.
- Consider dropping these ^^ completely (I'm not sure about this point, I'd like to hear some opinions).
- A very nice functionality would be to only add other coprs to repos. This way, we could make sure that anything user tries to install will have dependencies met and also we will have them under control. Also, that would allow us to generate RPMs with .repo files that would depend on other (e.g. copr X depends on copr Y, generated RPM for X depends on RPM for Y, Yum can download that somehow). Thoughts?
And I still hope that this would actually not destroy any of Tomas's work :)
Please comment, I'd really love to hear some opinions on this.
Thanks!
--
Regards,
Bohuslav "Slavek" Kabrda.
[1] https://lists.fedorahosted.org/pipermail/copr-devel/2013-February/000512....
11 years, 1 month
Re: Discussion: Usage of Repos Outside of Copr
by Rex Dieter
On 03/01/2013 02:26 AM, Bohuslav Kabrda wrote:
> - For now, keep the posibility of adding arbitrary repos to copr, but never make them available through .repo files.
+1 this allows the most flexibility, while keeping things relatively
safe (ie, clearly don't ever want to enable arbitrary stuff via .repos
to consumers).
-- rex
11 years, 1 month