def package(self): if not self.app.release_root.exists: self.app.release_root.make() app = Folder(self.app.path) try: zip_path = app.zzip() except: self.fail("Cannot create the archive") vzip_name = self.eval('name') vzip_path = self.app.release_root.child(vzip_name) self.app.archive = File(vzip_path) self.app.archive.delete() File(zip_path).move_to(vzip_path)
def build_siteinfo(self, deploy_path=None): tmp_folder = Folder(settings.TMP_DIR) deploy_folder = Folder((deploy_path, settings.DEPLOY_DIR)[not deploy_path]) if deploy_folder.exists and settings.BACKUP: backup_folder = Folder(settings.BACKUPS_DIR).make() deploy_folder.backup(backup_folder) tmp_folder.delete() tmp_folder.make() settings.DEPLOY_DIR = deploy_folder.path if not deploy_folder.exists: deploy_folder.make() self.create_siteinfo()
def initialize(self, root, template=None, force=False): if not template: template = "default" root_folder = Folder(root) template_dir = root_folder.child_folder("templates", template) if not template_dir.exists: raise ValueError("Cannot find the specified template[%s]." % template_dir) if self.site_path.exists: files = os.listdir(self.site_path.path) PathUtil.filter_hidden_inplace(files) if len(files) and not force: raise ValueError("The site_path[%s] is not empty." % self.site_path) else: self.site_path.delete() self.site_path.make() self.site_path.copy_contents_of(template_dir)
def build_siteinfo(self, deploy_path=None): tmp_folder = Folder(settings.TMP_DIR) deploy_folder = Folder( (deploy_path, settings.DEPLOY_DIR) [not deploy_path]) if deploy_folder.exists and settings.BACKUP: backup_folder = Folder(settings.BACKUPS_DIR).make() deploy_folder.backup(backup_folder) tmp_folder.delete() tmp_folder.make() settings.DEPLOY_DIR = deploy_folder.path if not deploy_folder.exists: deploy_folder.make() add_to_builtins('hydeengine.templatetags.hydetags') add_to_builtins('hydeengine.templatetags.aym') add_to_builtins('hydeengine.templatetags.typogrify') self.create_siteinfo()
def initialize_population(population_size_setpoint): print("Welcome to auto-ML!") # deal with path path = "Store" test_dir(path) folder = Folder(path) p = Population(folder, population_size_setpoint) print('population initialization succeed!\n') return p
def main(argv): parser = OptionParser(usage="usage: %prog [options]", version="%prog 0.1a") parser.add_option("-a", "--app", dest = "app", help = "The application to build. Required.") parser.add_option("-p", "--path", dest = "path", default = '.', help = "Conche root path. Default: Current Working Directory. Optional. Default: `%default`") (options, args) = parser.parse_args() if len(args): parser.error("Unexpected arguments encountered.") if not options.app: parser.error("You must specify an application.") path = options.path if path == ".": path = os.getcwdu() target = Folder(path) if not target.exists: target.make() source = Folder(PROG_ROOT).child_folder('template') target.copy_contents_of(source, incremental=True) apps = File(target.child('apps.yaml')) appsString = apps.read_all() appsString = string.Template(appsString).safe_substitute(init_app = options.app) apps.write(appsString)
def __init__(self, site_path): super(Initializer, self).__init__() self.site_path = Folder(site_path)
print("Welcome to analysis system!") # deal with path last_path = load_path() response = None if last_path != '': print("Notice the last store path is: ", last_path) while response not in ('y', 'n'): response = input("Do you want to use that?(y/n): ").lower() if response == 'y': last_path = test_dir(last_path) if response == 'n' or last_path == '' or response is None: last_path = input("Please choose a new store path: ") last_path = test_dir(last_path) last_path = test_dir(last_path) folder = Folder(last_path) data = np.zeros(folder.max_id) best = [] for file in folder.history: # alive file if not folder.alive(file): dead_file_path = folder.dead_file_path(file) arch_proto = read_file(dead_file_path) arch = Arch(arch_proto) data[arch.id - 1] = arch.accuracy # dead file else: file_path = folder.file_path(file) arch_proto = read_file(file_path)
def build_siteinfo(self, deploy_path=None): tmp_folder = Folder(settings.TMP_DIR) deploy_folder = Folder( (deploy_path, settings.DEPLOY_DIR)[not deploy_path]) if deploy_folder.exists and settings.BACKUP: backup_folder = Folder(settings.BACKUPS_DIR).make() deploy_folder.backup(backup_folder) tmp_folder.delete() tmp_folder.make() settings.DEPLOY_DIR = deploy_folder.path if not deploy_folder.exists: deploy_folder.make() self.create_siteinfo()
def serve(self, deploy_path, exit_listner): """ Starts the cherrypy server at the given `deploy_path`. If exit_listner is provided, calls it when the engine exits. """ try: import cherrypy from cherrypy.lib.static import serve_file except ImportError: print "Cherry Py is required to run the webserver" raise setup_env(self.site_path) validate_settings() deploy_folder = Folder( (deploy_path, settings.DEPLOY_DIR)[not deploy_path]) if not 'site' in settings.CONTEXT: generator = Generator(self.site_path) generator.create_siteinfo() site = settings.CONTEXT['site'] url_file_mapping = defaultdict(bool) # This following bit is for supporting listing pages with arbitrary # filenames. if settings.GENERATE_CLEAN_URLS: for page in site.walk_pages(): # build url to file mapping if page.listing and page.file.name_without_extension not in \ (settings.LISTING_PAGE_NAMES + [page.node.name]): filename = os.path.join(settings.DEPLOY_DIR, page.name) url = page.url.strip('/') url_file_mapping[url] = filename class WebRoot: @cherrypy.expose def index(self): page = site.listing_page return serve_file(deploy_folder.child(page.name)) if settings.GENERATE_CLEAN_URLS: @cherrypy.expose def default(self, *args): # first, see if the url is in the url_file_mapping # dictionary file = url_file_mapping[os.sep.join(args)] if file: return serve_file(file) # next, try to find a listing page whose filename is the # same as its enclosing folder's name file = os.path.join(deploy_folder.path, os.sep.join(args), args[-1] + '.html') if os.path.isfile(file): return serve_file(file) # try each filename in LISTING_PAGE_NAMES setting for listing_name in settings.LISTING_PAGE_NAMES: file = os.path.join(deploy_folder.path, os.sep.join(args), listing_name + '.html') if os.path.isfile(file): return serve_file(file) # failing that, search for a non-listing page file = os.path.join(deploy_folder.path, os.sep.join(args[:-1]), args[-1] + '.html') if os.path.isfile(file): return serve_file(file) # failing that, page not found raise cherrypy.NotFound cherrypy.config.update({ 'environment': 'production', 'log.error_file': 'site.log', 'log.screen': True, 'server.socket_host': self.address, 'server.socket_port': self.port, }) # even if we're still using clean urls, we still need to serve media. if settings.GENERATE_CLEAN_URLS: conf = { '/media': { 'tools.staticdir.dir': os.path.join(deploy_folder.path, 'media'), 'tools.staticdir.on': True } } else: conf = { '/': { 'tools.staticdir.dir': deploy_folder.path, 'tools.staticdir.on': True } } cherrypy.tree.mount(WebRoot(), "/", conf) if exit_listner: cherrypy.engine.subscribe('exit', exit_listner) cherrypy.engine.start()