Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 def process(resource):
     import clevercss
     data = resource.source_file.read_all()
     out = clevercss.convert(data)
     out_file = File(resource.source_file.path_without_extension + ".css")
     out_file.write(out)
     resource.source_file.delete()
Exemplo n.º 3
0
    def process(folder, params):
        site = settings.CONTEXT['site']
        sitemap_path = params["sitemap_file"]
        url_list_file = File(sitemap_path).parent.child("urllist.txt")
        config_file = File(sitemap_path).parent.child("sitemap_config.xml")
        urllist = open(url_list_file, 'w')
        for page in site.walk_pages():
            if not page.display_in_list and not page.listing:
                continue
            created = xmldatetime(page.created)
            updated = xmldatetime(page.updated)
            url = page.full_url
            priority = 0.5
            if page.listing:
                priority = 1.0
            changefreq = "weekly"
            urllist.write(
                "%(url)s lastmod=%(updated)s changefreq=%(changefreq)s \
priority=%(priority).1f\n" % locals())
        urllist.close()
        base_url = settings.SITE_WWW_URL
        config = open(config_file, 'w')
        config.write(SITEMAP_CONFIG % locals())
        config.close()
        generator = params["generator"]
        command = u"python %s --config=%s" % (generator, config_file)
        status, output = commands.getstatusoutput(command)
        if status > 0:
            print output
        File(config_file).delete()
        File(url_list_file).delete()
Exemplo n.º 4
0
 def process(resource):
     import clevercss
     data = resource.source_file.read_all()
     out = clevercss.convert(data)
     out_file = File(resource.source_file.path_without_extension + ".css")
     out_file.write(out)
     resource.source_file.delete()
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     hss = settings.HSS_PATH
     if not hss or not os.path.exists(hss):
         raise ValueError("HSS Processor cannot be found at [%s]" % hss)
     status, output = commands.getstatusoutput(
     u"%s %s -output %s/" % (hss, resource.source_file.path, out_file.parent.path))
     if status > 0:
         print output
         return None
     resource.source_file.delete()
     out_file.copy_to(resource.source_file.path)
     out_file.delete()
Exemplo n.º 6
0
    def process(resource):
        compress = settings.YUI_COMPRESSOR

        if not compress or not os.path.exists(compress):
            return
            
        tmp_file = File(resource.source_file.path + ".z-tmp")
        status, output = commands.getstatusoutput(
        u"java -jar %s %s > %s" % (compress, resource.source_file.path, tmp_file.path))
        if status > 0: 
            print output
        else:
            resource.source_file.delete()
            tmp_file.move_to(resource.source_file.path)
Exemplo n.º 7
0
 def notify(self, title, message):
     if hasattr(settings, "GROWL") and settings.GROWL and File(
             settings.GROWL).exists:
         try:
             subprocess.call(
                 [settings.GROWL, "-n", "Hyde", "-t", title, "-m", message])
         except:
             pass
