Пример #1
0
def _bootout_pip():
    import shutil, tempfile, pkgutil
    from urllib.request import urlopen
    from pip._internal import main
    #
    tmpdir0 = tempfile.mkdtemp()
    with open(os.path.join(tmpdir0, 'get_pip.py'), 'wb') as openfile:
        openfile.write(urlopen('https://bootstrap.pypa.io/get-pip.py').read())
    sys.path.append(tmpdir0)
    from get_pip import b85decode, DATA
    #
    tmpdir = tempfile.mkdtemp()
    pip_zip = os.path.join(tmpdir, "pip.zip")
    with open(pip_zip, "wb") as fp:
        fp.write(b85decode(DATA.replace(b"\n", b"")))
    shutil.rmtree(tmpdir0)

    val = sys.path.pop()
    sys.path.append(pip_zip)
    import pip

    cert_path = os.path.join(tmpdir, "cacert.pem")
    with open(cert_path, 'wb') as cert:
        cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))

    #
    ## also put other packages in there..
    main([
        'install', '--user', '--upgrade', '--cert', cert_path, 'pip',
        'setuptools', 'wheel'
    ])
    shutil.rmtree(tmpdir)
    print('INSTALLED pip AND NECESSARY DEPENDENCIES.')
    print('RERUN THIS APP TO INSTALL REST OF DEPENDENCIES.')
    sys.exit(0)
Пример #2
0
    def paid_method(self, request):
        try:
            from mollie.api.client import Client
        except:
            from pip._internal import main
            main(['install', 'mollie.api.client'])
            from mollie.api.client import Client
        url = request.query_params.get('url')  #hostname send from frontend
        mollie_client = Client()
        mollie_client.set_api_key('test_Cpf7MF9sAfpSmvnbqMRwuaFqBSRQF4')
        userid = request.query_params.get('userId')
        redirect_url = "http://127.0.0.1:8000/order/3/" if url == "127.0.0.1" else "http://" + settings.ALLOWED_HOSTS[
            0] + "/order/3/"
        print(self.total(userid))
        payment = mollie_client.payments.create({
            'amount': {
                'currency': 'EUR',
                'value': '{}.00'.format(self.total(userid))
                # 'value': '10.00'
            },
            'description': 'My first API payment',
            "redirectUrl": redirect_url,
            # 'webhookUrl': 'https://webshop.example.org/mollie-webhook/',
        })

        return Response(payment)
Пример #3
0
def install(package):
    import importlib
    try:
        importlib.import_module(package)
    except ImportError:
        import pip
        main(['install', package])
Пример #4
0
def install_numpy():
    try:
        import numpy
    except:
        try:
            import pip
            try:
                import pya
                install = pya.MessageBox.warning(
                    "Install package?", "Install package 'numpy' using pip?",
                    pya.MessageBox.Yes + pya.MessageBox.No)
                if install == pya.MessageBox.Yes:
                    # try installing using pip
                    from SiEPIC.install import get_pip_main
                    main = get_pip_main()
                    main(['install', 'numpy'])
            except ImportError:
                install = pya.MessageBox.warning(
                    "Install using pip failed",
                    "Error importing 'pip' to install package 'numpy'",
                    pya.MessageBox.Yes + pya.MessageBox.No)
                return False
        except ImportError:
            return False
    return True
Пример #5
0
def _install_packages(path, packages):
    """Install all packages listed to the target directory.

    Ignores any package that includes Python itself and python-lambda as well
    since its only needed for deploying and not running the code

    :param str path:
        Path to copy installed pip packages to.
    :param list packages:
        A list of packages to be installed via pip.
    """
    def _filter_blacklist(package):
        blacklist = ['-i', '#', 'Python==', 'python-lambda==']
        return all(package.startswith(entry) is False for entry in blacklist)

    filtered_packages = filter(_filter_blacklist, packages)

    pip_major_version = [int(v) for v in pip.__version__.split('.')][0]
    print('Pip major version: %s' % pip_major_version)

    for package in filtered_packages:
        if package.startswith('-e '):
            package = package.replace('-e ', '')

        print('Installing {package}'.format(package=package))

        if pip_major_version >= 10:
            from pip._internal import main
            main(['install', package, '-t', path, '--ignore-installed'])
        else:
            pip.main(['install', package, '-t', path, '--ignore-installed'])
