예제 #1
0
def load_scopes():
    from thepian.conf import structure

    base = join(structure.JS_DIR)
    scopes = [s for s in listdir(base,filters=(filters.fnmatch("*.scope.js"),))]
    for s in scopes:
        load_and_add_scope('"%s"' % s[:-9],join(base,s))
    print "Done loading scopes (", " ".join(scopes),")"
예제 #2
0
    def apply_single_basedir(self,repo_dir,basedir):
        self.REPO_DIR = repo_dir 

        self.CONF_DIR = join(basedir, "conf")
        self.PYTHON_DIR = join(basedir,"python")
        self.JS_DIR = join(basedir,"js")
        self.CSS_DIR = join(basedir,"css")
        self.TEMPLATES_DIR = join(basedir,"templates")
        self.SAMPLE_TEMPLATES_DIR = join(self.PYTHON_DIR,"theapps","samples","templates")  

        self.LIB_DIR = join(self.REPO_DIR,"python")
        self.PROJECT_NAME = split(self.REPO_DIR)[1]
        self.PROJECT_DIR = self.REPO_DIR
        self.SOURCE_DIR = self.REPO_DIR
        self.TARGET_DIR = join(self.PROJECT_DIR,"target")
        self.RELEASE_DIR = join(self.PROJECT_DIR,"release")
        self.UPLOADS_DIR = join("/var","uploads",self.PROJECT_NAME)
        self.DOWNLOADS_DIR = join("/var","downloads",self.PROJECT_NAME)
        self.BACKUPS_DIR = join("/var","backups",self.PROJECT_NAME)
        self.LOG_DIR = join("/var","log",self.PROJECT_NAME)
        self.SITES_DIR = dirname(self.PROJECT_DIR)
        self.WEBSITE_DIRS = fs.filterdirs((
            join(basedir,"root"), 
            join(basedir,"website"), 
            join(self.TARGET_DIR,"website"),
            ))
        self.MEDIASITE_DIRS = fs.filterdirs((
            join(basedir,"root"), 
            join(basedir,"mediasite"), 
            join(self.TARGET_DIR,"mediasite"),
            ))
        self.TOOLS_DIR = expanduser("~/Sites/tools")
        self.PID_DIR = join("/var/run",self.PROJECT_NAME)
        
        from fs import filters
        dirs = fs.listdir(self.PROJECT_DIR, filters=(filters.fnmatch("*site"),filters.only_directories,))
        dirs.sort() # just to make sure
        self.SITE_DIRS = dirs
예제 #3
0
파일: js.py 프로젝트: thepian/themaestro
 def list_sources(cls,src,full_path=True):
     return fs.listdir(src,full_path=True,recursed=False,filters=(fnmatch("*.js"),))
예제 #4
0
def populate(expander_writer,config):

	if site.SCSS_DIR:
		try:
			import scss
			setattr(scss,"LOAD_PATHS",site.SCSS_DIR)
		except ImportError:
			pass
	""" TODO:
LOAD_PATHS = os.path.join(PROJECT_ROOT, 'sass/frameworks/')
# Assets path, where new sprite files are created:
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static/')
# Assets path, where new sprite files are created:
ASSETS_ROOT = os.path.join(PROJECT_ROOT, 'static/assets/')
# Urls for the static and assets:
STATIC_URL = '/static/'
ASSETS_URL = '/static/assets/'
"""

	base_filters = [config.exclude_filter(),filters.no_hidden,filters.no_system]
	css_prefix = "css"
	js_prefix = "js"
	if config["assets-base"]:
		css_prefix = "%s/css" % config["assets-base"]
		js_prefix = "%s/js" % config["assets-base"]

	if site.SCSS_DIR:
		for relpath in listdir(site.SCSS_DIR,filters=base_filters+[filters.fnmatch("*.scss"),]):
			expander = FileExpander(site.SCSS_DIR,relpath,config=config,prefix=css_prefix)
			#setattr(scss,"LOAD_PATHS",site.SCSS_DIR)
			for browser in browsers:
				if not config["browser"] or config["browser"] == browser.browser_type:
					expander_writer(expander,browser,config) 
			logging.info("Cached %s for %s as %s" % (relpath,expander.domain,repr(expander)))

	if site.LIBS_DIR:
		builders = {}
		for relpath in listdir(site.LIBS_DIR, filters=[filters.only_directories,filters.fnmatch("*.js")]):
			libname = relpath[:-3]
			builder = LibBuilder(site.LIBS_DIR,subdir=libname,config=config)
			builders[libname] = builder
			#TODO figure out the relevant one

		for relpath in listdir(site.LIBS_DIR, filters=[filters.no_directories,filters.fnmatch("*.js")]):
			expander = FileExpander(site.LIBS_DIR,relpath,config=config,prefix=js_prefix)
			prefix = expander.name_parts[0]
			if prefix in builders:
				builder = builders[prefix]
			else:
				builder = LibBuilder(site.LIBS_DIR,prefix=prefix,config=config)
				builders[prefix] = builder
			builder.addVersion(expander)

		for name in builders.iterkeys():
			builder = builders[name]
			for expander in builder.deployed_expanders:
				for browser in browsers:
					if not config["browser"] or config["browser"] == browser.browser_type:
						#print >>sys.stderr, repr(expander)
						expander_writer(expander,browser,config)
		

	for relpath in listdir(site.SITE_DIR,recursed=True,filters=base_filters):
		expander = FileExpander(site.SITE_DIR,relpath,config=config)
		if relpath[0] != "_":
			for browser in browsers:
				if not config["browser"] or config["browser"] == browser.browser_type:
					expander_writer(expander,browser,config) 
			logging.info("Cached %s for %s as %s" % (relpath,expander.domain,repr(expander)))
