コード例 #1
0
    def test_04(self):
        filepath = os.path.join(FILE_DIR, "test.txt")
        hyp_01 = Jinja2Renderer.htmlfile2markup(filepath, {"name": "<a>a</a>"})
        self.assertTrue(
            Jinja2Tool.equal(hyp_01, Markup('<b>&lt;a&gt;a&lt;/a&gt;</b>!')))

        hyp_02 = Jinja2Renderer.htmlfile2markup(filepath,
                                                {"name": Markup("<a>a</a>")})
        self.assertTrue(Jinja2Tool.equal(hyp_02, Markup('<b><a>a</a></b>!')))
コード例 #2
0
    def test_02(self):
        hyp_01 = Jinja2Renderer.markup2markup(Markup('<b>{{ name }}</b>!'),
                                              {"name": "<a>a</a>"})
        self.assertTrue(
            Jinja2Tool.equal(hyp_01, Markup('<b>&lt;a&gt;a&lt;/a&gt;</b>!')))

        hyp_02 = Jinja2Renderer.markup2markup(Markup('<b>{{ name }}</b>!'),
                                              {"name": Markup("<a>a</a>")})
        self.assertTrue(Jinja2Tool.equal(hyp_02, Markup('<b><a>a</a></b>!')))
コード例 #3
0
    def test_02(cls):
        filepath = "config/google/api/foxytrixy.bot.credentials.json"

        creds = username_scope2creds(filepath, "foxytrixy.bot",
                                     cls.SCOPE_PROJECT)
        service = build('script', 'v1', http=creds.authorize(Http()))

        gsheet_id = "15K2PThxUL6YQhJBoQ5GYEgtNUsH132lUZDGYGxQDn40"
        #script_id = "my-project-1535733106774"
        str_JS = Jinja2Renderer.textfile2text(
            "foxyos/spreadsheet.isPartOfMerge.part.js",
            {"googlespreadsheet_id": gsheet_id})
        str_JSON_MANIFEST = Jinja2Renderer.textfile2text(
            "foxyos/manifest.sample.part.json", )
        try:
            h_PROJECT = {
                'title': 'Google Spreadsheet',
                "parentId": gsheet_id,
            }
            response = service.projects().create(body=h_PROJECT).execute()
            #             response = service.projects().get(scriptId=script_id).execute()
            script_id = response['scriptId']
            print(script_id)

            # Upload two files to the project
            h_BODY = {
                'files': [
                    {
                        'name': 'zz_code',
                        'type': 'SERVER_JS',
                        'source': str_JS,
                    },
                    {
                        'name': 'appsscript',
                        'type': 'JSON',
                        'source': cls.SAMPLE_MANIFEST,  #str_JSON_MANIFEST,
                    },
                ],
            }
            response = service.projects().updateContent(**{
                "body": h_BODY,
                "scriptId": script_id,
            }).execute()
            #print(response)

            print('https://script.google.com/d/' + response['scriptId'] +
                  '/edit')

        except errors.HttpError as error:
            # The API encountered a problem.
            print(error.content)
コード例 #4
0
    def env2compile(cls, env):
        logger = HenriqueLogger.func_level2logger(cls.env2compile,
                                                  logging.DEBUG)
        logger.debug({"env": env})

        uwsgi_mode = HenriqueUwsgi.env2mode(env)

        nginx_mode = HenriqueNginx.env2mode(env)
        uid = HenriqueNginx.Mode.mode2user(nginx_mode)
        gid = HenriqueNginx.Mode.mode2group(nginx_mode)

        data = {
            "env": env,
            "uid": uid,
            "gid": gid,
            "uwsgi_mode": uwsgi_mode,
        }

        filepath = os.path.join(FILE_DIR, "conf",
                                "henrique.supervisord.{}.conf".format(env))
        utf8 = Jinja2Renderer.template2text(cls.template(), data=data)
        FileTool.utf82file(utf8, filepath)

        logger.debug({
            "filepath": filepath,
            "data": data,
        })