Пример #6
0
def install(packages, id):
    for package in packages:
        try:
            pip.main(['install', package, '--target', '/tmp/{0}'.format(id)])
        except:
            return False
    return True
Пример #7
0
def ci(python="python", codecov="codecov", coverage_file="coverage.xml", wheel=True):
    """
    Run the most common CI tasks
    """

    # Import pip
    from pip import __version__ as pip_version
    if Version(pip_version) >= Version("10.0.0"):
        import pip._internal as pip
    else:
        import pip

    # Install requirements with pip
    pip.main(["install"] + DEPENDENCIES + REQUIREMENTS + ["-U"])
    # Build the installation wheel
    if wheel is True:
        build_and_install_wheel(python)
        # Remove all non-essential files
        for to_delete in TO_DELETE:
            rmtree(to_delete)
    # Run the tests on the installed ttkthemes
    return_code = run_command("{} -m nose --with-coverage --cover-xml --cover-package=ttkthemes".format(python))
    if return_code != 0:
        print("Tests failed.")
        exit(return_code)
    print("Tests successful.")
    # Run codecov
    return_code = run_command("{} -f {}".format(codecov, coverage_file))
    if return_code != 0:
        print("Codecov failed.")
        exit(return_code)
    # Successfully finished CI
    exit(0)
Пример #8
0
def lambda_build(event, context):
    import sys
    import shutil

    os.chdir("/tmp")
    path = "/tmp/deps"
    if os.path.exists(path):
        shutil.rmtree(path)

    if sys.version_info[0] == 2:
        import boto3
        import zipfile

        s3Client = boto3.client("s3")
        req = s3Client.download_file("eigensheep", "pip27.zip",
                                     "/tmp/pip27.zip")
        with zipfile.ZipFile("/tmp/pip27.zip", "r") as zip_ref:
            zip_ref.extractall("/tmp/pkg")
        sys.path.append("/tmp/pkg/site-packages")

    from pip import _internal

    _internal.main([
        "install", "--no-cache-dir", "--progress-bar=off", "--target=" + path
    ] + event["requirements"])

    package = build_lambda_package(path)
    save(event["s3_key"], package)
    return {}
Пример #9
0
    def run_outdated(cls, options):
        """Print outdated user packages."""
        latest_versions = sorted(
            cls.find_packages_latest_versions(cls.options),
            key=lambda p: p[0].project_name.lower())

        for dist, latest_version, typ in latest_versions:
            if latest_version > dist.parsed_version:
                if options.all:
                    pass
                elif options.pinned:
                    if cls.can_be_updated(dist, latest_version):
                        continue
                elif not options.pinned:
                    if not cls.can_be_updated(dist, latest_version):
                        continue
                    elif options.update:
                        print(dist.project_name if options.brief else
                              'Updating %s to Latest: %s [%s]' %
                              (cls.output_package(dist), latest_version, typ))
                        main(['install', '--upgrade'] + ([
                            '--user'
                        ] if ENABLE_USER_SITE else []) + [dist.key])
                        continue

                print(dist.project_name if options.brief else
                      '%s - Latest: %s [%s]' %
                      (cls.output_package(dist), latest_version, typ))
Пример #10
0
 def run(self):
     global m
     try:
         from pip._internal import main
     except ImportError:
         from pip import main
     main(['install', '--upgrade'] + m['install_requires'])
Пример #11
0
 def run(self):
     global m
     try:
         from pip._internal import main
     except ImportError:
         from pip import main
     main(['install', '--upgrade'] + m['install_requires'])
Пример #12
0
def check_dependency():
    pkgs = ['pandas']
    for package in pkgs:
        try:
            import package
        except ImportError:
            main(['install', package])
Пример #13
0
 def run(self, *args, **kwargs):
     try:
         from pip._internal import main
     except ImportError:
         from pip import main
     main(['install', '.'])
     InstallCommand.run(self, *args, **kwargs)