예제 #5
0
def source_paths():
    """Iterate url paths for css and js sources"""
    for name in fs.listdir(structure.CSS_DIR, filters=(only_directories,fnmatch("*.css"))):
        yield join("css",name)
    for name in fs.listdir(strucure.JS_DIR, filters=(only_directories,fnmatch("*.js"))):
        yield join("js",name)
예제 #6
0
def ensure_presets():
    home = expanduser("~/.ffmpeg")
    makedirs(home)
    presets = listdir(structure.CONF_DIR,filters=(filters.no_hidden,filters.no_system,filters.fnmatch("*.ffpreset")))
    for preset in presets:
        copy_file(src=join(structure.CONF_DIR,preset),dst=join(home,preset))
예제 #7
0
def load_seed():
    from thepian.conf import structure
    
    base = join(structure.PROJECT_DIR,"seed")
    if exists(base):
        for a in listdir(base):
            account = join(base,a)
            
            for p in listdir(account):
                project = join(account,p)
                
                REDIS.sadd(PROJECTS_KEY % a, p)

                upload_info = {
                    "account": a,
                    "project": p,
                    "expires": ONE_YEAR_IN_SECONDS,
                }
                upload_hash = hashlib.sha256( UPLOAD_SCRIPT_HASH_COMBINE % (a,p) ).hexdigest()
                REDIS[UPLOAD_PATH_KEY % (p,upload_hash)] = json.dumps(upload_info)
                REDIS[UPLOAD_SCRIPT_KEY % (p,upload_hash)] = load_expand_and_translate(join(structure.JS_DIR,'upload-specs.js'),**upload_info)[2]
                REDIS.sadd(SHORTCUT_UPLOADS_KEY % (a,p), upload_hash)
                print 'Upload URL /%s/%s/upload-specs.js' % (p,upload_hash)
                
                suite_info = {
                    "account": a,
                    "project": p,
                    "suite": "all",
                    "exec_name": "selftest",
                }
                suite_src = SUITE_HASH_COMBINE % (a,p,'all','selftest')
                suite_hash = hashlib.sha256(suite_src).hexdigest()
                suite_id = SUITE_KEY % (p,suite_hash)
                REDIS.set(suite_id , json.dumps(suite_info))
                REDIS.sadd(SHORTCUT_SUITES_KEY % (a,p), suite_hash)
                print 'Project %s URL /%s/%s/introduction.html' % (p,p,suite_hash) 
            
                for s in listdir(project, filters=(filters.fnmatch("*.spec.js"),)):
                    src,expanded,translated = load_expand_and_translate(join(project,s))
                    h = hashlib.sha256(src).hexdigest()
                    idx = 0
                    for spec in expanded:
                        spec_hash = h + "-" + str(idx)

                        translated = translate([ spec ])

                        id = TRANSLATED_SPEC_KEY % (a,p,spec_hash)
                        # print "adding", id, ":", t, "name", spec[2]
                        REDIS.set(id,translated)
                        info_id = SPEC_INFO_KEY % (a,p,spec_hash)
                        info = {"id":spec_hash,"name":spec[2],"filename":s}
                        REDIS.set(info_id , json.dumps(info))

                        examples_id = EXAMPLE_NAMES_KEY % (a,p,spec_hash)
                        examples = [e[1].replace('"','') for e in extract_examples(expanded)]
                        # print h, "seed examples", examples
                        # sadd is supposed to be callable by REDIS.sadd(examples_id,*examples)
                        for e in examples:
                            REDIS.sadd(examples_id, e)
                
                        # added the hash to the all list
                        REDIS.sadd(ALL_SPECS_KEY % (a,p), spec_hash)

                        ++idx

           
    print "Done loading seed."