Exemplo n.º 8
0
    def process(resource):
        compress = settings.CLOSURE_COMPILER
        if not os.path.exists(compress):
            compress = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError("Closure Compiler cannot be found at [%s]" % compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        status, output = commands.getstatusoutput(
            u"java -jar %s --js=%s --js_output_file=%s" % (compress, resource.source_file.path, tmp_file.path)
        )
        if status > 0:
            print output
        else:
            resource.source_file.delete()
            tmp_file.move_to(resource.source_file.path)
Exemplo n.º 9
0
    def process(resource):
        if settings.YUI_COMPRESSOR == None:
            return
        compress = settings.YUI_COMPRESSOR
        if not os.path.exists(compress):
            compress = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError("YUI Compressor cannot be found at [%s]" % compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        status, output = commands.getstatusoutput(
            u"java -jar %s %s > %s" % (compress, resource.source_file.path, tmp_file.path)
        )
        if status > 0:
            print output
        else:
            resource.source_file.delete()
            tmp_file.move_to(resource.source_file.path)
Exemplo n.º 10
0
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     hss = settings.HSS_PATH
     if not hss or not os.path.exists(hss):
         raise ValueError("HSS Processor cannot be found at [%s]" % hss)
     try:
         check_call([hss, resource.source_file.path, "-output", out_file.parent.path + '/'])
     except CalledProcessError, e:
         print 'Syntax Error when calling HSS Processor:', e
         return None
Exemplo n.º 11
0
    def process(resource):
        compress = settings.CLOSURE_COMPILER
        if not os.path.exists(compress):
            compress = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError("Closure Compiler cannot be found at [%s]" %
                             compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        status, output = commands.getstatusoutput(
            u"java -jar %s --js=%s --js_output_file=%s" %
            (compress, resource.source_file.path, tmp_file.path))
        if status > 0:
            print output
        else:
            resource.source_file.delete()
            tmp_file.move_to(resource.source_file.path)
Exemplo n.º 12
0
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     if not out_file.parent.exists:
         out_file.parent.make()
     less = settings.LESS_CSS_PATH
     if not less or not os.path.exists(less):
         raise ValueError("Less CSS Processor cannot be found at [%s]" % less)
     try:
         check_call([less, resource.source_file.path, out_file.path])
     except CalledProcessError, e:
         print 'Syntax Error when calling less:', e
Exemplo n.º 13
0
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     sass = settings.SASS_PATH
     if not sass or not os.path.exists(sass):
         raise ValueError("SASS Processor cannot be found at [%s]" % sass)
     status, output = commands.getstatusoutput(
         u"%s %s %s" % (sass, resource.source_file.path, out_file))
     if status > 0:
         print output
         return None
     resource.source_file.delete()
Exemplo n.º 14
0
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     load_path = os.path.dirname(resource.file.path)
     sass = settings.SASS_PATH
     if not sass or not os.path.exists(sass):
         raise ValueError("SASS Processor cannot be found at [%s]" % sass)
     try:
         check_call([sass, "-I", load_path, resource.source_file.path,
           out_file.path])
     except CalledProcessError, e:
         print 'Syntax Error when calling SASS Processor:', e
         return None
Exemplo n.º 15
0
    def process(resource):
        if settings.YUI_COMPRESSOR == None:
            return
        compress = settings.YUI_COMPRESSOR
        if not os.path.exists(compress):
            compress = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError("YUI Compressor cannot be found at [%s]" %
                             compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        status, output = commands.getstatusoutput(
            u"java -jar %s %s > %s" %
            (compress, resource.source_file.path, tmp_file.path))
        if status > 0:
            print output
        else:
            resource.source_file.delete()
            tmp_file.move_to(resource.source_file.path)
Exemplo n.º 16
0
    def process(resource):
        tmp_file = File(resource.source_file.path + ".z-tmp")
        if hasattr(settings, "UGLIFYJS"):
            compress = settings.UGLIFYJS
            if not os.path.exists(compress):
                compress = os.path.join(
                        os.path.dirname(
                        os.path.abspath(__file__)), "..", compress)

            try:
                check_call([compress, resource.source_file.path,
                            "--output", tmp_file.path])
            except CalledProcessError, e:
                print 'Syntax Error when calling UglifyJS:', e
                return False
Exemplo n.º 17
0
class Stylus:
    @staticmethod
    def process(resource):
        stylus = settings.STYLUS_PATH
        if not stylus or not os.path.exists(stylus):
            raise ValueError("Stylus Processor cannot be found at [%s]" % stylus)
        try:
            check_call([stylus, resource.source_file.path])
        except CalledProcessError, e:
            print 'Syntax Error when calling stylus:', e
        out_file = File(resource.source_file.path_without_extension + ".css")
        if not out_file.exists:
            print 'Error Occurred when processing with Stylus'
        else:
            resource.source_file.delete()
            resource.source_file = out_file
Exemplo n.º 18
0
class CoffeeScript:
    @staticmethod
    def process(resource):
        coffee = settings.COFFEE_PATH
        if not coffee or not os.path.exists(coffee):
            raise ValueError("CoffeeScript Processor cannot be found at [%s]" % coffee)
        try:
            check_call([coffee, "-b", "-c", resource.source_file.path])
        except CalledProcessError, e:
            print 'Syntax Error when calling CoffeeScript:', e
            return None
        out_file = File(resource.source_file.path_without_extension + ".js")
        if not out_file.exists:
            print 'Error Occurred when processing with CoffeeScript'
        else:
            resource.source_file.delete()
            resource.source_file = out_file
Exemplo n.º 19
0
    def process(resource):
        compress = settings.CLOSURE_COMPILER
        if not os.path.exists(compress):
            compress = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError("Closure Compiler cannot be found at [%s]" %
                             compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        try:
            check_call([
                "java", "-jar", compress, "--js", resource.source_file.path,
                "--js_output_file", tmp_file.path
            ])
        except CalledProcessError, e:
            print "Syntax Error when calling Closure Compiler:", e
Exemplo n.º 20
0
 def process(resource):
     out_file = File(resource.source_file.path_without_extension + ".css")
     hss = settings.HSS_PATH
     if not hss or not os.path.exists(hss):
         raise ValueError("HSS Processor cannot be found at [%s]" % hss)
     status, output = commands.getstatusoutput(
         u"%s %s -output %s/" %
         (hss, resource.source_file.path, out_file.parent.path))
     if status > 0:
         print output
         return None
     resource.source_file.delete()
     out_file.copy_to(resource.source_file.path)
     out_file.delete()
Exemplo n.º 21
0
    def process(resource):
        if settings.YUI_COMPRESSOR == None:
            return
        compress = settings.YUI_COMPRESSOR
        if not os.path.exists(compress):
            compress = os.path.join(
                    os.path.dirname(
                    os.path.abspath(__file__)), "..", compress)

        if not compress or not os.path.exists(compress):
            raise ValueError(
            "YUI Compressor cannot be found at [%s]" % compress)

        tmp_file = File(resource.source_file.path + ".z-tmp")
        try:
            check_call(["java", "-jar", compress,
                resource.source_file.path, "-o",
                tmp_file.path])
        except CalledProcessError, e:
            print 'Syntax Error when calling YUI Compressor:', e