Пример #14
0
def _install_packages(path, packages):
    """Install all packages listed to the target directory.

    Ignores any package that includes Python itself and python-lambda as well
    since its only needed for deploying and not running the code

    :param str path:
        Path to copy installed pip packages to.
    :param list packages:
        A list of packages to be installed via pip.
    """
    def _filter_blacklist(package):
        blacklist = ['-i', '#', 'Python==', 'python-lambda==']
        return all(package.startswith(entry) is False for entry in blacklist)
    filtered_packages = filter(_filter_blacklist, packages)
    for package in filtered_packages:
        if package.startswith('-e '):
            package = package.replace('-e ', '')

        print('Installing {package}'.format(package=package))
        pip_major_version = [int(v) for v in pip.__version__.split('.')][0]
        if pip_major_version >= 10:
            from pip._internal import main
            main(['install', package, '-t', path, '--ignore-installed'])
        else:
            pip.main(['install', package, '-t', path, '--ignore-installed'])
Пример #15
0
def install_pip_requirements():
    ''' Install Requeriments from pip '''
    try:
        import pip
    except ImportError:
        qgsu.showUserAndLogMessage(QCoreApplication.translate(
            "QgsFmvUtils", "Failed Import Pip! : "),
                                   "",
                                   onlyLog=True)
        raise

    package_dir = QgsApplication.qgisSettingsDirPath(
    ) + 'python/plugins/QGIS_FMV/'
    requirements_file = os.path.join(package_dir, 'requirements.txt')
    if not os.path.isfile(requirements_file):
        qgsu.showUserAndLogMessage(QCoreApplication.translate(
            "QgsFmvUtils",
            'No requirements file found in {}'.format(requirements_file)),
                                   "",
                                   onlyLog=True)
        raise
    try:
        version_num = pip.__version__[:pip.__version__.find('.')]
        if int(version_num) <= 10:
            pip.main(['install', '-r', requirements_file])
        else:
            from pip._internal import main
            main(['install', '-r', requirements_file])
    except Exception:
        raise
    return
Пример #16
0
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    from pip._internal import main
    main(args)
Пример #17
0
def _run_pip(args, additional_paths=None):
    # Add our bundled software to the sys.path so we can import it
    if additional_paths is not None:
        sys.path = additional_paths + sys.path

    # Install the bundled software
    from pip._internal import main
    main(args)
Пример #18
0
def install():
    dependencies = [
        'wheel', 'setuptools', 'docutils', 'pygments', 'pypiwin32',
        'kivy.deps.sdl2', 'kivy.deps.glew', 'kivy.deps.gstreamer', 'kivy',
        'passlib'
    ]
    for dep in dependencies:
        main(['install', dep])
Пример #19
0
 def test_cache_dir__PIP_NO_CACHE_DIR_invalid__with_no_cache_dir(self):
     """
     Test setting PIP_NO_CACHE_DIR to an invalid value while also passing
     --no-cache-dir.
     """
     os.environ['PIP_NO_CACHE_DIR'] = 'maybe'
     with assert_raises_message(ValueError, "invalid truth value 'maybe'"):
         main(['--no-cache-dir', 'fake'])
Пример #20
0
def pip_install(package):
    if package == "docx":
        os.system("pip uninstall docx -y")
        main(['install', "python-docx"])
    try:
        main(['install', package])
    except Exception as identifier:
        pass
Пример #21
0
def install(package):
    import importlib
    try:
        importlib.import_module(package)
    except ImportError:

        from pip._internal import main
        main(['install', package])
Пример #22
0
def install_and_import(package):
    import importlib
    try:
        importlib.import_module(package)
    except ImportError:
        main(["install", "--user", package])
    finally:
        globals()[package] = importlib.import_module(package)
Пример #23
0
def _install_packages_local(requirements):
    from pip._internal import main
    try:
        main(['install', '--user', '--upgrade'] + requirements +
             ['--trusted-host', 'pypi.python.org'] +
             ['--trusted-host', 'pypi.org'] +
             ['--trusted-host', 'files.pythonhosted.org'])
    except:
        main(['install', '--user', '--upgrade'] + requirements)
Пример #24
0
 def install_app_requirements(self):
     print(" * Installing requirements...")
     if self.distribution.install_requires:
         pip.main([
             'install', '--upgrade', '--force-reinstall',
             '--target={}'.format(self.app_packages_dir)
         ] + self.distribution.install_requires, )
     else:
         print("No requirements.")
Пример #25
0
def setupCheck(appname):
    '''
    check dependency when starting the application
    '''
    missDeps = missingDependency(appname)
    if len(missDeps) == 0:
        print('#')
        print('-> all depedency is complete')
        print('#')

    else:
        print('#')
        print('-> missing depedencies!')
        print('-> '.format(missDeps))
        # check if python pip is installeds
        try:
            missDeps.index('pip')
            print('=> installing pip from {}...'.format(
                'https://bootstrap.pypa.io/get-pip.py'))
            urllib.request.urlretrieve('https://bootstrap.pypa.io/get-pip.py',
                                       'get-pip.py')
            calloutput = subprocess.run('{} get-pip.py'.format(sys.executable),
                                        shell=True,
                                        env={'LANG': 'C'})
            os.remove('get-pip.py')

        except ValueError:
            pass

        finally:
            # install the depedency if python pip is not missing
            import pip

            # check compatibility with pip 10
            try:
                from pip._internal import main

            except:
                from pip import main

            for dep in missDeps:
                print('=> installing {}...'.format(dep))
                # if dep.find('transcrypt') != -1:
                #    main(['install', 'transcrypt'])

                # else:
                main(['install', dep])

            try:
                # updating all depedency
                main(main['install', 'update'])

            except Exception as ex:
                print(ex)

        print('#')
Пример #26
0
def uninstall_package(package):
    try:
        from pip._internal import main
    except Exception:
        from pip import main
    install_command = ['uninstall']
    if os.geteuid() != 0:
        install_command.append("--user")
    install_command.append(package)
    main(install_command)
Пример #27
0
 def install_code(self):
     print(" * Installing project code...")
     pip.main([
         'install',
         '--upgrade',
         '--force-reinstall',
         '--no-dependencies',  # We just want the code, not the dependencies
         '--target={}'.format(self.app_dir),
         '.'
     ])
Пример #28
0
 def run(self):
     global m
     try:
         from pip._internal import main
     except ImportError:
         from pip import main
     try:
         main(['install', '--upgrade'] + m['install_requires'])
     except TypeError:  # recent pip
         main.main(['install', '--upgrade'] + m['install_requires'])
Пример #29
0
def ci(python="python", codecov="codecov", coverage_file="coverage.xml"):
    """
    Run the most common CI tasks
    """

    # Import pip
    from pip import __version__ as pip_version
    if Version(pip_version) >= Version("10.0.0"):
        import pip._internal as pip
    else:
        import pip

    # Install requirements with pip
    pip.main(["install"] + DEPENDENCIES + REQUIREMENTS + ["-U"])
    # Build the installation wheel
    dist_type = "bdist_wheel" if not SDIST else "sdist"
    return_code = run_command("{} setup.py {}".format(python, dist_type))
    if return_code != 0:
        print("Building and installing wheel failed.")
        exit(return_code)
    assert os.path.exists(os.path.join("ttkthemes", "tkimg"))
    # Check if an artifact exists
    assert check_wheel_existence()
    print("Wheel file exists.")
    # Install the wheel file
    wheel = [
        file for file in os.listdir("dist")
        if file.endswith((".whl", ".tar.gz"))
    ][0]
    wheel = os.path.join("dist", wheel)
    print("Wheel file:", wheel)
    return_code = run_command("{} -m pip install --ignore-installed {}".format(
        python, wheel))
    if return_code != 0:
        print("Installation of wheel failed.")
        exit(return_code)
    print("Wheel file installed.")
    # Remove all non-essential files
    for to_delete in TO_DELETE:
        rmtree(to_delete)
    # Run the tests on the installed ttkthemes
    return_code = run_command(
        "{} -m nose --with-coverage --cover-xml --cover-package=ttkthemes".
        format(python))
    if return_code != 0:
        print("Tests failed.")
        exit(return_code)
    print("Tests successful.")
    # Run codecov
    return_code = run_command("{} -f {}".format(codecov, coverage_file))
    if return_code != 0:
        print("Codecov failed.")
        exit(return_code)
    # Successfully finished CI
    exit(0)
