sys.argv.insert

Here are the examples of the python api sys.argv.insert taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

25 Examples 7

Example 1

Project: bnw
Source File: entry.py
View license
def _entrypoint(name):
    def entrypoint():
        import sys
        from os import path
        app = path.join(path.dirname(__file__),name)
        sys.argv.insert(1, app)
        sys.argv.insert(1, '-y')
        from twisted.scripts.twistd import run
        run()
    return entrypoint

Example 2

Project: python-mode
Source File: utils.py
View license
def insert_default_options():
    """insert default options to sys.argv
    """
    options = get_default_options()
    options.reverse()
    for arg in options:
        sys.argv.insert(1, arg)

Example 3

Project: solace
Source File: scripts.py
View license
    def run(self):
        from werkzeug import run_simple
        def wsgi_app(*a):
            from solace.application import application
            return application(*a)

        # werkzeug restarts the interpreter with the same arguments
        # which would print "running runserver" a second time.  Because
        # of this we force distutils into quiet mode.
        import sys
        sys.argv.insert(1, '-q')

        run_simple(self.host, int(self.port), wsgi_app,
                   use_reloader=not self.no_reloader,
                   use_debugger=not self.no_debugger)

Example 4

Project: solace
Source File: scripts.py
View license
    def run(self):
        from werkzeug import run_simple
        def wsgi_app(*a):
            from solace.application import application
            return application(*a)

        # werkzeug restarts the interpreter with the same arguments
        # which would print "running runserver" a second time.  Because
        # of this we force distutils into quiet mode.
        import sys
        sys.argv.insert(1, '-q')

        run_simple(self.host, int(self.port), wsgi_app,
                   use_reloader=not self.no_reloader,
                   use_debugger=not self.no_debugger)

Example 5

View license
    @mock.patch('os_cloud_config.cmd.utils._clients.get_nova_bm_client')
    @mock.patch('os_cloud_config.flavors.create_flavors_from_nodes')
    @mock.patch.dict('os.environ', {'OS_USERNAME': 'a', 'OS_PASSWORD': 'a',
                     'OS_TENANT_NAME': 'a', 'OS_AUTH_URL': 'a'})
    @mock.patch.object(sys, 'argv', ['setup-flavors', '--nodes', '-k', 'aaa',
                       '-r', 'zzz'])
    def test_with_arguments_nodes(self, create_flavors_mock,
                                  get_nova_bm_client_mock):
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.insert(2, f.name)
            return_code = setup_flavors.main()

        create_flavors_mock.assert_called_once_with(
            get_nova_bm_client_mock(), {}, 'aaa', 'zzz', None)

        self.assertEqual(0, return_code)

Example 6

View license
    @mock.patch('os_cloud_config.cmd.utils._clients.get_nova_bm_client')
    @mock.patch('os_cloud_config.flavors.create_flavors_from_nodes')
    @mock.patch.dict('os.environ', {'OS_USERNAME': 'a', 'OS_PASSWORD': 'a',
                                    'OS_TENANT_NAME': 'a', 'OS_AUTH_URL': 'a',
                                    'ROOT_DISK': '10'})
    @mock.patch.object(sys, 'argv', ['setup-flavors', '--nodes', '-k', 'aaa',
                       '-r', 'zzz'])
    def test_with_arguments_nodes_root_disk(self, create_flavors_mock,
                                            get_nova_bm_client_mock):
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.insert(2, f.name)
            return_code = setup_flavors.main()

        create_flavors_mock.assert_called_once_with(
            get_nova_bm_client_mock(), {}, 'aaa', 'zzz', '10')

        self.assertEqual(0, return_code)

Example 7

View license
    @mock.patch('os_cloud_config.cmd.utils._clients.get_nova_bm_client')
    @mock.patch('os_cloud_config.flavors.create_flavors_from_list')
    @mock.patch.dict('os.environ', {'OS_USERNAME': 'a', 'OS_PASSWORD': 'a',
                     'OS_TENANT_NAME': 'a', 'OS_AUTH_URL': 'a'})
    @mock.patch.object(sys, 'argv', ['setup-flavors', '--flavors', '-k', 'aaa',
                       '-r', 'zzz'])
    def test_with_arguments_flavors(self, create_flavors_mock,
                                    get_nova_bm_client_mock):
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.insert(2, f.name)
            return_code = setup_flavors.main()

        create_flavors_mock.assert_called_once_with(
            get_nova_bm_client_mock(), {}, 'aaa', 'zzz')

        self.assertEqual(0, return_code)

Example 8

View license
    @mock.patch('os_cloud_config.cmd.utils._clients.get_nova_bm_client',
                return_value='nova_bm_client_mock')
    @mock.patch('os_cloud_config.flavors.create_flavors_from_nodes')
    @mock.patch.dict('os.environ', {'OS_USERNAME': 'a', 'OS_PASSWORD': 'a',
                     'OS_TENANT_NAME': 'a', 'OS_AUTH_URL': 'a'})
    @mock.patch.object(sys, 'argv', ['setup-flavors', '--nodes', '-k', 'aaa',
                       '-r', 'zzz'])
    def test_with_exception(self, create_flavors_mock,
                            get_nova_bm_client_mock):
        create_flavors_mock.side_effect = ValueError
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.insert(2, f.name)
            return_code = setup_flavors.main()
        self.assertEqual(1, return_code)

Example 9

Project: pylint
Source File: utils.py
View license
def insert_default_options():
    """insert default options to sys.argv
    """
    options = get_default_options()
    options.reverse()
    for arg in options:
        sys.argv.insert(1, arg)

Example 10

Project: python-mode
Source File: utils.py
View license
def insert_default_options():
    """insert default options to sys.argv
    """
    options = get_default_options()
    options.reverse()
    for arg in options:
        sys.argv.insert(1, arg)

Example 11

Project: rietveld
Source File: run_tests.py
View license
def main():
  sys.argv.insert(1, 'discover')
  sys.argv.insert(2, TESTS_DIR)
  return unittest.main()

Example 12

Project: bnw
Source File: instance.py
View license
def runintwistd():
    sys.argv.insert(1,__file__)
    sys.argv.insert(1,'-y')
    from twisted.scripts.twistd import run

Example 13

Project: bnw
Source File: search.py
View license
def runintwistd():
    sys.argv.insert(1,__file__)
    sys.argv.insert(1,'-y')
    from twisted.scripts.twistd import run

Example 14

Project: moviegrabber
Source File: CheetahWrapper.py
View license
def _cheetah_compile():
    sys.argv.insert(1, "compile")
    CheetahWrapper().main()

Example 15

Project: cgstudiomap
Source File: start_openerp.py
View license
def insert_args(arguments):
    """Insert `arguments` in ``sys.argv`` (direct impact on child script).
    """
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)

Example 16

Project: cgstudiomap
Source File: test_openerp.py
View license
def insert_args(arguments):
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)

Example 17

Project: typefacet
Source File: test_pystache.py
View license
def main(sys_argv=sys.argv):
    sys.argv.insert(1, FROM_SOURCE_OPTION)
    test.main()

Example 18

Project: pystache
Source File: test_pystache.py
View license
def main(sys_argv=sys.argv):
    sys.argv.insert(1, FROM_SOURCE_OPTION)
    test.main()

Example 19

Project: QMarkdowner
Source File: CheetahWrapper.py
View license
def _cheetah_compile():
    sys.argv.insert(1, "compile")
    CheetahWrapper().main()

Example 20

Project: bup-cron
Source File: __init__.py
View license
    def parse_args(self):
        """Process arguments list

        Inject system and user config files and cleanup various
        arguments and defaults that couldn't be done otherwise."""
        configs = map(lambda x: os.path.expanduser(x), self.configs)
        for conf in configs:
            try:
                with open(conf, 'r'):
                    sys.argv.insert(1, '@' + conf)
            except IOError:
                pass
        args = argparse.ArgumentParser.parse_args(self)
        if args.copyright:
            self.exit(0, __license__)
        if args.version:
            self.exit(0, __version__ + "\n")
        if 'BUP_DIR' not in os.environ and not args.repository:
            self.error('argument -d/--repository is required')

        if args.name and args.branch_name:
            self.error('The options --name and --branch-name cannot '
                       'be used together.')

        # merge the path and paths arguments
        if args.path:
            args.paths += args.path
        # remove this one to avoid ambiguity
        del args.path
        if len(args.paths) < 1:
            self.error('argument paths is required')
        os.environ['BUP_DIR'] = args.repository
        # remove this one to avoid ambiguity
        del args.repository
        if args.pidfile is None:
            args.pidfile = os.path.join(os.environ['BUP_DIR'], self.pidfile)
        # repair implies check
        args.check |= args.repair
        return args

Example 21

Project: bup-cron
Source File: __init__.py
View license
    def parse_args(self):
        """Process arguments list

        Inject system and user config files and cleanup various
        arguments and defaults that couldn't be done otherwise."""
        configs = map(lambda x: os.path.expanduser(x), self.configs)
        for conf in configs:
            try:
                with open(conf, 'r'):
                    sys.argv.insert(1, '@' + conf)
            except IOError:
                pass
        args = argparse.ArgumentParser.parse_args(self)
        if args.copyright:
            self.exit(0, __license__)
        if args.version:
            self.exit(0, __version__ + "\n")
        if 'BUP_DIR' not in os.environ and not args.repository:
            self.error('argument -d/--repository is required')

        if args.name and args.branch_name:
            self.error('The options --name and --branch-name cannot '
                       'be used together.')

        # merge the path and paths arguments
        if args.path:
            args.paths += args.path
        # remove this one to avoid ambiguity
        del args.path
        if len(args.paths) < 1:
            self.error('argument paths is required')
        os.environ['BUP_DIR'] = args.repository
        # remove this one to avoid ambiguity
        del args.repository
        if args.pidfile is None:
            args.pidfile = os.path.join(os.environ['BUP_DIR'], self.pidfile)
        # repair implies check
        args.check |= args.repair
        return args

Example 22

Project: anybox.recipe.odoo
Source File: start_openerp.py
View license
def insert_args(arguments):
    """Insert `arguments` in ``sys.argv`` (direct impact on child script).
    """
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)

Example 23

Project: anybox.recipe.odoo
Source File: start_openerp.py
View license
def insert_args(arguments):
    """Insert `arguments` in ``sys.argv`` (direct impact on child script).
    """
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)

Example 24

Project: anybox.recipe.odoo
Source File: test_openerp.py
View license
def insert_args(arguments):
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)

Example 25

Project: anybox.recipe.odoo
Source File: test_openerp.py
View license
def insert_args(arguments):
    for i, a in enumerate(arguments):
        sys.argv.insert(i+1, a)