示例#1
0
文件: site.py 项目: DjangoBD/Cactus
    def serve(self, browser=True, port=8000):
        """
        Start a http server and rebuild on changes.
        """
        self._parallel = PARALLEL_DISABLED
        self._port = port

        self.clean()
        self.build()

        logger.info('Running webserver at http://127.0.0.1:%s for %s' % (port, self.build_path))
        ipc.signal("server.didstart")
        logger.info('Type control-c to exit')

        os.chdir(self.build_path)

        self.listener = Listener(self.path, self._rebuild, ignore=self._rebuild_should_ignore)
        self.listener.run()

        self.server = WebServer(self.build_path, port=port)

        try:
            self.server.start()

            # if browser is True:
            #     webbrowser.open('http://127.0.0.1:%s' % port)

        except (KeyboardInterrupt, SystemExit):
            self.server.stop()
            logger.info("Bye")
示例#2
0
文件: file.py 项目: CILP/Cactus
    def upload(self):

        self.prepare()

        # Plugins may actually update those values afterwards
        self.cache_control = self.MAX_CACHE_EXPIRATION if self.is_fingerprinted else self.DEFAULT_CACHE_EXPIRATION
        self.content_encoding = 'gzip' if self.is_compressed else None
        self.content_length = len(self.payload())

        self.engine.site.plugin_manager.preDeployFile(self)

        remote_changed = self.remote_changed()

        if remote_changed:
            self.do_upload()

        self.total_bytes_uploaded = self.total_bytes

        op1 = '+' if remote_changed else '-'
        op2 = ' (%s compressed)' % (fileSize(len(self.payload()))) if self.is_compressed else ''

        # logger.warning("deploy.progress %s", self.engine.progress())

        ipc.signal("deploy.progress", {
            "progress": self.engine.progress(),
            "fileName": self.path
        })

        logger.info('%s %s - %s%s' % (op1, self.path, fileSize(len(self.data())), op2))

        return {'changed': remote_changed, 'size': len(self.payload())}
示例#3
0
    def upload(self):

        self.prepare()

        # Plugins may actually update those values afterwards
        self.cache_control = self.MAX_CACHE_EXPIRATION if self.is_fingerprinted else self.DEFAULT_CACHE_EXPIRATION
        self.content_encoding = 'gzip' if self.is_compressed else None
        self.content_length = len(self.payload())

        self.engine.site.plugin_manager.preDeployFile(self)

        remote_changed = self.remote_changed()

        if remote_changed:
            self.do_upload()

        self.total_bytes_uploaded = self.total_bytes

        op1 = '+' if remote_changed else '-'
        op2 = ' (%s compressed)' % (fileSize(len(
            self.payload()))) if self.is_compressed else ''

        # logger.warning("deploy.progress %s", self.engine.progress())

        ipc.signal("deploy.progress", {
            "progress": self.engine.progress(),
            "fileName": self.path
        })

        logger.info('%s %s - %s%s' %
                    (op1, self.path, fileSize(len(self.data())), op2))

        return {'changed': remote_changed, 'size': len(self.payload())}
示例#4
0
文件: site.py 项目: zorosteven/Cactus
    def serve(self, browser=True, port=8000):
        """
        Start a http server and rebuild on changes.
        """
        self._parallel = PARALLEL_DISABLED
        self._port = port

        self.clean()
        self.build()

        logger.info('Running webserver at http://127.0.0.1:%s for %s' %
                    (port, self.build_path))
        ipc.signal("server.didstart")
        logger.info('Type control-c to exit')

        os.chdir(self.build_path)

        self.listener = Listener(self.path,
                                 self._rebuild,
                                 ignore=self._rebuild_should_ignore)
        self.listener.run()

        self.server = WebServer(self.build_path, port=port)

        try:
            self.server.start()

            # if browser is True:
            #     webbrowser.open('http://127.0.0.1:%s' % port)

        except (KeyboardInterrupt, SystemExit):
            self.server.stop()
            logger.info("Bye")
示例#5
0
    def domain_list(self):
        bucket_name = self.site.config.get(self.config_bucket_name)

        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials(
        )
        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain_list = domain.nameServers()
        except DNSServerError as e:
            print(e)
            ipc.signal("domain.list.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
            return

        if domain_list:
            ipc.signal("domain.list.result", {"nameservers": domain_list})
            for domain in domain_list:
                logger.info(domain)
        else:
            logger.error("No name servers configured")
示例#6
0
    def domain_list(self):
        bucket_name = self.site.config.get(self.config_bucket_name)

        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials()
        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain_list = domain.nameServers()
        except DNSServerError as e:
            print(e)
            ipc.signal("domain.list.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
            return

        if domain_list:
            ipc.signal("domain.list.result", {"nameservers": domain_list})
            for domain in domain_list:
                logger.info(domain)
        else:
            logger.error("No name servers configured")
示例#7
0
文件: file.py 项目: dreadatour/Cactus
        def progressCallback(current, total):

            if current == 0 or total == 0:
                return

            self.total_bytes_uploaded = current

            logger.info('+ %s upload progress %.1f%%', self.url, float(current) / float(total) * 100)

            # logger.warning("deploy.progress %s", self.engine.progress())

            ipc.signal("deploy.progress", {
                "progress": self.engine.progress(),
                "fileName": self.path
            })
示例#8
0
文件: engine.py 项目: ateszdn/Cactus
    def domain_setup(self):
        bucket_name = self.site.config.get(self.config_bucket_name)
        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials()
        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain.setup()
        except DNSServerError, e:
            logger.debug(e)
            ipc.signal("domain.setup.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
示例#9
0
        def progressCallback(current, total):

            if current == 0 or total == 0:
                return

            self.total_bytes_uploaded = current

            logger.info('+ %s upload progress %.1f%%', self.url,
                        float(current) / float(total) * 100)

            # logger.warning("deploy.progress %s", self.engine.progress())

            ipc.signal("deploy.progress", {
                "progress": self.engine.progress(),
                "fileName": self.path
            })
示例#10
0
    def domain_setup(self):
        bucket_name = self.site.config.get(self.config_bucket_name)
        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials(
        )
        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain.setup()
        except DNSServerError, e:
            logger.debug(e)
            ipc.signal("domain.setup.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
示例#11
0
文件: engine.py 项目: ateszdn/Cactus
    def domain_list(self):
        bucket_name = self.site.config.get(self.config_bucket_name)

        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials()
        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain_list = domain.nameServers()
        except DNSServerError, e:
            print e
            ipc.signal("domain.list.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
            return

        if domain_list:
            ipc.signal("domain.list.result", {"nameservers": domain_list})
            for domain in domain_list:
                logger.info(domain)
        else:
            logger.error("No name servers configured")


    def domain_remove(self):
        pass
示例#12
0
文件: engine.py 项目: xy2/Cactus
    def domain_list(self):
        bucket_name = self.site.config.get(self.config_bucket_name)

        if not bucket_name:
            logger.warning("No bucket name")
            return

        aws_access_key, aws_secret_key = self.credentials_manager.get_credentials(
        )

        domain = AWSDomain(aws_access_key, aws_secret_key, bucket_name)

        try:
            domain_list = domain.nameServers()
        except DNSServerError, e:
            print e
            ipc.signal("domain.list.error", {"errorKey": "AccountDisabled"})
            logger.error("Account cannot use route 53")
            logger.error(e)
            return

        if domain_list:
            ipc.signal("domain.list.result", {"nameservers": domain_list})
            for domain in domain_list:
                logger.info(domain)
        else:
            logger.error("No name servers configured")

    def domain_remove(self):
        pass