[med-svn] [Git][med-team/python-etelemetry][master] 5 commits: Upstream moved from personal mgxd to sensein organization on github

Yaroslav Halchenko gitlab at salsa.debian.org
Sun Mar 22 18:25:43 GMT 2020



Yaroslav Halchenko pushed to branch master at Debian Med / python-etelemetry


Commits:
0b395ca5 by Yaroslav Halchenko at 2020-03-22T13:03:27-04:00
Upstream moved from personal mgxd to sensein organization on github

- - - - -
6ca5221b by Yaroslav Halchenko at 2020-03-22T13:03:53-04:00
New upstream version 0.2.0
- - - - -
36062ff4 by Yaroslav Halchenko at 2020-03-22T13:03:53-04:00
Update upstream source from tag 'upstream/0.2.0'

Update to upstream version '0.2.0'
with Debian dir 894b858cb39c7ce96ad7921b7d9b83b01821085e
- - - - -
974d5207 by Yaroslav Halchenko at 2020-03-22T13:05:37-04:00
Changelog for the 0.2.0-1

- - - - -
dcf29c52 by Yaroslav Halchenko at 2020-03-22T13:56:17-04:00
Added myself to uploaders

- - - - -


11 changed files:

- .travis.yml
- README.md
- codecov.yml
- debian/changelog
- debian/control
- debian/copyright
- debian/watch
- etelemetry/__init__.py
- etelemetry/client.py
- etelemetry/tests/test_client.py
- setup.cfg


Changes:

=====================================
.travis.yml
=====================================
@@ -1,7 +1,6 @@
 # vim ft=yaml
 language: python
 python:
-  - 2.7
   - 3.5
   - 3.6
   - 3.7


=====================================
README.md
=====================================
@@ -1,7 +1,7 @@
 ## Etelemetry-client
 