Пример #30
0
    def install_launch_scripts(self):
        exe_names = []
        if self.distribution.entry_points:
            print(" * Creating launchers...")
            pip.main([
                'install', '--upgrade', '--force-reinstall',
                '--target=%s' % self.app_packages_dir, 'setuptools'
            ])

            rel_sesources = os.path.relpath(self.resource_dir,
                                            self.launcher_script_location)
            rel_sesources_split = ', '.join(
                ["'%s'" % f for f in rel_sesources.split(os.sep)])

            easy_install.ScriptWriter.template = textwrap.dedent("""
                # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
                __requires__ = %(spec)r
                import os
                import re
                import sys
                import site
                from os.path import dirname, abspath, join
                resources = abspath(join(dirname(__file__), {}))
                site.addsitedir(join(resources, 'app'))
                site.addsitedir(join(resources, 'app_packages'))
                os.environ['PATH'] += os.pathsep + resources

                from pkg_resources import load_entry_point

                if __name__ == '__main__':
                    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
                    sys.exit(
                        load_entry_point(%(spec)r, %(group)r, %(name)r)()
                    )
            """.format(rel_sesources_split)).lstrip()

            ei = easy_install.easy_install(self.distribution)
            for dist in pkg_resources.find_distributions(self.app_dir):
                # Note: this is a different Distribution class to self.distribution
                ei.args = True  # Needs something to run finalize_options
                ei.finalize_options()
                ei.script_dir = self.launcher_script_location
                for args in easy_install.ScriptWriter.best().get_args(
                        dist, header=self.launcher_header):
                    ei.write_script(*args)

                # Grab names of launchers
                for entry_points in dist.get_entry_map().values():
                    exe_names.extend(entry_points.keys())

            if self.formal_name not in exe_names:
                print(" ! No entry_point matching formal_name, \n"
                      "   template builtin script will be main launcher.")

        return exe_names
Пример #31
0
    def test_env_override_default_append(self):
        """
        Test that environment variable overrides an append option default.
        """
        os.environ['PIP_FIND_LINKS'] = 'F1'
        options, args = main(['fake'])
        assert options.find_links == ['F1']

        os.environ['PIP_FIND_LINKS'] = 'F1 F2'
        options, args = main(['fake'])
        assert options.find_links == ['F1', 'F2']
Пример #32
0
 def test_cache_dir__PIP_NO_CACHE_DIR_invalid__with_no_cache_dir(
         self, capsys,
 ):
     """
     Test setting PIP_NO_CACHE_DIR to an invalid value while also passing
     --no-cache-dir.
     """
     os.environ['PIP_NO_CACHE_DIR'] = 'maybe'
     expected_err = "--no-cache-dir error: invalid truth value 'maybe'"
     with assert_option_error(capsys, expected=expected_err):
         main(['--no-cache-dir', 'fake'])
Пример #33
0
 def test_cache_dir__PIP_NO_CACHE_DIR_invalid__with_no_cache_dir(
         self, capsys,
 ):
     """
     Test setting PIP_NO_CACHE_DIR to an invalid value while also passing
     --no-cache-dir.
     """
     os.environ['PIP_NO_CACHE_DIR'] = 'maybe'
     expected_err = "--no-cache-dir error: invalid truth value 'maybe'"
     with assert_option_error(capsys, expected=expected_err):
         main(['--no-cache-dir', 'fake'])
Пример #34
0
    def test_env_override_default_choice(self):
        """
        Test that environment variable overrides a choice option default.
        """
        os.environ['PIP_EXISTS_ACTION'] = 'w'
        options, args = main(['fake'])
        assert options.exists_action == ['w']

        os.environ['PIP_EXISTS_ACTION'] = 's w'
        options, args = main(['fake'])
        assert options.exists_action == ['s', 'w']
Пример #35
0
 def install_platform_requirements(self):
     print(" * Installing platform requirements...")
     if self.app_requires:
         pip.main([
             'install',
             '--upgrade',
             '--force-reinstall',
             '--target={}'.format(self.app_packages_dir),
         ] + self.app_requires)
     else:
         print("No platform requirements.")
Пример #36
0
def about():
    """
    Prints the information for pennylane installation.
    """
    plugin_devices = [entry.name for entry in iter_entry_points("pennylane.plugins")]
    _internal.main(["show", "pennylane"])
    print("Python Version:          {0}.{1}.{2}".format(*sys.version_info[0:3]))
    print("Platform Info:           {}{}".format(platform.system(), platform.machine()))
    print("Installed plugins:       {}".format(plugin_devices))
    print("Numpy Version:           {}".format(numpy.__version__))
    print("Scipy Version:           {}".format(scipy.__version__))
