• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nginx.loadf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nginx.loadf函数的典型用法代码示例。如果您正苦于以下问题:Python loadf函数的具体用法?Python loadf怎么用?Python loadf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: post_install

    def post_install(self, name, path, vars, dbinfo={}):
        # Write a basic index file showing that we are here
        if vars.getvalue('php', '0') == '1':
            php = True
            path = os.path.join(path, 'htdocs')
            os.mkdir(path)
            c = nginx.loadf(os.path.join('/etc/nginx/sites-available', name))
            for x in c.servers:
                if x.filter('Key', 'root'):
                    x.filter('Key', 'root')[0].value = path
            nginx.dumpf(c, os.path.join('/etc/nginx/sites-available', name))
        else:
            php = False
            
        if php:
            phpctl = apis.langassist(self.app).get_interface('PHP')
            phpctl.enable_mod('xcache')
        if php and dbinfo and dbinfo['engine'] == 'MariaDB':
            phpctl.enable_mod('mysql')

        f = open(os.path.join(path, 'index.'+('php' if php is True else 'html')), 'w')
        f.write(
            '<html>\n'
            '<body>\n'
            '<h1>Genesis - Custom Site</h1>\n'
            '<p>Your site is online and available at '+path+'</p>\n'
            '<p>Feel free to paste your site files here</p>\n'
            '</body>\n'
            '</html>\n'
            )
        f.close()

        # Give access to httpd
        shell('chown -R http:http '+path)
开发者ID:Bugsbane,项目名称:genesis,代码行数:34,代码来源:main.py


示例2: ssl_disable

	def ssl_disable(self, data):
		name, stype = data.name, data.stype
		port = '80'
		s = None
		c = nginx.loadf('/etc/nginx/sites-available/'+name)
		if len(c.servers) > 1:
			for x in c.servers:
				if not 'ssl' in x.filter('Key', 'listen')[0].value \
				and x.filter('key', 'return'):
					c.remove(x)
					break
		s = c.servers[0]
		l = s.filter('Key', 'listen')[0]
		if l.value == '443 ssl':
			l.value = '80'
			port = '80'
		else:
			l.value = l.value.rstrip(' ssl')
			port = l.value
		s.remove(*[x for x in s.filter('Key') if x.name.startswith('ssl_')])
		g = ConfigParser.SafeConfigParser()
		g.read(os.path.join('/etc/nginx/sites-available', '.'+name+'.ginf'))
		g.set('website', 'ssl', '')
		g.write(open(os.path.join('/etc/nginx/sites-available', '.'+name+'.ginf'), 'w'))
		nginx.dumpf(c, '/etc/nginx/sites-available/'+name)
		apis.webapps(self.app).get_interface(stype).ssl_disable(
			os.path.join('/srv/http/webapps', name))
开发者ID:X4fyr,项目名称:genesis,代码行数:27,代码来源:backend.py


示例3: nginx_edit

	def nginx_edit(self, oldsite, site):
		# Update the nginx serverblock
		c = nginx.loadf(os.path.join('/etc/nginx/sites-available', oldsite.name))
		s = c.servers[0]
		if oldsite.ssl and oldsite.port == '443':
			for x in c.servers:
				if x.filter('Key', 'listen')[0].value == '443 ssl':
					s = x
			if site.port != '443':
				for x in c.servers:
					if not 'ssl' in x.filter('Key', 'listen')[0].value \
					and x.filter('key', 'return'):
						c.remove(x)
		elif site.port == '443':
			c.add(nginx.Server(
				nginx.Key('listen', '80'),
				nginx.Key('server_name', site.addr),
				nginx.Key('return', '301 https://%s$request_uri'%site.addr)
			))
		s.filter('Key', 'listen')[0].value = site.port+' ssl' if site.ssl else site.port
		s.filter('Key', 'server_name')[0].value = site.addr
		s.filter('Key', 'root')[0].value = site.path
		s.filter('Key', 'index')[0].value = 'index.php' if site.php else 'index.html'
		nginx.dumpf(c, os.path.join('/etc/nginx/sites-available', oldsite.name))
		# If the name was changed, rename the folder and files
		if site.name != oldsite.name:
			if os.path.exists(os.path.join('/srv/http/webapps', site.name)):
				shutil.rmtree(os.path.join('/srv/http/webapps', site.name))
			shutil.move(os.path.join('/srv/http/webapps', oldsite.name), 
				os.path.join('/srv/http/webapps', site.name))
			shutil.move(os.path.join('/etc/nginx/sites-available', oldsite.name),
				os.path.join('/etc/nginx/sites-available', site.name))
			self.nginx_disable(oldsite, reload=False)
			self.nginx_enable(site)
		self.nginx_reload()
