コード例 #1
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]

    # Configure our deprecation warnings to be sent through loggers
    deprecation.install_warning_logger()

    autocomplete()

    try:
        cmd_name, cmd_args = parseopts(args)
    except PipError as exc:
        sys.stderr.write("ERROR: %s" % exc)
        sys.stderr.write(os.linesep)
        sys.exit(1)

    # Needed for locale.getpreferredencoding(False) to work
    # in pip.utils.encoding.auto_decode
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error as e:
        # setlocale can apparently crash if locale are uninitialized
        logger.debug("Ignoring error %s when setting locale", e)

    command = commands_dict[cmd_name](isolated=check_isolated(cmd_args))
    return command.main(cmd_args)
コード例 #2
0
ファイル: pip_faster.py プロジェクト: anthrax3/venv-update
    def find_requirement(self, req, upgrade):
        if is_req_pinned(req.req):
            # if the version is pinned-down by a ==
            # first try to use any installed package that satisfies the req
            if req.satisfied_by:
                logger.info('Faster! pinned requirement already installed.')
                raise BestVersionAlreadyInstalled

            # then try an optimistic search for a .whl file:
            link = optimistic_wheel_search(req.req, self.index_urls)
            if link is None:
                # The wheel will be built during prepare_files
                logger.debug(
                    'No wheel found locally for pinned requirement %s', req)
            else:
                logger.info(
                    'Faster! Pinned wheel found, without hitting PyPI.')
                return link
        else:
            # unpinned requirements aren't very notable. only show with -v
            logger.info('slow: full search for unpinned requirement %s', req)

        # otherwise, do the full network search, per usual
        try:
            return super(FasterPackageFinder,
                         self).find_requirement(req, upgrade)
        except DistributionNotFound:
            exc_info = sys.exc_info()
            # Best effort: try and install from suitable version on-disk
            link = optimistic_wheel_search(req.req, self.index_urls)
            if link:
                return link
            else:
                reraise(*exc_info)
コード例 #3
0
    def send_key(self, values):
        """
        input the key
        :param values
        :return:
        """
        try:
            element = self.get()
            element.clear()

            logger.debug("input %s" % (values))
            element.send_keys(values)
        except AttributeError:
            raise
コード例 #4
0
 def process_template_response(self, request, response):
     if request.META.get('HTTP_X_PJAX', False):
         logger.debug('pjax response')
         response.context_data['template_base'] = PJAX_BASE_TEMPLATE
         # fix redirect problem
         url = '%s?%s' % (request.path, request.META['QUERY_STRING'])
         response['X-PJAX-URL'] = url
         # set version
         if PJAX_VERSION:
             response['X-PJAX-Version'] = PJAX_VERSION
     else:
         logger.debug('full response')
         response.context_data['template_base'] = BASE_TEMPLATE
     return response
コード例 #5
0
        def add_entry(self, entry):
            """Same as the original .add_entry, but sets only=False, so that egg-links are honored."""
            logger.debug('working-set entry: %r', entry)
            self.entry_keys.setdefault(entry, [])
            self.entries.append(entry)
            for dist in pkg_resources.find_distributions(entry, False):

                # eggs override anything that's installed normally
                # fun fact: pkg_resources.working_set's results depend on the
                # ordering of os.listdir since the order of os.listdir is
                # entirely arbitrary (an implemenation detail of file system),
                # without calling site.main(), an .egg-link file may or may not
                # be honored, depending on the filesystem
                replace = (dist.precedence == pkg_resources.EGG_DIST)
                self.add(dist, entry, False, replace=replace)
コード例 #6
0
ファイル: pip_faster.py プロジェクト: jolynch/pip-faster
        def add_entry(self, entry):
            """Same as the original .add_entry, but sets only=False, so that egg-links are honored."""
            logger.debug('working-set entry: %r', entry)
            self.entry_keys.setdefault(entry, [])
            self.entries.append(entry)
            for dist in pkg_resources.find_distributions(entry, False):

                # eggs override anything that's installed normally
                # fun fact: pkg_resources.working_set's results depend on the
                # ordering of os.listdir since the order of os.listdir is
                # entirely arbitrary (an implemenation detail of file system),
                # without calling site.main(), an .egg-link file may or may not
                # be honored, depending on the filesystem
                replace = (dist.precedence == pkg_resources.EGG_DIST)
                self.add(dist, entry, False, replace=replace)
