[Python-modules-commits] [usagestats] 01/04: New upstream 0.6

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Apr 18 15:00:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository usagestats.

commit e05c8ccfe2fa8779674acea5e4e27b7170e96620
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Tue Apr 18 15:38:11 2017 +0100

    New upstream 0.6
---
 CHANGELOG.md                       |   7 +++
 PKG-INFO                           | 102 +++++++++++++++++++++++++++++++++++++
 README.rst                         |   2 +-
 appveyor.yml                       |  15 ------
 scripts/conda/conda.sh             |  94 ----------------------------------
 scripts/conda/usagestats/bld.bat   |   8 ---
 scripts/conda/usagestats/build.sh  |   9 ----
 scripts/conda/usagestats/meta.yaml |  58 ---------------------
 setup.cfg                          |   5 ++
 setup.py                           |   2 +-
 usagestats.py                      |  10 ++--
 11 files changed, 121 insertions(+), 191 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b3d2138..415eb56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
 Changelog
 =========
 
+0.6 (2017-04-15)
+----------------
+
+Bugfixes:
+* Check environment variable again before submitting
+* Don't log full report on INFO (make that DEBUG)
+
 0.5 (2016-03-04)
 ----------------
 
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..2981842
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,102 @@
+Metadata-Version: 1.1
+Name: usagestats
+Version: 0.6
+Summary: Anonymous usage statistics collecter
+Home-page: https://github.com/remram44/usagestats
+Author: Remi Rampin
+Author-email: remirampin at gmail.com
+License: Apache License 2.0
+Description: Usage statistics collector
+        ==========================
+        
+        This package is meant to easily get usage statistics from the users of your
+        program.
+        
+        Statistics will be collected but won't be uploaded until the user opts in. A
+        message will be printed on stderr asking the user to explicitly opt in or opt
+        out.
+        
+        Usage
+        -----
+        
+        You can easily collect information from your program by adding usagestats to
+        your project's requirements and using the library. Here is an example::
+        
+            import usagestats
+            import sys
+        
+        
+            optin_prompt = usagestats.Prompt(enable='cool_program --enable-stats',
+                                             disable='cool_program --disable-stats')
+        
+            # Location where to store stats
+            # Also allocates a unique ID for the user
+            # The version is important, since the information you log (or the format)
+            # might change in later versions of your program
+            stats = usagestats.Stats('~/.myprog/usage_stats',
+                                     optin_prompt,
+                                     'https://usagestats.example.org/',
+                                     unique_user_id=True,
+                                     version='0.1')
+        
+        
+            def main():
+                if len(sys.argv) < 2:
+                    pass
+                elif sys.argv.get(1) == '--enable-stats':
+                    stats.enable_reporting()
+                    sys.exit(0)
+                elif sys.argv.get(1) == '--disable-stats':
+                    stats.disable_reporting()
+                    sys.exit(0)
+        
+                if sys.version_info < (3,):
+                    # Stores some info, will be reported when submit() is called
+                    stats.note({'mode': 'compatibility'})
+        
+                # Report things
+                stats.submit(
+                    # Dictionary containing the info
+                    {'what': 'Ran the program'},
+                    # Flags making usagestats insert more details
+                    usagestats.OPERATING_SYSTEM,  # Operating system/distribution
+                    usagestats.PYTHON_VERSION,    # Python version info
+                    usagestats.SESSION_TIME,      # Time since Stats object was created
+                )
+        
+        
+            if __name__ == '__main__':
+                main()
+        
+        `submit()` will, by default, store the info in the specified directory. Nothing
+        will be reported until the user opts in; a message will simply be printed to
+        stderr::
+        
+            Uploading usage statistics is currently DISABLED
+            Please help us by providing anonymous usage statistics; you can enable this
+            by running:
+                cool_program --enable-stats
+            If you do not want to see this message again, you can run:
+                cool_program --disable-stats
+            Nothing will be uploaded before you opt in.
+        
+        Server
+        ------
+        
+        To collect the reports, any server will do; the reports are uploaded via POST
+        as a LF-separated list of ``key:value`` pairs. A simple script for mod_wsgi is
+        included; it writes each report to a separate file. Writing your own
+        implementation in your language of choice (PHP, Java) with your own backend
+        should be fairly straightforward.
+        
+Keywords: server,log,logging,usage,stats,statistics,collection,report
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python
+Classifier: Topic :: Internet
+Classifier: Topic :: Internet :: Log Analysis
+Classifier: Topic :: Software Development
+Classifier: Topic :: System :: Logging
+Classifier: Topic :: Utilities
diff --git a/README.rst b/README.rst
index 4a7621b..ec36a74 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ This package is meant to easily get usage statistics from the users of your
 program.
 
 Statistics will be collected but won't be uploaded until the user opts in. A