开发者ID:X4fyr,项目名称:genesis,代码行数:35,代码来源:backend.py


示例4: edit

    def edit(self, newname=""):
        site_dir = config.get("websites", "site_dir")
        block = nginx.loadf(os.path.join("/etc/nginx/sites-available", self.id))

        # If SSL is enabled and the port is changing to 443, create the port 80 redirect
        server = block.servers[0]
        if self.cert and self.port == 443:
            for x in block.servers:
                if x.filter("Key", "listen")[0].value == "443 ssl":
                    server = x
            if self.port != 443:
                for x in block.servers:
                    if not "ssl" in x.filter("Key", "listen")[0].value \
                    and x.filter("key", "return"):
                        block.remove(x)
        elif self.port == 443:
            block.add(nginx.Server(
                nginx.Key("listen", "80"),
                nginx.Key("server_name", self.addr),
                nginx.Key("return", "301 https://%s$request_uri"%self.addr)
            ))

        # If the name was changed...
        if newname and self.id != newname:
            # rename the folder and files...
            if self.path.endswith("_site"):
                self.path = os.path.join(site_dir, newname, "_site")
            elif self.path.endswith("htdocs"):
                self.path = os.path.join(site_dir, newname, "htdocs")
            else:
                self.path = os.path.join(site_dir, newname)
            self.path = self.path.encode("utf-8")
            if os.path.exists(self.path):
                shutil.rmtree(self.path)
            self.nginx_disable(reload=False)
            shutil.move(os.path.join(site_dir, self.id), self.path)
            os.unlink(os.path.join("/etc/nginx/sites-available", self.id))
            signals.emit("websites", "site_removed", self)
            self.id = newname

            # then update the site's arkOS metadata file with the new name
            meta = ConfigParser.SafeConfigParser()
            meta.read(os.path.join(self.path, ".arkos"))
            meta.set("website", "id", self.id)
            with open(os.path.join(self.path, ".arkos"), "w") as f:
                meta.write(f)
            self.nginx_enable(reload=False)

        # Pass any necessary updates to the nginx serverblock and save
        server.filter("Key", "listen")[0].value = str(self.port)+" ssl" if self.cert else str(self.port)
        server.filter("Key", "server_name")[0].value = self.addr
        server.filter("Key", "root")[0].value = self.path
        server.filter("Key", "index")[0].value = "index.php" if hasattr(self, "php") and self.php else "index.html"
        nginx.dumpf(block, os.path.join("/etc/nginx/sites-available", self.id))

        # Call the site's edited hook, if it has one, then reload nginx
        signals.emit("websites", "site_loaded", self)
        if hasattr(self, "site_edited"):
            self.site_edited()
        nginx_reload()
开发者ID:jeffshaw-dev,项目名称:arkos,代码行数:60,代码来源:websites.py


示例5: ssl_disable

    def ssl_disable(self):
        block = nginx.loadf(os.path.join("/etc/nginx/sites-available/", self.id))

        # If there's an 80-to-443 redirect block, get rid of it
        if len(block.servers) > 1:
            for x in block.servers:
                if not "ssl" in x.filter("Key", "listen")[0].value \
                and x.filter("key", "return"):
                    block.remove(x)
                    break

        # Remove all SSL directives and save
        server = block.servers[0]
        listen = server.filter("Key", "listen")[0]
        if listen.value == "443 ssl":
            listen.value = "80"
        else:
            listen.value = listen.value.rstrip(" ssl")
        server.remove(*[x for x in server.filter("Key") if x.name.startswith("ssl_")])
        nginx.dumpf(block, os.path.join("/etc/nginx/sites-available/", self.id))
        meta = ConfigParser.SafeConfigParser()
        meta.read(os.path.join(self.path, ".arkos"))
        meta.set("website", "ssl", "None")
        with open(os.path.join(self.path, ".arkos"), "w") as f:
            meta.write(f)

        # Call the website type's SSL disable hook
        self.disable_ssl()