コード例 #7
0
ファイル: models.py プロジェクト: muroslav2909/reserv
    def do(self):
        logger.debug("I'm do it")
        self.init()
        self.driver.get(self.url)
        self.driver.maximize_window()
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_btnAccept"]').click()
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_btnNewAppointment"]').click()
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_ddCitizenship_Input"]').send_keys(self.nationality)
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_ddCountryOfResidence_Input"]').click()
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_ddVisaType_Input"]').click()
        self.driver.find_element_by_xpath('//*[@id="ctl00_cp1_ddVisaType_DropDown"]/div/ul/li[2]').click()

        try:
            self.main_func()
        except Exception, e:
            print e
            self.driver.close()
            if self.status != STOP:
                self.do()
コード例 #8
0
ファイル: pip_faster.py プロジェクト: jolynch/pip-faster
    def find_requirement(self, req, upgrade):
        if req_is_absolute(req.req):
            # if the version is pinned-down by a ==
            # first try to use any installed package that satisfies the req
            if req.satisfied_by:
                logger.notify('Faster! pinned requirement already installed.')
                raise BestVersionAlreadyInstalled

            # then try an optimistic search for a .whl file:
            link = optimistic_wheel_search(req, self.find_links)
            if link is None:
                # The wheel will be built during prepare_files
                logger.debug('No wheel found locally for pinned requirement %s', req)
            else:
                logger.notify('Faster! Pinned wheel found, without hitting PyPI.')
                return link
        else:
            # unpinned requirements aren't very notable. only show with -v
            logger.info('slow: full search for unpinned requirement %s', req)

        # otherwise, do the full network search, per usual
        return super(FasterPackageFinder, self).find_requirement(req, upgrade)
コード例 #9
0
def optimistic_wheel_search(req, find_links):
    assert req_is_pinned(req), req

    # this matches the name-munging done in pip.wheel:
    reqname = req.project_name.replace('-', '_')
    reqname = ignorecase_glob(reqname)
    reqname = reqname + '-*.whl'

    for findlink in find_links:
        if findlink.startswith('file:'):
            findlink = findlink[5:]
        from os.path import join
        findlink = join(findlink, reqname)
        logger.debug('wheel glob: %s', findlink)
        from glob import glob
        for link in glob(findlink):
            from pip.index import Link
            link = Link('file:' + link)
            from pip.wheel import Wheel
            wheel = Wheel(link.filename)
            logger.debug('Candidate wheel: %s', link.filename)
            if wheel.version in req and wheel.supported():
                return link
コード例 #10
0
def optimistic_wheel_search(req, find_links):
    from os.path import join, exists

    best_version = pkg_resources.parse_version('')
    best_link = None
    for findlink in find_links:
        if findlink.startswith('file:'):
            findlink = findlink[5:]
        elif not exists(findlink):
            assert False, 'findlink not file: coverage: %r' % findlink
            continue  # TODO: test coverage
        # this matches the name-munging done in pip.wheel:
        reqname = req.name.replace('-', '_')

        reqname = ignorecase_glob(reqname)
        reqname = join(findlink, reqname + '-*.whl')
        logger.debug('wheel glob: %s', reqname)
        from glob import glob
        for link in glob(reqname):
            from pip.index import Link
            link = Link('file://' + link)
            from pip.wheel import Wheel
            wheel = Wheel(link.filename)
            logger.debug('Candidate wheel: %s', link.filename)
            if wheel.version not in req.req:
                continue

            if not wheel.supported():
                continue

            version = pkg_resources.parse_version(wheel.version)
            if version > best_version:
                best_version = version
                best_link = link

    return best_link