コード例 #5
0
 def dashboard(cls):
     data = {
         "userinfo": session['profile'],
         "userinfo_pretty": json.dumps(session['jwt_payload'], indent=2),
     }
     filepath = os.path.join(FILE_DIR, "dashboard.html")
     return Jinja2Renderer.htmlfile2markup(filepath, data=data)
コード例 #6
0
    def mode2compile(cls, mode):
        data = {
            "mode": mode,
        }

        filepath = os.path.join(FILE_DIR, "ini",
                                "henrique.uwsgi.{}.ini".format(mode))
        utf8 = Jinja2Renderer.template2text(cls.template(), data=data)
        FileTool.utf82file(utf8, filepath)
コード例 #7
0
def main():
    logger = FoxylibLogger.func_level2logger(main, logging.DEBUG)

    str_in = sys.stdin.read()

    h_env = dict(os.environ)
    str_out = Jinja2Renderer.text2text(str_in, h_env)

    logger.debug({
        "str_in": str_in,
        "str_out": str_out,
    })

    print(str_out)
コード例 #8
0
    def get(cls):

        html_head = wrap_html_tag(HenriqueFront.html_head_inner(), "head")

        filepath = os.path.join(FILE_DIR, "index.part.html")
        html_body = join_html_and_wrap([
            HenriqueFront.html_top(),
            Jinja2Renderer.htmlfile2markup(filepath),
        ], "body")

        # <!DOCTYPE html>
        html = join_html_and_wrap([html_head, html_body],
                                  "html",
                                  attrs=HenriqueFront.html_attrs())
        return html, 200
コード例 #9
0
    def env2compile(cls, env):
        domain_name = cls.env2domain_name(env)

        mode = cls.env2mode(env)
        nginx_dir = cls.Mode.mode2nginx_dir(mode)
        socket = cls.Mode.mode2socket(mode)
        uid = cls.Mode.mode2user(mode)
        gid = cls.Mode.mode2group(mode)

        data = {"DOMAIN_NAME": domain_name,
                "NGINX_DIR": nginx_dir,
                "socket": socket,
                "uid": uid,
                "gid": gid,
                "FILEPATH_SSL_CERTI": None,
                "FILEPATH_SSL_PRIVATE_KEY": None,
                }

        filepath = os.path.join(FILE_DIR, "conf","henrique.nginx.{}.conf".format(env))
        utf8 = Jinja2Renderer.template2text(cls.template(), data=data)
        FileTool.utf82file(utf8, filepath)
コード例 #10
0
 def template(cls):
     filepath = os.path.join(FILE_DIR, "henrique.supervisord.conf.tmplt")
     utf8 = FileTool.filepath2utf8(filepath)
     template = Jinja2Renderer.env_text2template(None, utf8)
     return template
コード例 #11
0
    def textfile2text(cls, textfile, data=None, env=None):
        text = cls.filepath2utf8(textfile)
        if text is None:
            return None

        return Jinja2Renderer.text2text(text, data=data, env=env)
コード例 #12
0
 def test_03(self):
     filepath = os.path.join(FILE_DIR, "test.txt")
     hyp_01 = Jinja2Renderer.textfile2text(filepath, {"name": "<a>a</a>"})
     self.assertTrue(Jinja2Tool.equal(hyp_01, '<b><a>a</a></b>!'))
コード例 #13
0
 def test_01(self):
     hyp = Jinja2Renderer.text2text('<b>{{ name }}</b>!',
                                    {"name": "<a>a</a>"})
     self.assertTrue(Jinja2Tool.equal(hyp, "<b><a>a</a></b>!"))
コード例 #14
0
 def html_top(cls):
     filepath = os.path.join(cls.dirpath_singleton(), "body", "top",
                             "top.part.html")
     html_inner = Jinja2Renderer.htmlfile2markup(filepath)
     return html_inner
コード例 #15
0
 def html_head_inner(cls):
     filepath = os.path.join(cls.dirpath_singleton(), "head",
                             "head_inner.part.html")
     html_inner = Jinja2Renderer.htmlfile2markup(filepath)
     return html_inner
コード例 #16
0
 def index(cls):
     filepath = os.path.join(FILE_DIR, "index.html")
     return Jinja2Renderer.htmlfile2markup(filepath, )