开发者ID:jeffshaw-dev,项目名称:arkos,代码行数:28,代码来源:websites.py


示例6: ssl_disable

	def ssl_disable(self, data):
		name, stype = data.name, data.stype
		port = '80'
		s = None
		c = nginx.loadf('/etc/nginx/sites-available/'+name)
		if len(c.servers) > 1:
			for x in c.servers:
				if not 'ssl' in x.filter('Key', 'listen')[0].value \
				and x.filter('key', 'return'):
					c.remove(x)
					break
		s = c.servers[0]
		l = s.filter('Key', 'listen')[0]
		if l.value == '443 ssl':
			l.value = '80'
			port = '80'
		else:
			l.value = l.value.rstrip(' ssl')
			port = l.value
		s.remove(*[x for x in s.filter('Key') if x.name.startswith('ssl_')])
		c.filter('Comment')[0].comment = 'GENESIS %s http://%s:%s' \
			% (stype, data.addr, port)
		nginx.dumpf(c, '/etc/nginx/sites-available/'+name)
		apis.webapps(self.app).get_interface(stype).ssl_disable(
			os.path.join('/srv/http/webapps', name))
开发者ID:elimisteve,项目名称:genesis,代码行数:25,代码来源:backend.py


示例7: ssl_disable

 def ssl_disable(self):
     n = nginx.loadf('/etc/nginx/sites-available/%s' % self.name)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s' % self.name)
开发者ID:alon7786,项目名称:arkos-applications,代码行数:7,代码来源:website.py


示例8: ssl_enable

	def ssl_enable(self, data, cpath, kpath):
		name, stype = data.name, data.stype
		port = '443'
		c = nginx.loadf('/etc/nginx/sites-available/'+name)
		l = c.servers[0].filter('Key', 'listen')[0]
		if l.value == '80':
			l.value = '443 ssl'
			port = '443'
		else:
			port = l.value.split(' ssl')[0]
			l.value = l.value.split(' ssl')[0] + ' ssl'
		if c.servers[0].filter('Key', 'ssl_certificate'):
			c.servers[0].remove(c.servers[0].filter('Key', 'ssl_certificate'))
		if c.servers[0].filter('Key', 'ssl_certificate_key'):
			c.servers[0].remove(c.servers[0].filter('Key', 'ssl_certificate_key'))
		if c.servers[0].filter('Key', 'ssl_protocols'):
			c.servers[0].remove(c.servers[0].filter('Key', 'ssl_protocols'))
		if c.servers[0].filter('Key', 'ssl_ciphers'):
			c.servers[0].remove(c.servers[0].filter('Key', 'ssl_ciphers'))
		c.servers[0].add(
			nginx.Key('ssl_certificate', cpath),
			nginx.Key('ssl_certificate_key', kpath),
			nginx.Key('ssl_protocols', 'SSLv3 TLSv1 TLSv1.1 TLSv1.2'),
			nginx.Key('ssl_ciphers', 'HIGH:!aNULL:!MD5')
			)
		c.filter('Comment')[0].comment = 'GENESIS %s https://%s:%s' \
			% (stype, data.addr, port)
		nginx.dumpf(c, '/etc/nginx/sites-available/'+name)
		apis.webapps(self.app).get_interface(stype).ssl_enable(
			os.path.join('/srv/http/webapps', name), cpath, kpath)
		self.nginx_reload()
开发者ID:gzsombor,项目名称:genesis,代码行数:31,代码来源:backend.py