-message will be printed on stderr asking the user to explicitely opt in or opt
+message will be printed on stderr asking the user to explicitly opt in or opt
 out.
 
 Usage
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 1f6d2f8..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-# https://ci.appveyor.com/project/remram44/usagestats
-build: false
-shallow_clone: true
-environment:
-  matrix:
-    - PYTHON: "C:/Python27"
-    - PYTHON: "C:/Python34"
-install:
-  - ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
-  - set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
-  - python C:/get-pip.py
-  - pip install setuptools
-  - ".appveyor\\install.bat"
-test_script:
-  - ".appveyor\\test.bat"
diff --git a/scripts/conda/conda.sh b/scripts/conda/conda.sh
deleted file mode 100755
index d6d7696..0000000
--- a/scripts/conda/conda.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-set -e
-
-# This script automatically builds Conda packages
-
-ORIG_CWD="$(pwd)"
-cd "$1"
-DEST_DIR="$(pwd)"
-
-cd "$ORIG_CWD"
-cd "$(dirname "$0")/../.."
-TOPLEVEL="$(pwd)"
-
-# Clears Conda cache
-ANACONDA_CACHE="$(dirname "$(which python)")/../conda-bld/src_cache/*"
-rm -f "$ANACONDA_CACHE"
-
-if [ -z "$1" ]; then
-    echo "Usage: $(basename $0) <target_directory> [version]" >&2
-    exit 1
-fi
-if [ -z "$2" ]; then
-    # describe gives us either "0.5" or "0.5-40-g1234567"
-    # note: no 'sed -r' on OS X
-    VERSION="$(git describe --always --tags | sed 's/^\([0-9.]*\)-\([0-9]*\)-g\([a-z0-9]*\)$/\1.\2/')"
-else
-    VERSION="$2"
-fi
-
-sedi(){
-    TEMPFILE="$(mktemp /tmp/rr_conda_XXXXXXXX)"
-    sed "$1" "$2" > "$TEMPFILE"
-    mv "$TEMPFILE" "$2"
-}
-
-absolutepathname(){
-    mkdir -p "$(dirname "$1")"
-    cd "$(dirname "$1")"
-    echo "$(pwd)/$(basename "$1")"
-}
-
-for PYTHONVER in 2.7 3.5; do
-    for PKGNAME in usagestats; do
-        TEMP_DIR="$(mktemp -d /tmp/rr_conda_XXXXXXXX)"
-
-        PKGDIR="$TOPLEVEL"
-        cd "$PKGDIR"
-
-        # Builds source distribution
-        if ! python setup.py sdist --dist-dir "$TEMP_DIR"; then
-            rm -Rf "$TEMP_DIR"
-            exit 1
-        fi
-
-        # Creates symlink
-        TEMP_FILE="$(echo $TEMP_DIR/*)"
-        ln -s "$TEMP_FILE" "$TEMP_DIR/$PKGNAME.tar.gz"
-
-        # Copies conda recipe
-        cp -r "$TOPLEVEL/scripts/conda/$PKGNAME" "$TEMP_DIR/$PKGNAME"
-
-        # Changes version in recipe
-        VERSION_ESCAPED="$(echo "$VERSION" | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')"
-        sedi "s/_REPLACE_version_REPLACE_/$VERSION_ESCAPED/g" "$TEMP_DIR/$PKGNAME/meta.yaml"
-
-        # Changes URL
-        URL_ESCAPED="$(echo "file://$TEMP_DIR/$PKGNAME.tar.gz" | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')"
-        sedi "s/_REPLACE_url_REPLACE_/$URL_ESCAPED/g" "$TEMP_DIR/$PKGNAME/meta.yaml"
-
-        # Change build string
-        sedi "s/_REPLACE_buildstr_REPLACE_/py$PYTHONVER/g" "$TEMP_DIR/$PKGNAME/meta.yaml"
-
-        # Builds Conda package
-        cd "$TEMP_DIR"
-        OUTPUT_PKG="$(conda build --python "$PYTHONVER" --output "$PKGNAME")"
-        OUTPUT_PKG="$(absolutepathname "$OUTPUT_PKG")"
-        if ! conda build --python "$PYTHONVER" "$PKGNAME"; then
-            rm -Rf "$TEMP_DIR"
-            rm -f "$ANACONDA_CACHE"
-            exit 1
-        fi
-
-        # Copies result out
-        cd "$PKGDIR"
-        cp "$OUTPUT_PKG" "$DEST_DIR/"
-
-        # Removes temporary directory
-        rm -Rf "$TEMP_DIR"
-    done
-done
-
-# Clears Conda cache
-rm -f "$ANACONDA_CACHE"
diff --git a/scripts/conda/usagestats/bld.bat b/scripts/conda/usagestats/bld.bat
deleted file mode 100644
index 87b1481..0000000
--- a/scripts/conda/usagestats/bld.bat
+++ /dev/null
@@ -1,8 +0,0 @@
-"%PYTHON%" setup.py install
-if errorlevel 1 exit 1
-
-:: Add more build steps here, if they are necessary.
-
-:: See
-:: http://docs.continuum.io/conda/build.html
-:: for a list of environment variables that are set during the build process.
diff --git a/scripts/conda/usagestats/build.sh b/scripts/conda/usagestats/build.sh
deleted file mode 100644
index 4d7fc03..0000000
--- a/scripts/conda/usagestats/build.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-$PYTHON setup.py install
-
-# Add more build steps here, if they are necessary.
-
-# See
-# http://docs.continuum.io/conda/build.html
-# for a list of environment variables that are set during the build process.
diff --git a/scripts/conda/usagestats/meta.yaml b/scripts/conda/usagestats/meta.yaml
deleted file mode 100644
index dfeff0e..0000000
--- a/scripts/conda/usagestats/meta.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
-package:
-  name: usagestats
-  version: !!str _REPLACE_version_REPLACE_
-
-source:
-  fn: usagestats.tar.gz
-  url: _REPLACE_url_REPLACE_
-
-build:
-  #preserve_egg_dir: True
-  entry_points:
-    # Put any entry points (scripts to be generated automatically) here. The
-    # syntax is module:function.  For example
-    #
-    # - usagestats = usagestats:main
-    #
-    # Would create an entry point called usagestats that calls usagestats.main()
-
-
-  # If this is a new build for the same version, increment the build
-  # number. If you do not include this key, it defaults to 0.
-  # number: 1
-  string: _REPLACE_buildstr_REPLACE_
-
-requirements:
-  build:
-    - python
-    - setuptools
-    - requests
-
-  run:
-    - python
-    - requests
-
-test:
-  # Python imports
-  imports:
-    - usagestats
-
-  # commands:
-    # You can put test commands to be run here.  Use this to test that the
-    # entry points work.
-
-  # You can also put a file called run_test.py in the recipe that will be run
-  # at test time.
-
-  # requires:
-    # Put any additional test requirements here.  For example
-    # - nose
-
-about:
-  home: https://github.com/remram44/usagestats
-  license: Apache Software License
-  summary: 'Anonymous usage statistics collecter'
-
-# See
-# http://docs.continuum.io/conda/build.html for
-# more information about meta.yaml
diff --git a/setup.cfg b/setup.cfg
index 2a9acf1..adf5ed7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,7 @@
 [bdist_wheel]
 universal = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+
