Beispiel #1
0
Datei: main.py Projekt: dejw/vip
def main():
    parser, args = create_argument_parser()

    commands = ["init", "locate", "command"]

    # Configure logger using --verbose option
    core.logger.verbose = bool(args.verbose)

    with protect_from_VipError():

        if args.version:
            sys.stdout.write("%s\n" % vip.VERSION)
            sys.exit(0)

        # Check for only one command
        used_commands = [int(bool(getattr(args, cmd))) for cmd in commands]
        if sum(used_commands) > 1:
            parser.print_help()

        elif args.init:
            directory = core.create_virtualenv(args.init)
            core.logger.info("Initialized virtualenv in %s" % directory)

        elif args.locate:
            sys.stdout.write(core.find_vip_directory(args.locate) + "\n")

        elif args.command:
            directory = core.find_vip_directory()
            return_code = core.execute_virtualenv_command(
                directory, args.command, args.arguments)

            sys.exit(return_code)
        else:
            parser.print_help()
Beispiel #2
0
    def test_create_virtualenv(self):
        repo_dir = path.normpath(path.join(path.dirname(__file__),
                                 'fixtures', 'test1'))
        vip_dir = path.join(repo_dir, '.vip')

        self.mox.StubOutWithMock(virtualenv, 'create_environment')

        self.mox.StubOutWithMock(core, 'execute_virtualenv_command')
        core.execute_virtualenv_command(
            vip_dir, 'pip',
            ['install', '-r', path.join(repo_dir, 'requirements.txt')])

        self.mox.ReplayAll()
        self.mox.StubOutWithMock(core, 'logger', use_mock_anything=True)

        dir_ = core.create_virtualenv(repo_dir)

        mox.Reset(core.logger)
        self.mox.VerifyAll()
        self.assertEqual(vip_dir, dir_)