示例9: ssl_disable

 def ssl_disable(self, path):
     name = os.path.basename(path)
     n = nginx.loadf('/etc/nginx/sites-available/%s'%name)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%name)
     s = self.app.get_backend(apis.services.IServiceManager)
开发者ID:keybits,项目名称:genesis,代码行数:9,代码来源:main.py


示例10: post_install

	def post_install(self, name, path, vars):
		# Make sure the webapps config points to the _site directory and generate it.
		c = nginx.loadf(os.path.join('/etc/nginx/sites-available', name))
		c.servers[0].filter('Key', 'root')[0].value = os.path.join(path, '_site')
		nginx.dumpf(c, os.path.join('/etc/nginx/sites-available', name))
		shell('jekyll build --source '+path+' --destination '+os.path.join(path, '_site'))

		# Return an explicatory message.
		return 'Jekyll has been setup, with a sample site at '+path+'. Modify these files as you like. To learn how to use Jekyll, visit http://jekyllrb.com/docs/usage. After making changes, click the Configure button next to the site, then "Regenerate Site" to bring your changes live.'
开发者ID:CoinCoder-,项目名称:genesis,代码行数:9,代码来源:main.py


示例11: enable_ssl

 def enable_ssl(self, cfile, kfile):
     n = nginx.loadf('/etc/nginx/sites-available/%s'%self.id)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             self.addtoblock[0].add(
                 nginx.Key('proxy_set_header', 'X-Forwarded-For $proxy_add_x_forwarded_for'),
                 nginx.Key('proxy_set_header', 'X-Forwarded-Proto $scheme'),
             )
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%self.id)
开发者ID:alon7786,项目名称:arkos-applications,代码行数:11,代码来源:website.py


示例12: ssl_enable

    def ssl_enable(self):
        # Get server-preferred ciphers
        if config.get("certificates", "ciphers"):
            ciphers = config.get("certificates", "ciphers")
        else:
            config.set("certificates", "ciphers", ciphers)
            config.save()

        block = nginx.loadf(os.path.join("/etc/nginx/sites-available/", self.id))

        # If the site is on port 80, setup an HTTP redirect to new port 443
        server = block.servers[0]
        listen = server.filter("Key", "listen")[0]
        if listen.value == "80":
            listen.value = "443 ssl"
            block.add(nginx.Server(
                nginx.Key("listen", "80"),
                nginx.Key("server_name", self.addr),
                nginx.Key("return", "301 https://%s$request_uri" % self.addr)
            ))
            for x in block.servers:
                if x.filter("Key", "listen")[0].value == "443 ssl":
                    server = x
                    break
        else:
            listen.value = listen.value.split(" ssl")[0] + " ssl"

        # Clean up any pre-existing SSL directives that no longer apply
        for x in server.all():
            if type(x) == nginx.Key and x.name.startswith("ssl_"):
                server.remove(x)

        # Add the necessary SSL directives to the serverblock and save
        server.add(
            nginx.Key("ssl_certificate", self.cert.cert_path),
            nginx.Key("ssl_certificate_key", self.cert.key_path),
            nginx.Key("ssl_protocols", "TLSv1 TLSv1.1 TLSv1.2"),
            nginx.Key("ssl_ciphers", ciphers),
            nginx.Key("ssl_session_timeout", "5m"),
            nginx.Key("ssl_prefer_server_ciphers", "on"),
            nginx.Key("ssl_dhparam", "/etc/arkos/ssl/dh_params.pem"),
            nginx.Key("ssl_session_cache", "shared:SSL:50m"),
            )
        nginx.dumpf(block, os.path.join("/etc/nginx/sites-available/", self.id))

        # Set the certificate name in the metadata file
        meta = ConfigParser.SafeConfigParser()
        meta.read(os.path.join(self.path, ".arkos"))
        meta.set("website", "ssl", self.cert.id)
        with open(os.path.join(self.path, ".arkos"), "w") as f:
            meta.write(f)

        # Call the website type's SSL enable hook
        self.enable_ssl(self.cert.cert_path, self.cert.key_path)