-[![Build Status](https://travis-ci.org/mgxd/etelemetry-client.svg?branch=master)](https://travis-ci.org/mgxd/etelemetry-client)
-[![codecov](https://codecov.io/gh/mgxd/etelemetry-client/branch/master/graph/badge.svg)](https://codecov.io/gh/mgxd/etelemetry-client)
+[![Build Status](https://travis-ci.org/sensein/etelemetry-client.svg?branch=master)](https://travis-ci.org/sensein/etelemetry-client)
+[![codecov](https://codecov.io/gh/sensein/etelemetry-client/branch/master/graph/badge.svg)](https://codecov.io/gh/sensein/etelemetry-client)
 
 A lightweight python client to communicate with the etelemetry server
 
@@ -17,5 +17,17 @@ pip install etelemetry
 import etelemetry
 etelemetry.get_project("nipy/nipype")
 
-{'version': '1.2.1'}
+{'version': '1.4.2', 'bad_versions': ['1.2.1', '1.2.3', '1.3.0']}
 ```
+
+or to take advantage of comparing and checking for bad versions, you
+can use the following form
+
+```python
+import etelemetry
+etelemetry.check_available_version("nipy/nipype", "1.2.1")
+
+A newer version (1.4.2) of nipy/nipype is available. You are using 1.2.1
+You are using a version of nipy/nipype with a critical bug. Please use a different version.
+returns: {'version': '1.4.2', 'bad_versions': ['1.2.1', '1.2.3', '1.3.0']}
+```
\ No newline at end of file


=====================================
codecov.yml
=====================================
@@ -4,3 +4,4 @@ coverage:
     - "etelemetry/_version.py"
     - "setup.py"
     - "versioneer.py"
+    - "etelemetry/tests"


=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+python-etelemetry (0.2.0-1) unstable; urgency=medium
+
+  * New upstream release
+  * Upstream moved from personal mgxd to sensein organization on github
+  * Added myself to uploaders
+
+ -- Yaroslav Halchenko <debian at onerussian.com>  Sun, 22 Mar 2020 13:05:26 -0400
+
 python-etelemetry (0.1.2-1) unstable; urgency=medium
 
   * Initial release (Closes: #952558)


=====================================
debian/control
=====================================
@@ -2,7 +2,8 @@ Source: python-etelemetry
 Section: python
 Priority: optional
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
+Uploaders: Andreas Tille <tille at debian.org>,
+  Yaroslav Halchenko <debian at onerussian.com>,
 Build-Depends: debhelper-compat (= 12),
                dh-python,
                python3-all,
@@ -12,7 +13,7 @@ Build-Depends: debhelper-compat (= 12),
 Standards-Version: 4.5.0
 Vcs-Browser: https://salsa.debian.org/med-team/python-etelemetry
 Vcs-Git: https://salsa.debian.org/med-team/python-etelemetry.git
-Homepage: https://github.com/mgxd/etelemetry-client/
+Homepage: https://github.com/sensein/etelemetry-client/
 
 Package: python3-etelemetry
 Architecture: all


=====================================
debian/copyright
=====================================
@@ -1,6 +1,6 @@
 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
 Upstream-Name: etelemetry-client
-Source: https://github.com/mgxd/etelemetry-client/releases
+Source: https://github.com/sensein/etelemetry-client/releases
 
 Files: *
 Copyright: 2019, Senseable Intelligence Group


=====================================
debian/watch
=====================================
@@ -1,3 +1,3 @@
 version=4
 
-https://github.com/mgxd/etelemetry-client/releases .*/archive/v?@ANY_VERSION@@ARCHIVE_EXT@
+https://github.com/sensein/etelemetry-client/releases .*/archive/v?@ANY_VERSION@@ARCHIVE_EXT@


=====================================
etelemetry/__init__.py
=====================================
@@ -1 +1 @@
-from .client import get_project
+from .client import get_project, check_available_version


=====================================
etelemetry/client.py
=====================================
@@ -1,13 +1,24 @@
 from requests import request, ConnectionError, ReadTimeout
+import os
+
+import ci
 
 from .config import ET_PROJECTS
 
+_available_version_checked = None
+
 
 def _etrequest(endpoint, method="get", **kwargs):
     if kwargs.get('timeout') is None:
         kwargs['timeout'] = 5
+
+    params = {}
+    if ci.is_ci():
+        # send along CI information
+        params = ci.info()
+
     try:
-        res = request(method, endpoint, **kwargs)
+        res = request(method, endpoint, params=params, **kwargs)
     except ConnectionError:
         raise RuntimeError("Connection to server could not be made")
     except ReadTimeout:
@@ -36,7 +47,71 @@ def get_project(repo, **rargs):
     response
         Dictionary with `version` field
     """
+    if "NO_ET" in os.environ:
+        return None
     if "/" not in repo:
         raise ValueError("Invalid repository")
     res = _etrequest(ET_PROJECTS.format(repo=repo), **rargs)
     return res.json(encoding="utf-8")
+
+
+def check_available_version(project, version, lgr=None, raise_exception=False):
+    """A helper to check (and report) if newer version of project is available
+    Should be ok to execute multiple times, it will be checked only one time
+    Parameters
+    ----------
+    project: str
+      as on GitHub (e.g., sensein/etelemetry-client. Releases will be checked
+    version: str
+      local version of project
+    lgr: python logger object
+      external logger to be used
+    raise_exception: bool
+      raise an exception if a bad local version is detected
+    """
+    global _available_version_checked
+    if _available_version_checked is not None:
+        return _available_version_checked
+
+    if lgr is None:
+        import logging
+        lgr = logging.getLogger('et-client')
+
+    from pkg_resources import parse_version
+
+    latest = {"version": "Unknown", "bad_versions": []}
+    ret = None
+    try:
+        ret = get_project(project)
+    except Exception as e:
+        lgr.debug("Could not check %s for version updates: %s", project, e)
+        return None
+    finally:
+        if ret:
+            latest.update(**ret)
+            local_version = parse_version(version)
+            remote_version = parse_version(latest["version"])
+            if local_version < remote_version:
+                lgr.warning("A newer version (%s) of %s is available. You are "
+                            "using %s", latest["version"], project, version)
+            elif remote_version < local_version:
+                lgr.debug(
+                    "Running a newer version (%s) of %s than available (%s)",
+                    version, project, latest["version"])
+            else:  # ==
+                lgr.debug("No newer (than %s) version of %s found available",
+                          version, project)
+            if latest["bad_versions"] and any(
+                    [
+                        local_version == parse_version(ver)
+                        for ver in latest["bad_versions"]
+                    ]
+            ):
+                message = ("You are using a version of {0} with a critical bug. "
+                          "Please use a different version.").format(project)
+                if raise_exception:
+                    raise RuntimeError(message)
+                else:
+                    lgr.critical(message)
+            _available_version_checked = latest
+    return latest


=====================================
etelemetry/tests/test_client.py
=====================================
@@ -1,7 +1,7 @@
 import pytest
 
 from ..config import ET_ROOT
-from ..client import _etrequest, get_project
+from ..client import _etrequest, get_project, check_available_version
 
 
 def test_etrequest():
@@ -23,3 +23,31 @@ def test_get_project():
     repo = "github/hub"
     res = get_project(repo)
     assert "version" in res
+
+
+def test_noet():
+    import os
+    old_var = None
+    if 'NO_ET' in os.environ:
+        old_var = (True, os.environ["NO_ET"])
+    os.environ["NO_ET"] = "1"
+    repo = "github/hub"
+    res = get_project(repo)
+    assert res is None
+    if old_var is None:
+        del os.environ["NO_ET"]
+    else:
+        os.environ["NO_ET"] = old_var[1]
+
+
+def test_check_available():
+    repo = "invalidrepo"
+    res = check_available_version(repo, "0.1.0")
+    assert res is None
+    repo = "github/hub"
+    res = check_available_version(repo, "0.1.0")
+    assert "version" in res
+    res = check_available_version(repo, res["version"])
+    assert "version" in res
+    res = check_available_version(repo, "1000.1.0")
+    assert "version" in res


=====================================
setup.cfg
=====================================
@@ -5,21 +5,23 @@ maintainer = Mathias Goncalves
 maintainer_email = mathiasg at mit.edu
 description = Etelemetry python client API
 license = Apache License, 2.0
+long_description = file:README.md
+long_description_content_type = text/markdown; charset=UTF-8; variant=GFM
 provides =
     etelemetry
 classifiers =
     Development Status :: 3 - Alpha
     Intended Audience :: Science/Research
     License :: OSI Approved :: Apache Software License
-    Programming Language :: Python :: 2.7
     Programming Language :: Python :: 3.5
     Programming Language :: Python :: 3.6
     Programming Language :: Python :: 3.7
 
 [options]
-python_requires = >= 2.7
+python_requires = >= 3.5
 install_requires =
     requests
+    ci-info
 test_requires =
     pytest >= 4.4.0
     pytest-cov



View it on GitLab: https://salsa.debian.org/med-team/python-etelemetry/-/compare/e60fad6869c9b00ec36b5dc050ba344869174925...dcf29c52b0e4f713daeaa74d58a574c18ba4d154

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-etelemetry/-/compare/e60fad6869c9b00ec36b5dc050ba344869174925...dcf29c52b0e4f713daeaa74d58a574c18ba4d154
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200322/27b3055d/attachment-0001.html>


More information about the debian-med-commit mailing list