Esempio n. 1
0
 def rsync(self):
     deploy_dir = os.path.join(self.config.base_dir, 'deploy')
     site = Site(path=utils.locate_base_dir(), output=deploy_dir)
     site.generate()
     os.chdir(os.path.join(self.config.base_dir, 'deploy'))
     os.system("rsync -avz {0}\/* {1}:{2}".format(self.config.publish_dir,
                                               self.config.ip,
                                               self.config.remote_dir))
Esempio n. 2
0
 def git_deploy(self):
     git_remote = self.config.git_repository
     deploy_dir = os.path.join(self.config.base_dir, '.deploy')
     if not os.path.exists(deploy_dir):
         os.mkdir(deploy_dir)
         os.system("git clone {0} {1}".format(git_remote, deploy_dir))
     os.chdir(os.path.join(self.config.base_dir, '.deploy'))
     os.system("git pull")
     site = Site(path=utils.locate_base_dir(), full=True, output=deploy_dir)
     site.generate()
     os.system("git add --all *")
     os.system("git commit -m {0}".format("\"Crotal commit.\""))
     os.system("git push origin master")
Esempio n. 3
0
def start(port, path=os.getcwd()):
    if not path:
        sys.exit()
    site = Site(path)
    site.generate()
    config = Config(path)
    serverThread = ServerThread(config, port)
    serverThread.daemon = True
    serverThread.start()
    observer = Observer()
    for loader in site.loaders:
        for path in loader.path:
            observer.schedule(ChangeHandler(config, site, ignore_patterns=["*/.DS_Store"]),
                              path=os.path.join(config.base_dir, path), recursive=True)
    observer.start()
    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            logger.info('Server shutting down.')
            sys.exit()
Esempio n. 4
0
 def generate(full=False, output=None):
     start = time.time()
     site = Site(utils.locate_base_dir(), full=full, output=output)
     site.generate()
     end = time.time()
     logger.info("Site generated in {0:.2f} seconds.".format(end-start))