diff --git a/setup.py b/setup.py
index 171c508..232d849 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ os.chdir(os.path.abspath(os.path.dirname(__file__)))
 with open('README.rst') as fp:
     description = fp.read()
 setup(name='usagestats',
-      version='0.5',
+      version='0.6',
       py_modules=['usagestats'],
       description="Anonymous usage statistics collecter",
       install_requires=['requests'],
diff --git a/usagestats.py b/usagestats.py
index b37eb58..1ce1bae 100644
--- a/usagestats.py
+++ b/usagestats.py
@@ -6,7 +6,7 @@ import time
 import sys
 
 
-__version__ = '0.5'
+__version__ = '0.6'
 
 
 logger = logging.getLogger('usagestats')
@@ -318,7 +318,7 @@ class Stats(object):
         if self.user_id:
             all_info.insert(1, ('user', self.user_id))
 
-        logger.info("Generated report:\n%r", (all_info,))
+        logger.debug("Generated report:\n%r", (all_info,))
 
         # Current report
         def generator():
@@ -346,7 +346,7 @@ class Stats(object):
             fullname = os.path.join(self.location, old_filename)
             try:
                 with open(fullname, 'rb') as fp:
-                    # `data=f` would make requests stream, which is currently
+                    # `data=fp` would make requests stream, which is currently
                     # not a good idea (WSGI chokes on it)
                     r = requests.post(self.drop_point, data=fp.read(),
                                       timeout=1, verify=self.ssl_verify)
@@ -355,7 +355,7 @@ class Stats(object):
                 logger.warning("Couldn't upload %s: %s", old_filename, str(e))
                 break
             else:
-                logger.info("Submitted %s", old_filename)
+                logger.info("Submitted report %s", old_filename)
                 os.remove(fullname)
 
         # Post current report
@@ -373,6 +373,6 @@ class Stats(object):
         else:
             try:
                 r.raise_for_status()
-                logger.info("Submitted current report")
+                logger.info("Submitted report")
             except requests.RequestException as e:
                 logger.warning("Server rejected report: %s", str(e))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/usagestats.git



More information about the Python-modules-commits mailing list