public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: /, gs_pypi/
Date: Tue, 23 Jul 2013 23:13:49 +0000 (UTC)	[thread overview]
Message-ID: <1374621242.65e4510b7409a122a8744f1ced20286ca9ca0a3c.jauhien@gentoo> (raw)

commit:     65e4510b7409a122a8744f1ced20286ca9ca0a3c
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Tue Jul 23 23:14:02 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Tue Jul 23 23:14:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=65e4510b

PyPI backend: experiments

---
 gs-pypi.json       |  2 +-
 gs_pypi/pypi_db.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/gs-pypi.json b/gs-pypi.json
index eb26221..06a23a4 100644
--- a/gs-pypi.json
+++ b/gs-pypi.json
@@ -2,7 +2,7 @@
   "package": "gs_pypi", 
   "repositories": {
     "pypi": {
-      "repo_uri": "https://pypi.python.org/pypi"
+      "repo_uri": "http://pypi.python.org/pypi"
     }
   }
 }

diff --git a/gs_pypi/pypi_db.py b/gs_pypi/pypi_db.py
index 938f79c..71e5397 100644
--- a/gs_pypi/pypi_db.py
+++ b/gs_pypi/pypi_db.py
@@ -11,7 +11,60 @@
     :license: GPL-2, see LICENSE for more details.
 """
 
+from g_sorcery.compatibility import py2k
+
+if py2k:
+    import xmlrpclib
+    import httplib
+    urlparse
+else:
+    import xmlrpc.client as xmlrpclib
+    import http.client as httplib
+    import urllib.parse as urlparse
+
+import sys
+
+from g_sorcery.logger import Logger
 from g_sorcery.package_db import DBGenerator
 
 class PypiDBGenerator(DBGenerator):
-    pass
+
+    def process_uri(self, uri, data):
+        url = uri["uri"]
+        client = xmlrpclib.ServerProxy(url)
+        logger = Logger()
+        logger.info("downloading packages data")
+        pkg_list = client.list_packages()
+
+        number_of_packages = len(pkg_list)
+        downloaded_number = 0
+
+        connection = httplib.HTTPConnection(urlparse.urlparse(url).netloc)
+
+        connection.request("GET", "/pypi/zmqpy/json")
+        response = connection.getresponse()
+        print(response.getheaders())
+        
+        for pkg in pkg_list:
+            data[pkg] = {}
+
+            chars = ['-','\\','|','/']
+            show = chars[downloaded_number % 4]
+            percent = (downloaded_number * 100)//number_of_packages
+            length = 70
+            progress = (percent * length)//100
+            blank = length - progress
+
+            sys.stdout.write("\r %s [%s%s] %s%%" % (show, "#" * progress, " " * blank, percent))
+            sys.stdout.flush()
+            downloaded_number += 1
+
+        connection.close()
+
+        sys.stdout.write("\r %s [%s] %s%%" % ("-", "#" * length, 100))
+        sys.stdout.flush()
+        print("")
+
+    def process_data(self, pkg_db, data, common_config, config):
+        #print(data)
+        pass


             reply	other threads:[~2013-07-23 23:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 23:13 Jauhien Piatlicki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-09-05 17:21 [gentoo-commits] proj/g-sorcery:master commit in: /, gs_pypi/ Jauhien Piatlicki
2013-09-05 17:09 Jauhien Piatlicki
2013-08-30 16:58 Jauhien Piatlicki
2013-07-24 23:32 Jauhien Piatlicki
2013-07-23 23:13 Jauhien Piatlicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374621242.65e4510b7409a122a8744f1ced20286ca9ca0a3c.jauhien@gentoo \
    --to=piatlicki@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox