Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions yolk/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import urllib2
else:
import xmlrpc.client as xmlrpclib
import pickle
import pickle as cPickle
import urllib.request as urllib2
import os
import time
Expand Down Expand Up @@ -164,7 +164,7 @@ def get_xmlrpc_server(self):
Returns PyPI's XML-RPC server instance
"""
check_proxy_setting()
if os.environ.has_key('XMLRPC_DEBUG'):
if 'XMLRPC_DEBUG' in os.environ:
debug = 1
else:
debug = 0
Expand Down Expand Up @@ -203,13 +203,16 @@ def query_cached_package_list(self):
"""Return list of pickled package names from PYPI"""
if self.debug:
self.logger.debug("DEBUG: reading pickled cache file")
return cPickle.load(open(self.pkg_cache_file, "r"))
try:
return cPickle.load(open(self.pkg_cache_file, "rb"))
except ValueError:
return cPickle.load(open(self.pkg_cache_file, "r"))

def fetch_pkg_list(self):
"""Fetch and cache master list of package names from PYPI"""
self.logger.debug("DEBUG: Fetching package name list from PyPI")
package_list = self.list_packages()
cPickle.dump(package_list, open(self.pkg_cache_file, "w"))
cPickle.dump(package_list, open(self.pkg_cache_file, "wb"))
self.pkg_list = package_list

def search(self, spec, operator):
Expand Down Expand Up @@ -275,7 +278,7 @@ def get_download_urls(self, package_name, version="", pkg_type="all"):

#Try the package's metadata directly in case there's nothing
#returned by XML-RPC's release_urls()
if metadata and metadata.has_key('download_url') and \
if metadata and 'download_url' in metadata and \
metadata['download_url'] != "UNKNOWN" and \
metadata['download_url'] != None:
if metadata['download_url'] not in all_urls:
Expand Down