コード例 #11
0
    def find_requirement(self, req, upgrade):
        if req_is_absolute(req.req):
            # if the version is pinned-down by a ==
            # first try to use any installed package that satisfies the req
            if req.satisfied_by:
                logger.notify('Faster! pinned requirement already installed.')
                raise BestVersionAlreadyInstalled

            # then try an optimistic search for a .whl file:
            link = optimistic_wheel_search(req, self.find_links)
            if link is None:
                # The wheel will be built during prepare_files
                logger.debug(
                    'No wheel found locally for pinned requirement %s', req)
            else:
                logger.notify(
                    'Faster! Pinned wheel found, without hitting PyPI.')
                return link
        else:
            # unpinned requirements aren't very notable. only show with -v
            logger.info('slow: full search for unpinned requirement %s', req)

        # otherwise, do the full network search, per usual
        return super(FasterPackageFinder, self).find_requirement(req, upgrade)
コード例 #12
0
ファイル: pip_faster.py プロジェクト: jolynch/pip-faster
def optimistic_wheel_search(req, find_links):
    from os.path import join, exists

    best_version = pkg_resources.parse_version('')
    best_link = None
    for findlink in find_links:
        if findlink.startswith('file:'):
            findlink = findlink[5:]
        elif not exists(findlink):
            assert False, 'findlink not file: coverage: %r' % findlink
            continue  # TODO: test coverage
        # this matches the name-munging done in pip.wheel:
        reqname = req.name.replace('-', '_')

        reqname = ignorecase_glob(reqname)
        reqname = join(findlink, reqname + '-*.whl')
        logger.debug('wheel glob: %s', reqname)
        from glob import glob
        for link in glob(reqname):
            from pip.index import Link
            link = Link('file://' + link)
            from pip.wheel import Wheel
            wheel = Wheel(link.filename)
            logger.debug('Candidate wheel: %s', link.filename)
            if wheel.version not in req.req:
                continue

            if not wheel.supported():
                continue

            version = pkg_resources.parse_version(wheel.version)
            if version > best_version:
                best_version = version
                best_link = link

    return best_link
コード例 #13
0
def trace_requirements(requirements):
    """given an iterable of pip InstallRequirements,
    return the set of required packages, given their transitive requirements.
    """
    requirements = tuple(pretty_req(r) for r in requirements)
    working_set = fresh_working_set()

    # breadth-first traversal:
    from collections import deque
    queue = deque(requirements)
    seen = set()
    errors = []
    result = []
    while queue:
        req = queue.popleft()
        req_id = str(
            req
        )  # InstallRequirement doesn't implement hash/equality, so we compare using str()
        if req_id in seen:
            logger.debug('already analyzed: %s', req)
            continue
        else:
            seen.add(req_id)

        logger.debug('tracing: %s', req)
        if req_cycle(req):
            logger.warn('Circular dependency! %s', req)
            continue

        try:
            dist = working_set.find(req.req)
        except pkg_resources.VersionConflict as conflict:
            dist = conflict.args[0]
            errors.append('Error: version conflict: %s (%s) <-> %s' %
                          (dist, timid_relpath(dist.location), req))

        if dist is None:
            errors.append('Error: unmet dependency: %s' % req)
            continue

        result.append(dist_to_req(dist))

        for dist_req in sorted(dist.requires(), key=lambda req: req.key):
            from pip.req import InstallRequirement
            dist_req = InstallRequirement(dist_req, req)

            logger.debug('adding sub-requirement %s', dist_req)
            queue.append(dist_req)

    if errors:
        raise InstallationError('\n'.join(errors))

    return result
