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


Python Task.install_packages方法代码示例

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


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

示例1: install

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import install_packages [as 别名]
    def install(self):
        print "Installing " + self.name + "..."

        Task.install_packages(self)

        """ Open template and substitute variables """
        f = open(self.nginx_template_url, "r")
        template = f.read()

        template = re.sub("{{domain_name}}", self.domain_name, template)
        template = re.sub("{{base_dir}}", self.base_dir, template)

        f = open(self.base_dir + "/" + self.domain_name + "/conf/nginx.conf", "w")
        f.write(template)
        f.close()

        """ Link files to nginx """
        result = call(
            "ln -s "
            + self.base_dir
            + "/"
            + self.domain_name
            + "/conf/nginx.conf /etc/nginx/sites-available/"
            + self.domain_name,
            shell=True,
        )
        result = call(
            "ln -s /etc/nginx/sites-available/" + self.domain_name + "  /etc/nginx/sites-enabled/" + self.domain_name,
            shell=True,
        )

        """ Restart Nginx """
        result = call("/etc/init.d/nginx restart", shell=True)

        return True
开发者ID:xavicolomer,项目名称:Automata,代码行数:37,代码来源:nginx.py

示例2: install

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import install_packages [as 别名]
    def install(self):
        print 'Installing ' + self.name + '...'
        
        #modules = map(__import__, moduleNames)
        django_installed = False
        try:
            modules = map(__import__, ['django'])
            django_installed = True
        except Exception:
            django_installed = False
        
        temp_folder = '/home/installers/'
 
        if ( not django_installed ):
            Task.install_packages(self)     
   
            self.dir_already_created = True
            if not os.path.exists(temp_folder):
                self.dir_already_created = False
                os.makedirs(temp_folder)
        
            self.django_file_name = url_file(self.django_url) 
         
            """ Download and install Django from given URL """
            run("curl " + self.django_url + " >> " +temp_folder + self.django_file_name)
            run("tar zxvf " + temp_folder + self.django_file_name  + " -C " + temp_folder)
            run("python " + temp_folder + self.django_file_name[:-7] + '/setup.py install')
         
            """ Copy styles """
            run("sudo cp -Rf " + temp_folder +self.django_file_name[:-7]+"/django/contrib/admin/media {{base_dir}}/{{domain_name}}/static/admin")
        
            """ Clean Django Installers """
            run("rm -R " + temp_folder + self.django_file_name[:-7] + "*")
        
        """ Install extras """
        extra1_url = "http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg"
        run("curl " + extra1_url + " >> " + temp_folder + url_file(extra1_url))
        run("sh " + temp_folder  + url_file(extra1_url) )

        extra2_url = "http://www.saddi.com/software/flup/dist/flup-1.0.2-py2.6.egg"
        run("curl " + extra2_url + " >> " + temp_folder + url_file(extra2_url))
        run("easy_install " + temp_folder  + url_file(extra2_url))
        
        """ Clean extras """
        run("rm -R " + temp_folder + url_file(extra1_url) + "*")
        run("rm -R " + temp_folder + url_file(extra2_url) + "*")
 
        return True
开发者ID:xavicolomer,项目名称:Automata,代码行数:50,代码来源:django.py

示例3: install

# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import install_packages [as 别名]
    def install(self):
        print 'Installing ' + self.name + '...'
        
        """ We save the password in the system for a non attended installation  """
        
        run("echo mysql-server mysql-server/root_password select {{mysql_password}} | debconf-set-selections")
        run("echo mysql-server mysql-server/root_password_again select {{mysql_password}} | debconf-set-selections")
        
        Task.install_packages(self)
 
        """ Create user and tables specified on the config file  """
        result = self.executeQuery("CREATE DATABASE " + self.mysql_database_name + ";")
        result = self.executeQuery("CREATE USER '" + self.mysql_username + "'@'localhost' IDENTIFIED BY '" + self.mysql_password + "';")         
        result = self.executeQuery("GRANT ALL PRIVILEGES ON " + self.mysql_database_name + " . * TO '" + self.mysql_username + "'@'localhost';")
        result = self.executeQuery("FLUSH PRIVILEGES;")

        return True
开发者ID:xavicolomer,项目名称:Automata,代码行数:19,代码来源:mysql.py


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