开发者ID:jeffshaw-dev,项目名称:arkos,代码行数:54,代码来源:websites.py


示例13: get_sites

    def get_sites(self):
        applist = []
        if not os.path.exists('/etc/nginx/sites-available'):
            os.makedirs('/etc/nginx/sites-available')
        if not os.path.exists('/etc/nginx/sites-enabled'):
            os.makedirs('/etc/nginx/sites-enabled')

        for site in glob.glob('/etc/nginx/sites-available/.*.ginf'):
            g = ConfigParser.SafeConfigParser()
            g.read(site)
            path = os.path.join('/etc/nginx/sites-available', g.get('website', 'name'))
            if not os.path.exists(path):
                continue
            w = Webapp()
            # Set default values and regexs to use
            w.name = g.get('website', 'name')
            w.addr = False
            w.port = '80'
            w.stype = 'Unknown'
            w.path = path
            rport = re.compile('(\\d+)\s*(.*)')

            # Get actual values
            try:
                s = None
                c = nginx.loadf(w.path)
                stype = g.get('website', 'stype')
                w.stype = stype if stype in [x.plugin_info.wa_plugin for x in self.get_apptypes()] else 'Unknown'
                # Get the right serverblock - SSL if it's here
                for x in c.servers:
                    if 'ssl' in x.filter('Key', 'listen')[0].value:
                        s = x
                        break
                if not s:
                    s = c.servers[0]
                w.port, w.ssl = re.match(rport, s.filter('Key', 'listen')[0].value).group(1, 2)
                w.addr = s.filter('Key', 'server_name')[0].value
                w.path = s.filter('Key', 'root')[0].value
                w.php = True if 'php' in s.filter('Key', 'index')[0].value else False
            except IndexError:
                pass
            w.version = g.get('website', 'version', None)
            w.dbengine = g.get('website', 'dbengine', None)
            w.dbname = g.get('website', 'dbname', None)
            w.dbuser = g.get('website', 'dbuser', None)

            w.enabled = True if os.path.exists(os.path.join('/etc/nginx/sites-enabled', g.get('website', 'name'))) else False

            w.sclass = self.get_interface(w.stype)
            w.sinfo = self.get_info(w.stype)
            w.ssl_able = w.sinfo.ssl if hasattr(w.sinfo, 'ssl') else False

            applist.append(w)
        return applist
开发者ID:heinzK1X,项目名称:genesis,代码行数:54,代码来源:api.py


示例14: post_install

    def post_install(self, name, path, vars):
        # Write a basic index file showing that we are here
        if vars.getvalue('php', '0') == '1':
            php = True
            path = os.path.join(path, 'htdocs')
            os.mkdir(path)
            c = nginx.loadf(os.path.join('/etc/nginx/sites-available', name))
            for x in c.servers:
                if x.filter('Key', 'root'):
                    x.filter('Key', 'root')[0].value = path
            nginx.dumpf(c, os.path.join('/etc/nginx/sites-available', name))
        else:
            php = False
            
        # Create a database if the user wants one
        if php:
            phpctl = apis.langassist(self.app).get_interface('PHP')
        if vars.getvalue('ws-dbsel', 'None') != 'None':
            dbtype = vars.getvalue('ws-dbsel', '')
            dbname = vars.getvalue('ws-dbname', '')
            passwd = vars.getvalue('ws-dbpass', '')
            dbase = apis.databases(self.app).get_interface(dbtype)
            if hasattr(dbase, 'connect'):
                conn = apis.databases(self.app).get_dbconn(dbtype)
                dbase.add(dbname, conn)
                dbase.usermod(dbname, 'add', passwd, conn)
                dbase.chperm(dbname, dbname, 'grant', conn)
            else:
                dbase.add(dbname)
                dbase.usermod(dbname, 'add', passwd)
                dbase.chperm(dbname, dbname, 'grant')
            if php:
                phpctl.enable_mod('mysql')

        f = open(os.path.join(path, 'index.'+('php' if php is True else 'html')), 'w')
        f.write(
            '<html>\n'
            '<body>\n'
            '<h1>Genesis - Custom Site</h1>\n'
            '<p>Your site is online and available at '+path+'</p>\n'
            '<p>Feel free to paste your site files here</p>\n'
            '</body>\n'
            '</html>\n'
            )
        f.close()

        # Give access to httpd
        shell('chown -R http:http '+path)

        # Enable xcache if PHP is set
        if php:
            phpctl.enable_mod('xcache')
