diff --git a/.gitignore b/.gitignore index e69de29..4e94aaa 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/pdc-client-0.2.0.2.tar.gz diff --git a/0001-Fix-release-component-update-logging-type.patch b/0001-Fix-release-component-update-logging-type.patch new file mode 100644 index 0000000..be09990 --- /dev/null +++ b/0001-Fix-release-component-update-logging-type.patch @@ -0,0 +1,49 @@ +From 63c4af4d2e984b7235b80de89ec2aa3236f9871f Mon Sep 17 00:00:00 2001 +From: Stanislav Ochotnicky +Date: Fri, 8 Jan 2016 17:27:49 +0100 +Subject: [PATCH] Fix release component update logging type + +release_component_id is sting at this time and logging complains when running +testsuite on F22. Partial traceback: + + File "/home/w0rm/rpmbuild/BUILD/pdc-client-0.1.9/pdc_client/plugins/component.py", line 291, in release_component_update + release_component_id, data) + File "/usr/lib64/python2.7/logging/__init__.py", line 1153, in debug + self._log(DEBUG, msg, args, **kwargs) + File "/usr/lib64/python2.7/logging/__init__.py", line 1284, in _log + self.handle(record) + File "/usr/lib64/python2.7/logging/__init__.py", line 1294, in handle + self.callHandlers(record) + File "/usr/lib64/python2.7/logging/__init__.py", line 1334, in callHandlers + hdlr.handle(record) + File "/usr/lib64/python2.7/logging/__init__.py", line 757, in handle + self.emit(record) + File "/usr/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 82, in emit + self.buffer.append(self.format(record)) + File "/usr/lib64/python2.7/logging/__init__.py", line 732, in format + return fmt.format(record) + File "/usr/lib64/python2.7/logging/__init__.py", line 471, in format + record.message = record.getMessage() + File "/usr/lib64/python2.7/logging/__init__.py", line 335, in getMessage + msg = msg % self.args +TypeError: %d format: a number is required, not str +--- + pdc_client/plugins/component.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pdc_client/plugins/component.py b/pdc_client/plugins/component.py +index a71b07b..c362613 100644 +--- a/pdc_client/plugins/component.py ++++ b/pdc_client/plugins/component.py +@@ -288,7 +288,7 @@ class ReleaseComponentPlugin(PDCClientPlugin): + data['active'] = args.active + if data: + self.logger.debug('Updating release component %d with data %r', +- release_component_id, data) ++ int(release_component_id), data) + self.client['release-components'][release_component_id]._ += data + else: + self.logger.debug('Empty data, skipping request') +-- +2.4.10 + diff --git a/pdc-client.spec b/pdc-client.spec new file mode 100644 index 0000000..6cb0e7c --- /dev/null +++ b/pdc-client.spec @@ -0,0 +1,183 @@ +%if 0%{?fedora} +%global with_python3 1 +%else +%{!?__python2: %global __python2 /usr/bin/python2} +%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")} +%endif + +# upstream has no support now, some dependencies are missing +%global with_python3 0 + +Name: pdc-client +Version: 0.2.0.2 +Release: 2%{?dist} +Summary: Client library and console client for Product Definition Center +License: MIT +URL: https://github.com/product-definition-center/pdc-client +BuildArch: noarch + +Source0: https://pypi.python.org/packages/source/p/pdc-client/pdc-client-%{version}.tar.gz + +# https://github.com/product-definition-center/pdc-client/pull/32 +Patch0: 0001-Fix-release-component-update-logging-type.patch + +BuildRequires: python2-devel +BuildRequires: python-setuptools +BuildRequires: python-nose +BuildRequires: pytest +BuildRequires: python-requests +BuildRequires: python-requests-kerberos +BuildRequires: python-mock +BuildRequires: python2-beanbag + +%if 0%{?with_python3} +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-nose +BuildRequires: python3-pytest +BuildRequires: python3-requests +BuildRequires: python3-requests-kerberos +BuildRequires: python3-mock +BuildRequires: python3-beanbag +%endif # if with_python3 + + +# default to v2 since py3 doesnt' exist really +Requires: python2-pdc-client = %{version}-%{release} + +%description +This client package contains two separate Product Definition Center clients and +API module. Both clients contain extensive built-in help. Just run the +executable with -h or --help argument. + +1. pdc_client + +This is a very simple client. Essentially this is just a little more convenient +than using curl manually. Each invocation of this client obtains a token and +then performs a single request. + +This client is not meant for direct usage, but just as a helper for integrating +with PDC from languages where it might be easier than performing the network +requests manually. + +2. pdc + +This is much more user friendly user interface. A single invocation can perform +multiple requests depending on what subcommand you used. + +The pdc client supports Bash completion if argcomplete Python package is +installed. + +3. Python API (pdc_client) + +When writing a client code interfacing with PDC server, you might find +pdc_client module handy. It provides access to the configuration defined above +and automates obtaining authorization token. + +%package -n python2-pdc-client +Summary: Python 2 client library for Product Definition Center +%{?python_provide:%python_provide python2-pdc-client} +Requires: python2-beanbag +Requires: python-requests-kerberos + +%description -n python2-pdc-client +This is a python module for interacting with Product Definition Center +programatically. It can handle common authentication and configuration of PDC +server connections + +%package -n python3-pdc-client +Summary: Python 3 client library for Product Definition Center + +%{?python_provide:%python_provide python3-pdc-client} +Requires: python3-beanbag +Requires: python3-requests-kerberos + +%description -n python3-pdc-client +This is a python module for interacting with Product Definition Center +programatically. It can handle common authentication and configuration of PDC +server connections + +%prep +%setup -q -n pdc-client-%{version} + +%patch0 -p1 + +%if 0%{?with_python3} +rm -rf %{py3dir} +cp -a . %{py3dir} +find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|' +%endif # with_python3 + +find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|' + +%build +%py2_build + +%if 0%{?with_python3} +%py3_build +%endif # with_python3 + +%check +%{__python2} setup.py nosetests || exit 1 + +%if 0%{?with_python3} +pushd %{py3dir} +%{__python3} setup.py nosetests || exit 1 +popd +%endif # with_python3 + +%install +%py2_install +%if 0%{?with_python3} +py3_install +%endif # with_python3 + +mkdir -p %{buildroot}/%{_mandir}/man1 +cp docs/pdc_client.1 %{buildroot}/%{_mandir}/man1/ + +mkdir -p %{buildroot}/%{_sysconfdir}/bash_completion.d/ +cp pdc.bash %{buildroot}/%{_sysconfdir}/bash_completion.d/ + +mkdir -p %{buildroot}/%{_sysconfdir}/pdc +cat > %{buildroot}/%{_sysconfdir}/pdc/client_config.json << EOF +{ + "dev": { + "host": "https://pdc.fedoraproject.org/rest_api/v1/", + "develop": false, + "insecure": false + } +} +EOF + + +%files +%doc README.markdown +%{_mandir}/man1/pdc_client.1* +%{_sysconfdir}/bash_completion.d +%dir %{_sysconfdir}/pdc +%config(noreplace) %{_sysconfdir}/pdc/client_config.json +%{_bindir}/pdc +%{_bindir}/pdc_client + +%files -n python2-pdc-client +%doc README.markdown +%license LICENSE +%{python_sitelib}/pdc_client* + +%if 0%{?with_python3} +%files -n python3-pdc-client +%doc README.markdown +%license LICENSE +%{python3_sitelib}/pdc_client* +%endif # with_python3 + + +%changelog +* Mon Feb 08 2016 Ralph Bean - 0.2.0.2-2 +- Point default configuration at Fedora's prod instance. + +* Fri Jan 22 2016 Stanislav Ochotnicky - 0.2.0.2-1 +- Rebase to latest upstream + +* Mon Jan 11 2016 Stanislav Ochotnicky - 0.1.9-1 +- Initial version diff --git a/sources b/sources index e69de29..37647fa 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +c7dc288dab145a3e96cd54a37deb4665 pdc-client-0.2.0.2.tar.gz