Exemplo n.º 1
0
def RunTime(language, items, OML, CLASS={"OML": "oml.base.OMLBase"}):
    langruntime = __from__("oml.{}.RunTime".format(language.lower()))

    for k in CLASS:
        CLASS[k] = __from__(CLASS[k])()
    CLASS["ROW"] = ROW

    nitems = []
    for item in items:
        nitem = item.copy()
        for oml_line in OML.split("\n"):
            temp = Template(oml_line)
            render = temp.render(item)

            runlang = Template(
                "function(#for @class in @_class:@class"
                "#if(@velocityHasNext), #end#end) "
                "return @render end")

            _run = langruntime.eval(runlang.render(
                {"_class": [i for i in CLASS],
                 "render": render}))
            nitem.update(_run(*CLASS.values()).items())
        nitems.append(nitem)
    return nitems
Exemplo n.º 2
0
    def launch(self):
        template = Template(self._TEMPLATE)
        self.script = template.render(self._namespace)

        temp = tempfile.NamedTemporaryFile(delete=False)
        temp.write(self.script)
        temp.close()

        logging.debug('Launch AppleScript at %s: %s', temp.name, self.script)
        subprocess.call('osascript %s' % temp.name, shell=True)
        os.unlink(temp.name)
Exemplo n.º 3
0
    def launch(self):
        template = Template(self._TEMPLATE)
        self.script = template.render(self._namespace)

        temp = tempfile.NamedTemporaryFile(delete=False)
        temp.write(self.script)
        temp.close()

        logging.debug('Launch AppleScript at %s: %s', temp.name, self.script)
        subprocess.call('osascript %s' % temp.name, shell=True)
        os.unlink(temp.name)
Exemplo n.º 4
0
def RunTime(language, items, OML, CLASS={"OML": "oml.base.OMLBase"}):
    langruntime = __from__("oml.{}.RunTime".format(language.lower()))

    for k in CLASS:
        CLASS[k] = __from__(CLASS[k])()
    CLASS["ROW"] = ROW

    nitems = []
    for item in items:
        nitem = item.copy()
        for oml_line in OML.split("\n"):
            temp = Template(oml_line)
            render = temp.render(item)

            runlang = Template("function(#for @class in @_class:@class"
                               "#if(@velocityHasNext), #end#end) "
                               "return @render end")

            _run = langruntime.eval(
                runlang.render({
                    "_class": [i for i in CLASS],
                    "render": render
                }))
            nitem.update(_run(*CLASS.values()).items())
        nitems.append(nitem)
    return nitems
Exemplo n.º 5
0
 def render(self, dictto):
     temp = Template(manageproxy.template2)
     return temp.render(dictto)
Exemplo n.º 6
0
 def _template(self, item, config):
     template = Template(item)
     return template.render(config)
Exemplo n.º 7
0
	def render(self,dictto):
		temp = Template(manageproxy.template2)
		return temp.render(dictto)
Exemplo n.º 8
0
  def generate_nginx_config(nginx_dir, host, install_dir):
    template = Template("""
server {
      listen     80 default;
      server_name _;
      return 301 https://$host$request_uri;
}

server {
    listen 443;
    server_name @seafile_host;

    proxy_set_header X-Forwarded-For $remote_addr;

    location / {
        fastcgi_pass    127.0.0.1:8000;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;

        fastcgi_param    SERVER_PROTOCOL        $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param    SERVER_ADDR         $server_addr;
        fastcgi_param    SERVER_PORT         $server_port;
        fastcgi_param    SERVER_NAME         $server_name;
        fastcgi_param   REMOTE_ADDR         $remote_addr;

        access_log      /var/log/nginx/seahub.access.log;
        error_log       /var/log/nginx/seahub.error.log;
        fastcgi_read_timeout 36000;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
    }

    location /media {
        root @seafile_install_dir/seafile-server-latest/seahub;
    }
}
""")
    output_file_path = os.path.join(nginx_dir,"etc","nginx","sites-enabled","seafile") 
    os.makedirs(os.path.dirname(output_file_path),exist_ok=True)
 
    output_file = open(output_file_path,'w')
    output_file.write(template.render({"seafile_host":host, "seafile_install_dir":install_dir}))
    output_file.close()

    found = False
    output_file_path = os.path.join(nginx_dir,"etc","nginx","nginx.conf")
   
    with fileinput.FileInput(output_file_path, inplace=True, backup='.bak') as file:
      for line in file:
        if (re.match("daemon .*;",line) != None):
          found = True
          print(re.sub("daemon .*;", "daemon off;", line),end='')
        else:
          print(line,end='')
    if found == False:
      output_file = open(output_file_path,"a")
      output_file.write("daemon off;")
      output_file.close()
Exemplo n.º 9
0
 def _template(self, item, config):
     template = Template(item)
     return template.render(config)