コード例 #14
0
ファイル: pip_faster.py プロジェクト: jolynch/pip-faster
def trace_requirements(requirements):
    """given an iterable of pip InstallRequirements,
    return the set of required packages, given their transitive requirements.
    """
    requirements = tuple(pretty_req(r) for r in requirements)
    working_set = fresh_working_set()

    # breadth-first traversal:
    from collections import deque
    queue = deque(requirements)
    seen = set()
    errors = []
    result = []
    while queue:
        req = queue.popleft()
        req_id = str(req)  # InstallRequirement doesn't implement hash/equality, so we compare using str()
        if req_id in seen:
            logger.debug('already analyzed: %s', req)
            continue
        else:
            seen.add(req_id)

        logger.debug('tracing: %s', req)
        if req_cycle(req):
            logger.warn('Circular dependency! %s', req)
            continue

        try:
            dist = working_set.find(req.req)
        except pkg_resources.VersionConflict as conflict:
            dist = conflict.args[0]
            errors.append('Error: version conflict: %s (%s) <-> %s' % (
                dist, timid_relpath(dist.location), req
            ))

        if dist is None:
            errors.append('Error: unmet dependency: %s' % req)
            continue

        result.append(dist_to_req(dist))

        for dist_req in sorted(dist.requires(), key=lambda req: req.key):
            from pip.req import InstallRequirement
            dist_req = InstallRequirement(dist_req, req)

            logger.debug('adding sub-requirement %s', dist_req)
            queue.append(dist_req)

    if errors:
        raise InstallationError('\n'.join(errors))

    return result
コード例 #15
0
ファイル: pip_faster.py プロジェクト: anthrax3/venv-update
def trace_requirements(requirements):
    """given an iterable of pip InstallRequirements,
    return the set of required packages, given their transitive requirements.
    """
    requirements = tuple(pretty_req(r) for r in requirements)
    working_set = fresh_working_set()

    # breadth-first traversal:
    from collections import deque
    queue = deque(requirements)
    queued = {_package_req_to_pkg_resources_req(req.req) for req in queue}
    errors = []
    result = []
    while queue:
        req = queue.popleft()

        logger.debug('tracing: %s', req)
        try:
            dist = working_set.find_normalized(
                _package_req_to_pkg_resources_req(req.req))
        except pkg_resources.VersionConflict as conflict:
            dist = conflict.args[0]
            errors.append('Error: version conflict: %s (%s) <-> %s' %
                          (dist, timid_relpath(dist.location), req))

        assert dist is not None, 'Should be unreachable in pip8+'
        result.append(dist_to_req(dist))

        # TODO: pip does no validation of extras. should we?
        extras = [extra for extra in req.extras if extra in dist.extras]
        for sub_req in sorted(dist.requires(extras=extras),
                              key=lambda req: req.key):
            sub_req = InstallRequirement(sub_req, req)

            if req_cycle(sub_req):
                logger.warning('Circular dependency! %s', sub_req)
                continue
            elif sub_req.req in queued:
                logger.debug('already queued: %s', sub_req)
                continue
            else:
                logger.debug('adding sub-requirement %s', sub_req)
                queue.append(sub_req)
                queued.add(sub_req.req)

    if errors:
        raise InstallationError('\n'.join(errors))

    return result
コード例 #16
0
ファイル: models.py プロジェクト: muroslav2909/reserv
        #     from selenium.webdriver.common import proxy, desired_capabilities
        #     from selenium.webdriver.firefox import webdriver
        #
        #     p = proxy.Proxy({
        #         'proxyType': proxy.ProxyType().MANUAL,
        #         'httpProxy': '85.143.164.100:81',
        #         })
        #
        #     capabilities = desired_capabilities.DesiredCapabilities().FIREFOX
        #     p.add_to_capabilities(capabilities)
        #     self.driver = webdriver.WebDriver(capabilities=capabilities)

        except Exception, e:
            logger.error(e, exc_info=True, extra={'Message': 'Cant start browser.'})
            self.display.stop()
        logger.debug("Init: good.")
        return True

    # def hover(self):
    #     wd = self.webdriver_connection.connection
    #     element = wd.find_element_by_class_name("recaptcha-checkbox-hover")
    #     hov = self.ActionChains(wd).move_to_element(element)
    #     hov.perform()

    def get_number_image(self, result):
        res = []
        if " " in result:
            result = result.replace(' ', '')
        if ',' in result:
            result = result.replace(',', '')
        if '.' in result: