当前位置: 首页>>代码示例>>Python>>正文


Python Recipe.make_scripts方法代码示例

本文整理汇总了Python中djangorecipe.recipe.Recipe.make_scripts方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.make_scripts方法的具体用法?Python Recipe.make_scripts怎么用?Python Recipe.make_scripts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在djangorecipe.recipe.Recipe的用法示例。


在下文中一共展示了Recipe.make_scripts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_python_option

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import make_scripts [as 别名]
 def test_python_option(self):
     # The python option makes it possible to specify a specific Python 
     # executable which is to be used for the generated scripts.
     recipe = Recipe({'buildout': {'eggs-directory': self.eggs_dir,
                                   'develop-eggs-directory': self.develop_eggs_dir,
                                   'python': 'python-version',
                                   'bin-directory': self.bin_dir,
                                   'parts-directory': self.parts_dir,
                                   'directory': self.buildout_dir,
                                  },
                      'python-version': {'executable': '/python4k'}}, 
                     'django',
                     {'recipe': 'djangorecipe', 'version': 'trunk',
                      'wsgi': 'true'})
     recipe.make_scripts([], [])
     # This should have created a script in the bin dir
     wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
     self.assertEqual(open(wsgi_script).readlines()[0], '#!/python4k\n')
     # Changeing the option for only the part will change the used Python
     # version.
     recipe = Recipe({'buildout': {'eggs-directory': self.eggs_dir,
                                   'develop-eggs-directory': self.develop_eggs_dir,
                                   'python': 'python-version',
                                   'bin-directory': self.bin_dir,
                                   'parts-directory': self.parts_dir,
                                   'directory': self.buildout_dir,
                                  },
                      'python-version': {'executable': '/python4k'},
                      'py5k': {'executable': '/python5k'}}, 
                     'django',
                     {'recipe': 'djangorecipe', 'version': 'trunk',
                      'python': 'py5k', 'wsgi': 'true'})
     recipe.make_scripts([], [])
     self.assertEqual(open(wsgi_script).readlines()[0], '#!/python5k\n')        
开发者ID:attilaolah,项目名称:djangorecipe,代码行数:36,代码来源:tests.py

示例2: test_relative_paths_true

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import make_scripts [as 别名]
    def test_relative_paths_true(self):
        recipe = Recipe({
                'buildout': {
                    'eggs-directory': self.eggs_dir,
                    'develop-eggs-directory': self.develop_eggs_dir,
                    'python': 'python-version',
                    'bin-directory': self.bin_dir,
                    'parts-directory': self.parts_dir,
                    'directory': self.buildout_dir,
                    'find-links': '',
                    'allow-hosts': '',
                    'develop': '.',
                    'relative-paths': 'true'
                    },
                'python-version': {'executable': sys.executable}},
                             'django',
                             {'recipe': 'djangorecipe',
                              'wsgi': 'true'})
        recipe.make_scripts([], [])
        recipe.create_manage_script([], [])

        manage = os.path.join(self.bin_dir, 'django')
        wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')

        expected = base = 'base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))'
        self.assertTrue(expected in open(manage).read())
        self.assertTrue(expected in open(wsgi_script).read())
开发者ID:ethirajit,项目名称:onlinepos,代码行数:29,代码来源:tests.py

示例3: test_python_option

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import make_scripts [as 别名]
 def test_python_option(self):
     # Changing the option for only the part will change the used Python
     # version.
     recipe_args = copy.deepcopy(self.recipe_initialisation)
     recipe_args[0].update({'py5k': {'executable': '/python5k'}})
     recipe_args[2].update({'python': 'py5k',
                            'wsgi': 'true'})
     recipe = Recipe(*recipe_args)
     wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
     recipe.make_scripts([], [])
     self.assertEqual(open(wsgi_script).readlines()[0], '#!/python5k\n')
开发者ID:sirex,项目名称:djangorecipe,代码行数:13,代码来源:tests.py

示例4: TestRecipe

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import make_scripts [as 别名]
class TestRecipe(unittest.TestCase):

    def setUp(self):
        # Create a directory for our buildout files created by the recipe
        self.buildout_dir = tempfile.mkdtemp('djangorecipe')

        self.bin_dir = os.path.join(self.buildout_dir, 'bin')
        self.develop_eggs_dir = os.path.join(self.buildout_dir,
                                             'develop-eggs')
        self.eggs_dir = os.path.join(self.buildout_dir, 'eggs')
        self.parts_dir = os.path.join(self.buildout_dir, 'parts')

        # We need to create the bin dir since the recipe should be able to
        # expect it exists
        os.mkdir(self.bin_dir)

        self.recipe = Recipe({
                'buildout': {
                    'eggs-directory': self.eggs_dir,
                    'develop-eggs-directory': self.develop_eggs_dir,
                    'python': 'python-version',
                    'bin-directory': self.bin_dir,
                    'parts-directory': self.parts_dir,
                    'directory': self.buildout_dir,
                    'find-links': '',
                    'allow-hosts': '',
                    },
                'python-version': {'executable': sys.executable}},
                             'django',
                             {'recipe': 'djangorecipe'})

    def tearDown(self):
        # Remove our test dir
        shutil.rmtree(self.buildout_dir)

    def test_consistent_options(self):
        # Buildout is pretty clever in detecting changing options. If
        # the recipe modifies it's options during initialisation it
        # will store this to determine wheter it needs to update or do
        # a uninstall & install. We need to make sure that we normally
        # do not trigger this. That means running the recipe with the
        # same options should give us the same results.
        self.assertEqual(*[
                Recipe({'buildout': {
                            'eggs-directory': self.eggs_dir,
                            'develop-eggs-directory': self.develop_eggs_dir,
                            'python': 'python-version',
                            'bin-directory': self.bin_dir,
                            'parts-directory': self.parts_dir,
                            'directory': self.buildout_dir,
                            'find-links': '',
                            'allow-hosts':'',
                            },
                        'python-version': {'executable': sys.executable}},
                       'django',
                       {'recipe': 'djangorecipe'}).options.copy()
                for i in range(2)])

    def test_create_file(self):
        # The create file helper should create a file at a certain
        # location unless it already exists. We will need a
        # non-existing file first.
        f, name = tempfile.mkstemp()
        # To show the function in action we need to delete the file
        # before testing.
        os.remove(name)
        # The method accepts a template argument which it will use
        # with the options argument for string substitution.
        self.recipe.create_file(name, 'Spam %s', 'eggs')
        # Let's check the contents of the file
        self.assertEqual(open(name).read(), 'Spam eggs')
        # If we try to write it again it will just ignore our request
        self.recipe.create_file(name, 'Spam spam spam %s', 'eggs')
        # The content of the file should therefore be the same
        self.assertEqual(open(name).read(), 'Spam eggs')
        # Now remove our temp file
        os.remove(name)

    def test_generate_secret(self):
        # To create a basic skeleton the recipe also generates a
        # random secret for the settings file. Since it should very
        # unlikely that it will generate the same key a few times in a
        # row we will test it with letting it generate a few keys.
        self.assert_(len(set(
                    [self.recipe.generate_secret() for i in range(10)])) > 1)

    def test_make_protocol_scripts(self):
        # To ease deployment a WSGI script can be generated. The
        # script adds any paths from the `extra_paths` option to the
        # Python path.
        self.recipe.options['wsgi'] = 'true'
        self.recipe.options['fcgi'] = 'true'
        self.recipe.make_scripts([], [])
        # This should have created a script in the bin dir
        wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
        self.assert_(os.path.exists(wsgi_script))
        # The contents should list our paths
        contents = open(wsgi_script).read()
        # It should also have a reference to our settings module
        self.assert_('project.development' in contents)
#.........这里部分代码省略.........
开发者ID:Abouplah,项目名称:nefpy,代码行数:103,代码来源:tests.py

示例5: TestRecipe

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import make_scripts [as 别名]

#.........这里部分代码省略.........
        # random secret for the settings file. Since it should very
        # unlikely that it will generate the same key a few times in a
        # row we will test it with letting it generate a few keys.
        self.assert_(len(set(
                    [self.recipe.generate_secret() for i in xrange(10)])) > 1)

    def test_version_to_svn(self):
        # Version specification that lead to a svn repository can be
        # specified in different ways. Just specifying `trunk` should
        # be enough to get the full url to the Django trunk.
        self.assertEqual(self.recipe.version_to_svn('trunk'),
                         'http://code.djangoproject.com/svn/django/trunk/')
        # Any other specification should lead to the url it is given
        self.assertEqual(self.recipe.version_to_svn('svn://somehost/trunk'),
                         'svn://somehost/trunk')

    def test_version_to_download_suffic(self):
        # To create standard names for the download directory a method
        # is provided which converts a version to a dir suffix. A
        # simple pointer to trunk should return svn.
        self.assertEqual(self.recipe.version_to_download_suffix('trunk'), 
                         'svn')
        # Any other url should return the last path component. This
        # works out nicely for branches or version pinned url's.
        self.assertEqual(self.recipe.version_to_download_suffix(
                'http://monty/branches/python'), 'python')

    def test_make_protocol_scripts(self):
        # To ease deployment a WSGI script can be generated. The
        # script adds any paths from the `extra_paths` option to the
        # Python path.
        self.recipe.options['wsgi'] = 'true'
        self.recipe.options['fcgi'] = 'true'
        self.recipe.make_scripts([], [])
        # This should have created a script in the bin dir
        wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
        self.assert_(os.path.exists(wsgi_script))
        # The contents should list our paths
        contents = open(wsgi_script).read()
        # It should also have a reference to our settings module
        self.assert_('project.development' in contents)
        # and a line which set's up the WSGI app
        self.assert_("application = "
                     "djangorecipe.wsgi.main('project.development', logfile='')"
                     in contents)
        self.assert_("class logger(object)" not in contents)

        # Another deployment options is FCGI. The recipe supports an option to
        # automatically create the required script.
        fcgi_script = os.path.join(self.bin_dir, 'django.fcgi')
        self.assert_(os.path.exists(fcgi_script))
        # The contents should list our paths
        contents = open(fcgi_script).read()
        # It should also have a reference to our settings module
        self.assert_('project.development' in contents)
        # and a line which set's up the WSGI app
        self.assert_("djangorecipe.fcgi.main('project.development', logfile='')"
                     in contents)
        self.assert_("class logger(object)" not in contents)

        self.recipe.options['logfile'] = '/foo'
        self.recipe.make_scripts([], [])
        wsgi_script = os.path.join(self.bin_dir, 'django.wsgi')
        contents = open(wsgi_script).read()
        self.assert_("logfile='/foo'" in contents)
开发者ID:attilaolah,项目名称:djangorecipe,代码行数:69,代码来源:tests.py


注:本文中的djangorecipe.recipe.Recipe.make_scripts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。