Пример #37
0
    def test_env_override_default_choice(self):
        """
        Test that environment variable overrides a choice option default.
        """
        os.environ['PIP_EXISTS_ACTION'] = 'w'
        options, args = main(['fake'])
        assert options.exists_action == ['w']

        os.environ['PIP_EXISTS_ACTION'] = 's w'
        options, args = main(['fake'])
        assert options.exists_action == ['s', 'w']
Пример #38
0
    def test_env_override_default_append(self):
        """
        Test that environment variable overrides an append option default.
        """
        os.environ['PIP_FIND_LINKS'] = 'F1'
        options, args = main(['fake'])
        assert options.find_links == ['F1']

        os.environ['PIP_FIND_LINKS'] = 'F1 F2'
        options, args = main(['fake'])
        assert options.find_links == ['F1', 'F2']
Пример #39
0
 def test_env_alias_override_default(self):
     """
     When an option has multiple long forms, test that the technique of
     using the env variable, "PIP_<long form>" works for all cases.
     (e.g. PIP_LOG_FILE and PIP_LOCAL_LOG should all work)
     """
     os.environ['PIP_LOG_FILE'] = 'override.log'
     options, args = main(['fake'])
     assert options.log == 'override.log'
     os.environ['PIP_LOCAL_LOG'] = 'override.log'
     options, args = main(['fake'])
     assert options.log == 'override.log'
Пример #40
0
 def test_cli_override_environment(self):
     """
     Test the cli overrides and environment variable
     """
     os.environ['PIP_TIMEOUT'] = '-1'
     options, args = main(['fake', '--timeout', '-2'])
     assert options.timeout == -2
Пример #41
0
 def test_env_override_default_int(self):
     """
     Test that environment variable overrides an int option default.
     """
     os.environ['PIP_TIMEOUT'] = '-1'
     options, args = main(['fake'])
     assert options.timeout == -1
Пример #42
0
 def test_cache_dir__PIP_NO_CACHE_DIR(self, pip_no_cache_dir):
     """
     Test setting the PIP_NO_CACHE_DIR environment variable without
     passing any command-line flags.
     """
     os.environ['PIP_NO_CACHE_DIR'] = pip_no_cache_dir
     options, args = main(['fake'])
     assert options.cache_dir is False
Пример #43
0
 def test_cache_dir__PIP_NO_CACHE_DIR__with_cache_dir(
     self, pip_no_cache_dir
 ):
     """
     Test setting PIP_NO_CACHE_DIR while also passing an explicit
     --cache-dir value.
     """
     os.environ['PIP_NO_CACHE_DIR'] = pip_no_cache_dir
     options, args = main(['--cache-dir', '/cache/dir', 'fake'])
     # The command-line flag takes precedence.
     assert options.cache_dir == '/cache/dir'
Пример #44
0
 def test_cache_dir__PIP_NO_CACHE_DIR__with_no_cache_dir(
     self, pip_no_cache_dir
 ):
     """
     Test setting PIP_NO_CACHE_DIR while also passing --no-cache-dir.
     """
     os.environ['PIP_NO_CACHE_DIR'] = pip_no_cache_dir
     options, args = main(['--no-cache-dir', 'fake'])
     # The command-line flag should take precedence (which has the same
     # value in this case).
     assert options.cache_dir is False
Пример #45
0
 def update(self):
     from pip._internal import main
     from pip._internal.utils.misc import get_installed_distributions
     module_list = []
     for dist in get_installed_distributions():
         requires = [req.key for req in dist.requires()]
         if (dist.key == 'lucterios') or ('lucterios' in requires):
             module_list.append(dist.project_name)
     if len(module_list) > 0:
         try:
             self.print_info_("Modules to update: %s" %
                              ",".join(module_list))
             options = self.get_default_args_(['install', '-U'])
             options.extend(module_list)
             main(options)
         finally:
             self.refreshall()
         return True
     else:
         self.print_info_("No modules to update")
         return False
Пример #46
0
    def test_quiet(self):
        options1, args1 = main(['--quiet', 'fake'])
        options2, args2 = main(['fake', '--quiet'])
        assert options1.quiet == options2.quiet == 1

        options3, args3 = main(['--quiet', '--quiet', 'fake'])
        options4, args4 = main(['fake', '--quiet', '--quiet'])
        assert options3.quiet == options4.quiet == 2

        options5, args5 = main(['--quiet', '--quiet', '--quiet', 'fake'])
        options6, args6 = main(['fake', '--quiet', '--quiet', '--quiet'])
        assert options5.quiet == options6.quiet == 3