开发者ID:IsSuEat,项目名称:genesis,代码行数:52,代码来源:main.py


示例15: ssl_enable

 def ssl_enable(self, path, cfile, kfile):
     name = os.path.basename(path)
     n = nginx.loadf('/etc/nginx/sites-available/%s'%name)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             self.addtoblock[0].add(
                 nginx.Key('proxy_set_header', 'X-Forwarded-For $proxy_add_x_forwarded_for'),
                 nginx.Key('proxy_set_header', 'X-Forwarded-Proto $scheme'),
             )
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%name)
     s = self.app.get_backend(apis.services.IServiceManager)
开发者ID:keybits,项目名称:genesis,代码行数:13,代码来源:main.py


示例16: post_install

    def post_install(self, vars, dbpasswd=""):
        # Get around top-level zip restriction (FIXME 0.7.2)
        if "paperwork-master" in os.listdir(self.path):
            tmp_path = os.path.abspath(os.path.join(self.path, "../pwrk-tmp"))
            os.rename(os.path.join(self.path, "paperwork-master/frontend"), tmp_path)
            os.rename(os.path.join(self.path, ".arkos"),
                      os.path.join(tmp_path, ".arkos"))
            shutil.rmtree(self.path)
            os.rename(tmp_path, self.path)

        # Make sure that the correct PHP settings are enabled
        php.enable_mod('gd', 'opcache', 'mysql', 'pdo_mysql', 'mcrypt')
        php.enable_mod('apcu', config_file="/etc/php/conf.d/apcu.ini")

        dbstr = "mysql, localhost, 3389, {0}, {1}, {0}".format(self.id, dbpasswd)
        with open(os.path.join(self.path, 'app/storage/db_settings'), 'w') as f:
            f.write(dbstr)

        php.composer_install(self.path)
        nodejs.install("gulp", as_global=True)
        nodejs.install_from_package(self.path, stat=None)

        cwd = os.getcwd()
        os.chdir(self.path)
        s = shell("bower install --allow-root", stdin='y\n')
        if s["code"] != 0:
            raise Exception("Failed to run bower: %s" % s["stderr"])
        s = shell("gulp")
        if s["code"] != 0:
            raise Exception("Failed to run gulp: %s" % s["stderr"])
        s = shell("php artisan migrate --force")
        if s["code"] != 0:
            raise Exception("Failed to run artisan: %s" % s["stderr"])
        os.chdir(cwd)

        # Make sure the webapps config points to the public directory.
        c = nginx.loadf(os.path.join('/etc/nginx/sites-available', self.id))
        for x in c.servers:
            if x.filter('Key', 'root'):
                x.filter('Key', 'root')[0].value = os.path.join(self.path, 'public')
        nginx.dumpf(c, os.path.join('/etc/nginx/sites-available', self.id))
        uid, gid = users.get_system("http").uid, groups.get_system("http").gid
        for r, d, f in os.walk(os.path.join(self.path, 'app')):
            for x in d:
                os.chmod(os.path.join(r, x), 0755)
                os.chown(os.path.join(r, x), uid, gid)
            for x in f:
                os.chmod(os.path.join(r, x), 0644)
                os.chown(os.path.join(r, x), uid, gid)
        if os.path.exists(os.path.join(self.path, 'app/storage/setup')):
            os.unlink(os.path.join(self.path, 'app/storage/setup'))
开发者ID:alon7786,项目名称:arkos-applications,代码行数:51,代码来源:website.py


示例17: disable_ssl

 def disable_ssl(self):
     n = nginx.loadf('/etc/nginx/sites-available/%s'%self.id)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%self.id)
     with open(os.path.join(self.path, 'config.js'), 'r') as f:
         data = f.read()
     data = data.replace('production: {\n        url: \'https://', 
         'production: {\n        url: \'http://')
     with open(os.path.join(self.path, 'config.js'), 'w') as f:
         f.write(data)
     services.get(self.id).restart()
开发者ID:josejamilena,项目名称:arkos-applications,代码行数:14,代码来源:website.py


示例18: ssl_disable

 def ssl_disable(self, path):
     name = os.path.basename(path)
     n = nginx.loadf('/etc/nginx/sites-available/%s'%name)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%name)
     f = open(os.path.join(path, 'config.js'), 'r').read()
     with open(os.path.join(path, 'config.js'), 'w') as config_file:
         f = f.replace('production: {\n        url: \'https://', 
             'production: {\n        url: \'http://')
         config_file.write(f)
         config_file.close()
     s = self.app.get_backend(apis.services.IServiceManager)
     s.restart('ghost', 'supervisor')
开发者ID:Bugsbane,项目名称:genesis,代码行数:16,代码来源:main.py


示例19: get_sites

    def get_sites(self):
        applist = []
        if not os.path.exists('/etc/nginx/sites-available'):
            os.makedirs('/etc/nginx/sites-available')
        if not os.path.exists('/etc/nginx/sites-enabled'):
            os.makedirs('/etc/nginx/sites-enabled')

        for site in os.listdir('/etc/nginx/sites-available'):
            w = Webapp()
            # Set default values and regexs to use
            w.name = site
            w.addr = False
            w.port = '80'
            w.stype = 'Unknown'
            w.path = os.path.join('/etc/nginx/sites-available', site)
            rtype = re.compile('GENESIS ((?:[a-z][a-z]+))', flags=re.IGNORECASE)
            rport = re.compile('(\\d+)\s*(.*)')

            # Get actual values
            try:
                s = None
                c = nginx.loadf(w.path)
                w.stype = re.match(rtype, c.filter('Comment')[0].comment).group(1)
                # Get the right serverblock - SSL if it's here
                for x in c.servers:
                    if 'ssl' in x.filter('Key', 'listen')[0].value:
                        s = x
                        break
                if not s:
                    s = c.servers[0]
                w.port, w.ssl = re.match(rport, s.filter('Key', 'listen')[0].value).group(1, 2)
                w.addr = s.filter('Key', 'server_name')[0].value
                w.path = s.filter('Key', 'root')[0].value
                w.php = True if 'php' in s.filter('Key', 'index')[0].value else False
            except IndexError:
                pass

            w.enabled = True if os.path.exists(os.path.join('/etc/nginx/sites-enabled', site)) else False

            w.sclass = self.get_interface(w.stype)
            w.sinfo = self.get_info(w.stype)
            w.dbengine = w.sinfo.dbengine if hasattr(w.sinfo, 'dbengine') else None
            w.ssl_able = w.sinfo.ssl if hasattr(w.sinfo, 'ssl') else False

            applist.append(w)
        return applist
开发者ID:IsSuEat,项目名称:genesis,代码行数:46,代码来源:api.py


示例20: ssl_disable

 def ssl_disable(self, path):
     name = os.path.basename(path)
     n = nginx.loadf('/etc/nginx/sites-available/%s'%name)
     for x in n.servers:
         if x.filter('Location', '/'):
             x.remove(x.filter('Location', '/')[0])
             x.add(self.addtoblock[0])
             nginx.dumpf(n, '/etc/nginx/sites-available/%s'%name)
     f = open(os.path.join(path, 'config.js'), 'r').read()
     with open(os.path.join(path, 'config.js'), 'w') as config_file:
         f = f.replace('production: {\n        url: \'https://', 
             'production: {\n        url: \'http://')
         config_file.write(f)
         config_file.close()
     s = apis.orders(self.app).get_interface('supervisor')
     if s:
         s[0].order('rel', 'ghost')
开发者ID:IsSuEat,项目名称:genesis,代码行数:17,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ngram.NGram类代码示例发布时间:2022-05-27
下一篇:
Python nginx.dumpf函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap