Example #1
0
 def __init__(self, index_url=None, eggs_dir=None):
     if not index_url:
         index_url = config.get('eggproxy', 'index')
     if not eggs_dir:
         eggs_dir = config.get('eggproxy', 'eggs_directory')
     if not os.path.isdir(eggs_dir):
         print 'You must create the %r directory' % eggs_dir
         sys.exit()
     self.eggs_index_proxy = IndexProxy(PackageIndex(index_url=index_url))
     self.eggs_dir = eggs_dir
Example #2
0
 def __init__(self, index_url=None, eggs_dir=None):
     if not index_url:
         index_url = config.get("eggproxy", "index")
     if not eggs_dir:
         eggs_dir = config.get("eggproxy", "eggs_directory")
     if not os.path.isdir(eggs_dir):
         create_eggs_directory = config.getboolean("eggproxy", "create_eggs_directory")
         if create_eggs_directory:
             print "Creating the %r directory" % eggs_dir
             os.makedirs(eggs_dir)
         else:
             print "You must create the %r directory" % eggs_dir
             sys.exit()
     self.eggs_index_proxy = IndexProxy(PackageIndex(index_url=index_url))
     self.eggs_dir = eggs_dir
Example #3
0
def standalone():
    port = config.get("eggproxy", "port")
    # 0.2.0 way of starting the httpserver, but using the config'ed port
    # number instead of a hardcoded 8888.
    httpserver.serve(
        EggProxyApp(),
        host="127.0.0.1",
        port=port,
        socket_timeout=5 * 60,
        use_threadpool=False,
        threadpool_workers=10,
        threadpool_options=None,
        request_queue_size=5,
    )
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, write to the
## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
from os.path import getmtime
from time import time

from collective.eggproxy import eggs_index_proxy
from collective.eggproxy import PackageNotFound
from collective.eggproxy.config import config

UPDATE_INTERVAL = int(config.get("eggproxy", "update_interval")) * 3600
EGGS_DIR = config.get("eggproxy", "eggs_directory")
TIME_LIMIT = int(time()) - UPDATE_INTERVAL

def isOutDated(file_path):
    """A file is outdated if it does not exists or if its modification date is
    older than now - update_interval
    """
    if os.path.exists(file_path):
        mtime = getmtime(file_path)
        return mtime < TIME_LIMIT
    return True

def updateCache(*args):
    """
    """
Example #5
0
def standalone():
    port = config.get('eggproxy', 'port')
    host = config.get('eggproxy', 'host')
    # 0.2.0 way of starting the httpserver, but using the config'ed port
    # number instead of a hardcoded 8888.
    httpserver.serve(EggProxyApp(), host=host, port=port)
Example #6
0
from paste import httpserver
from paste.script.appinstall import Installer as BaseInstaller
from paste.fileapp import FileApp
from paste.httpexceptions import HTTPNotFound
from collective.eggproxy.utils import PackageIndex
from collective.eggproxy import IndexProxy
from collective.eggproxy import PackageNotFound
from collective.eggproxy.config import config

ALWAYS_REFRESH = config.getboolean('eggproxy', 'always_refresh')
if ALWAYS_REFRESH:
    print "Always-refresh mode switched on"
    # Apply timeout setting right here. Might not be the best spot. Timeout is
    # needed for the always_refresh option to keep a down pypi from blocking
    # the proxy.
    timeout = config.get('eggproxy', 'timeout')
    socket.setdefaulttimeout(int(timeout))


class EggProxyApp(object):

    def __init__(self, index_url=None, eggs_dir=None):
        if not index_url:
            index_url = config.get('eggproxy', 'index')
        if not eggs_dir:
            eggs_dir = config.get('eggproxy', 'eggs_directory')
        if not os.path.isdir(eggs_dir):
            print 'You must create the %r directory' % eggs_dir
            sys.exit()
        self.eggs_index_proxy = IndexProxy(PackageIndex(index_url=index_url))
        self.eggs_dir = eggs_dir
Example #7
0
from setuptools.package_index import (
    egg_info_for_url,
    safe_name,
    safe_version,
    to_filename,
    HREF,
    htmldecode,
    find_external_links,
    PYPI_MD5,
    )

from pkg_resources import Requirement
from collective.eggproxy.config import config

ALWAYS_REFRESH = config.getboolean('eggproxy', 'always_refresh')
EGGS_DIR = config.get("eggproxy", "eggs_directory")
INDEX_URL = config.get("eggproxy", "index")
#INDEX is defined *after* the PackageIndex class.


class PackageIndex(BasePackageIndex):
    """
    """

    def can_add(self, dist):
        """Overrides PackageIndex.can_add method to remove filter on python
    major version: we want packages for all versions, all platforms
        """
        return True

    def find_packages(self, requirement):
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, write to the
## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
from mod_python import apache

from collective.eggproxy import eggs_index_proxy
from collective.eggproxy.config import config
from restkit import Resource

EGGS_DIR = config.get("eggproxy", "eggs_directory")


def fixup_handler(req):
    options = req.get_options()
    document_root = EGGS_DIR
    url_prefix = options['URLPrefix']
    url_prefix = [part for part in url_prefix.split('/') if part]
    url_prefix_len = len(url_prefix)
    uri_path = req.parsed_uri[apache.URI_PATH]
    uri_path = [part for part in uri_path.split('/') if part][url_prefix_len:]

    real_path = os.path.join(document_root, *uri_path)

    if os.path.exists(real_path) and not os.path.isdir(real_path):
        #FIXME isdir: cannot make apache serve index.html with mod_dir
Example #9
0
from setuptools.package_index import (
    egg_info_for_url,
    safe_name,
    safe_version,
    to_filename,
    HREF,
    htmldecode,
    find_external_links,
    PYPI_MD5,
    )

from pkg_resources import Requirement
from collective.eggproxy.config import config

ALWAYS_REFRESH = config.getboolean('eggproxy', 'always_refresh')
EGGS_DIR = config.get("eggproxy", "eggs_directory")
INDEX_URL = config.get("eggproxy", "index")
IGNORED_EXTENSIONS = [x.strip() for x in
                      config.get("eggproxy", "ignored_extensions").split(',')
                      if x.strip()]
#INDEX is defined *after* the PackageIndex class.


class PackageIndex(BasePackageIndex):
    """
    """

    def can_add(self, dist):
        """Overrides PackageIndex.can_add method to remove filter on python
    major version: we want packages for all versions, all platforms
        """
Example #10
0
from paste.httpexceptions import HTTPNotFound
from collective.eggproxy.utils import PackageIndex
from collective.eggproxy import IndexProxy
from collective.eggproxy import PackageNotFound
from collective.eggproxy.config import config
import logging

logger = logging.getLogger(__name__)

ALWAYS_REFRESH = config.getboolean("eggproxy", "always_refresh")
if ALWAYS_REFRESH:
    print "Always-refresh mode switched on"
    # Apply timeout setting right here. Might not be the best spot. Timeout is
    # needed for the always_refresh option to keep a down pypi from blocking
    # the proxy.
    timeout = config.get("eggproxy", "timeout")
    socket.setdefaulttimeout(int(timeout))


class EggProxyApp(object):
    def __init__(self, index_url=None, eggs_dir=None):
        if not index_url:
            index_url = config.get("eggproxy", "index")
        if not eggs_dir:
            eggs_dir = config.get("eggproxy", "eggs_directory")
        if not os.path.isdir(eggs_dir):
            create_eggs_directory = config.getboolean("eggproxy", "create_eggs_directory")
            if create_eggs_directory:
                print "Creating the %r directory" % eggs_dir
                os.makedirs(eggs_dir)
            else:
Example #11
0
def standalone():
    port = config.get('eggproxy', 'port')
    host = config.get('eggproxy', 'host')
    # 0.2.0 way of starting the httpserver, but using the config'ed port
    # number instead of a hardcoded 8888.
    httpserver.serve(EggProxyApp(), host=host, port=port)
Example #12
0
from paste import httpserver
from paste.script.appinstall import Installer as BaseInstaller
from paste.fileapp import FileApp
from paste.httpexceptions import HTTPNotFound
from collective.eggproxy.utils import PackageIndex
from collective.eggproxy import IndexProxy
from collective.eggproxy import PackageNotFound
from collective.eggproxy.config import config

ALWAYS_REFRESH = config.getboolean('eggproxy', 'always_refresh')
if ALWAYS_REFRESH:
    print "Always-refresh mode switched on"
    # Apply timeout setting right here. Might not be the best spot. Timeout is
    # needed for the always_refresh option to keep a down pypi from blocking
    # the proxy.
    timeout = config.get('eggproxy', 'timeout')
    socket.setdefaulttimeout(int(timeout))


class EggProxyApp(object):
    def __init__(self, index_url=None, eggs_dir=None):
        if not index_url:
            index_url = config.get('eggproxy', 'index')
        if not eggs_dir:
            eggs_dir = config.get('eggproxy', 'eggs_directory')
        if not os.path.isdir(eggs_dir):
            print 'You must create the %r directory' % eggs_dir
            sys.exit()
        self.eggs_index_proxy = IndexProxy(PackageIndex(index_url=index_url))
        self.eggs_dir = eggs_dir
Example #13
0
from setuptools.package_index import (
    egg_info_for_url,
    safe_name,
    safe_version,
    to_filename,
    HREF,
    htmldecode,
    find_external_links,
    PYPI_MD5,
    )

from pkg_resources import Requirement
from collective.eggproxy.config import config

ALWAYS_REFRESH = config.getboolean('eggproxy', 'always_refresh')
EGGS_DIR = config.get("eggproxy", "eggs_directory")
INDEX_URL = config.get("eggproxy", "index")
#INDEX is defined *after* the PackageIndex class.


class PackageIndex(BasePackageIndex):
    """
    """

    def can_add(self, dist):
        """Overrides PackageIndex.can_add method to remove filter on python
    major version: we want packages for all versions, all platforms
        """
        return True

    def find_packages(self, requirement):
Example #14
0
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, write to the
## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
from os.path import getmtime
from time import time

from collective.eggproxy import eggs_index_proxy
from collective.eggproxy import PackageNotFound
from collective.eggproxy.config import config

UPDATE_INTERVAL = int(config.get("eggproxy", "update_interval")) * 3600
EGGS_DIR = config.get("eggproxy", "eggs_directory")
TIME_LIMIT = int(time()) - UPDATE_INTERVAL


def isOutDated(file_path):
    """A file is outdated if it does not exists or if its modification date is
    older than now - update_interval
    """
    if os.path.exists(file_path):
        mtime = getmtime(file_path)
        return mtime < TIME_LIMIT
    return True


def updateCache(*args):