Пример #47
0
 def test_require_virtualenv(self):
     options1, args1 = main(['--require-virtualenv', 'fake'])
     options2, args2 = main(['fake', '--require-virtualenv'])
     assert options1.require_venv
     assert options2.require_venv
Пример #48
0
 def test_local_log(self):
     options1, args1 = main(['--local-log', 'path', 'fake'])
     options2, args2 = main(['fake', '--local-log', 'path'])
     assert options1.log == options2.log == 'path'
Пример #49
0
 def test_no_input(self):
     options1, args1 = main(['--no-input', 'fake'])
     options2, args2 = main(['fake', '--no-input'])
     assert options1.no_input
     assert options2.no_input
Пример #50
0
 def test_timeout(self):
     options1, args1 = main(['--timeout', '-1', 'fake'])
     options2, args2 = main(['fake', '--timeout', '-1'])
     assert options1.timeout == options2.timeout == -1
Пример #51
0
 def test_proxy(self):
     options1, args1 = main(['--proxy', 'path', 'fake'])
     options2, args2 = main(['fake', '--proxy', 'path'])
     assert options1.proxy == options2.proxy == 'path'
Пример #52
0
    from lucterios.framework.settings import fill_appli_settings
    import types
    import gc
    gc.collect()
    lct_modules = []
    glob = LucteriosGlobal()
    _, mod_applis, mod_modules = glob.installed()
    for mod_item in mod_applis:
        lct_modules.append(mod_item[0])
    for mod_item in mod_modules:
        lct_modules.append(mod_item[0])
    try:
        module = types.ModuleType("default_setting")
    except TypeError:
        module = types.ModuleType(six.binary_type("default_setting"))
    setattr(module, '__file__', "")
    setattr(module, 'SECRET_KEY', "default_setting")
    setattr(
        module, 'DATABASES', {'default': {'ENGINE': 'django.db.backends.dummy'}})
    fill_appli_settings("lucterios.standard", lct_modules, module)
    sys.modules["default_setting"] = module
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "default_setting")
    import django
    from django import db
    django.setup()
    db.close_old_connections()


if __name__ == '__main__':
    main()
Пример #53
0
 def test_retries(self):
     options1, args1 = main(['--retries', '-1', 'fake'])
     options2, args2 = main(['fake', '--retries', '-1'])
     assert options1.retries == options2.retries == -1
Пример #54
0
 def test_client_cert(self):
     options1, args1 = main(['--client-cert', 'path', 'fake'])
     options2, args2 = main(['fake', '--client-cert', 'path'])
     assert options1.client_cert == options2.client_cert == 'path'
Пример #55
0
try:
    import xlrd
except ImportError:
    import pip
    try:
        pip.main(["install", "xlrd"])
        import xlrd
    except AttributeError:
        from pip import _internal
        _internal.main(["install", "xlrd"])
        import xlrd

from filldict import cell, fill


book = xlrd.open_workbook("data.xlsx")
sheet = book.sheet_by_name("Limits")

def g(x, y):
    return sheet.cell_value(rowx=y, colx=x)

template = {
    cell(["a3", ..., "a5"], g, func=lambda x: x + "a"): cell((6, 0), g, rel=True, func=str)
}


print(fill(template))
Пример #56
0
 def test_no_cache_dir__provided(self):
     options, args = main(['--no-cache-dir', 'fake'])
     assert options.cache_dir is False
Пример #57
0
# -*- coding: utf-8 -*-
import re
import sys

from pip._internal import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
Пример #58
0
 def test_verbose(self):
     options1, args1 = main(['--verbose', 'fake'])
     options2, args2 = main(['fake', '--verbose'])
     assert options1.verbose == options2.verbose == 1
Пример #59
0
 def test_skip_requirements_regex(self):
     options1, args1 = main(['--skip-requirements-regex', 'path', 'fake'])
     options2, args2 = main(['fake', '--skip-requirements-regex', 'path'])
     assert options1.skip_requirements_regex == 'path'
     assert options2.skip_requirements_regex == 'path'
Пример #60
0
 def test_exists_action(self):
     options1, args1 = main(['--exists-action', 'w', 'fake'])
     options2, args2 = main(['fake', '--exists-action', 'w'])
     assert options1.exists_action == options2.exists_action == ['w']