def __init__(self, cache, db, distro=None):
     super(ReviewLoaderSpawningRNRClient, self).__init__(cache, db, distro)
     cachedir = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "rnrclient")
     self.rnrclient = RatingsAndReviewsAPI(cachedir=cachedir)
     cachedir = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "rnrclient")
     self.rnrclient = RatingsAndReviewsAPI(cachedir=cachedir)
     self._reviews = {}
#!/usr/bin/python

import json
import subprocess
import sys

from softwarecenter.backend.piston.rnrclient import RatingsAndReviewsAPI

if __name__ == "__main__":

    rnrclient = RatingsAndReviewsAPI()
    piston_review_stats = rnrclient.review_stats(origin="ubuntu")

    # means            1  2  3  4  5 stars
    histogram_total = [0, 0, 0, 0, 0]
    for s in piston_review_stats:
        histogram = json.loads(s.histogram)
        for i in range(5):
            histogram_total[i] += histogram[i]
    print "overall distribution: ", histogram_total

    # write out data file
    f = open("reviews-spread.dat", "w")
    for i in range(5):
        f.write("%i %i\n" % (i + 1, histogram_total[i]))
    f.close()

    # write out gnuplot
    f = open("reviews-spread.gnuplot", "w")
    f.write("""
set title "Reviews spread"
Exemple #3
0
from softwarecenter.backend.piston.rnrclient import RatingsAndReviewsAPI
from piston_mini_client import APIError

LOG = logging.getLogger(__name__)

if __name__ == "__main__":
    logging.basicConfig()

    # common options for optparse go here
    parser = OptionParser()

    # check options
    parser.add_option("--username", default=None)
    (options, args) = parser.parse_args()

    rnrclient = RatingsAndReviewsAPI()
            
    useful_votes = []
    
    if options.username:
        try:
            useful_votes = rnrclient.get_usefulness(username=options.username)
        except ValueError as e:
            LOG.error("failed to parse '%s'" % e.doc)
        except APIError, e:
            LOG.warn("_get_useful_votes_helper: no usefulness able to be retrieved for username: %s" % (options.username))
            LOG.debug("_get_reviews_threaded: no reviews able to be retrieved: %s" % e)
        except:
            LOG.exception("_get_useful_votes_helper")
            sys.exit(1)
#!/usr/bin/python

import json
import subprocess
import sys

from softwarecenter.backend.piston.rnrclient import RatingsAndReviewsAPI

if __name__ == "__main__":

    rnrclient = RatingsAndReviewsAPI()
    piston_review_stats = rnrclient.review_stats(origin="ubuntu")

    # means            1  2  3  4  5 stars
    histogram_total = [0, 0, 0, 0, 0]
    for s in piston_review_stats:
        histogram = json.loads(s.histogram)
        for i in range(5):
            histogram_total[i] += histogram[i]
    print "overall distribution: ", histogram_total

    # write out data file
    f=open("reviews-spread.dat", "w")
    for i in range(5):
        f.write("%i %i\n" % (i+1, histogram_total[i]))
    f.close()

    # write out gnuplot
    f=open("reviews-spread.gnuplot", "w")
    f.write("""
set title "Reviews spread"
    # check options
    parser.add_option("--origin", default="any")
    parser.add_option("--distroseries", default="any")
    parser.add_option("--days-delta", default=None)
    parser.add_option("--debug",
                      action="store_true", default=False)
    parser.add_option("--no-pickle",
                      action="store_true", default=False)
    (options, args) = parser.parse_args()

    if options.debug:
        LOG.setLevel(logging.DEBUG)

    cachedir = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "rnrclient")
    rnrclient = RatingsAndReviewsAPI(cachedir=cachedir)

    kwargs = {"origin": options.origin,
              "distroseries": options.distroseries,
             }
    if options.days_delta:
        kwargs["days"] = int(options.days_delta)

    # depending on the time delta, use a different call
    piston_review_stats = []
    try:
        piston_review_stats = rnrclient.review_stats(**kwargs)
    except:
        LOG.exception("get_review_stats")
        sys.exit(1)
Exemple #6
0
    # common options for optparse go here
    parser = OptionParser()

    # check options
    parser.add_option("--origin", default="any")
    parser.add_option("--distroseries", default="any")
    parser.add_option("--days-delta", default=None)
    parser.add_option("--debug", action="store_true", default=False)
    parser.add_option("--no-pickle", action="store_true", default=False)
    (options, args) = parser.parse_args()

    if options.debug:
        LOG.setLevel(logging.DEBUG)

    cachedir = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "rnrclient")
    rnrclient = RatingsAndReviewsAPI(cachedir=cachedir)

    kwargs = {
        "origin": options.origin,
        "distroseries": options.distroseries,
    }
    if options.days_delta:
        kwargs["days"] = int(options.days_delta)

    # depending on the time delta, use a different call
    piston_review_stats = []
    try:
        piston_review_stats = rnrclient.review_stats(**kwargs)
    except:
        LOG.exception("get_review_stats")
        sys.exit(1)
Exemple #7
0
    parser.add_option("--distroseries", default="any")
    parser.add_option("--pkgname")
    parser.add_option("--version", default="any")
    parser.add_option("--page", default="1")
    parser.add_option("", "--debug",
                      action="store_true", default=False)
    parser.add_option("--no-pickle",
                      action="store_true", default=False)
    parser.add_option("--sort", default="helpful")
    (options, args) = parser.parse_args()

    if options.debug:
        LOG.setLevel(logging.DEBUG)

    cachedir = os.path.join(SOFTWARE_CENTER_CACHE_DIR, "rnrclient")
    rnrclient = RatingsAndReviewsAPI(cachedir=cachedir)

    kwargs = {"language": options.language, 
              "origin": options.origin,
              "distroseries": options.distroseries,
              "packagename": options.pkgname.split(':')[0], #multiarch..
              "version": options.version,
              "page": int(options.page),
              "sort" : options.sort,
              }
    piston_reviews = []
    try:
        piston_reviews = try_get_reviews(kwargs)
    except ValueError as e:
        LOG.error("failed to parse '%s'" % e)
    #bug lp:709408 - don't print 404 errors as traceback when api request