当前位置: 首页>>代码示例>>Python>>正文


Python App.db方法代码示例

本文整理汇总了Python中libraries.app.app.App.db方法的典型用法代码示例。如果您正苦于以下问题:Python App.db方法的具体用法?Python App.db怎么用?Python App.db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libraries.app.app.App的用法示例。


在下文中一共展示了App.db方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]
 def get(cls, *args, **kwargs):
     """
     :param args:
     :param kwargs:
     :return TxModel:
     """
     if args:
         kwargs[inspect(cls).primary_key[0].name] = args[0]
     item = cls.query(**kwargs).first()
     App.db().close()
     return item
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:13,代码来源:tx_model.py

示例2: query

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]
 def query(cls, **kwargs):
     items = App.db().query(cls).filter_by(**kwargs)
     return items
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:5,代码来源:tx_model.py

示例3: delete

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]
 def delete(self):
     App.db().delete(self)
     App.db().commit()
     App.db().close()
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:6,代码来源:tx_model.py

示例4: update

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]
 def update(self):
     App.db().merge(self)
     App.db().commit()
     App.db().close()
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:6,代码来源:tx_model.py

示例5: insert

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]
 def insert(self):
     App.db().add(self)
     App.db().commit()
     App.db().close()
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:6,代码来源:tx_model.py

示例6: generate_dashboard

# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import db [as 别名]

#.........这里部分代码省略.........
                    'html.parser'))
                body.table.append(BeautifulSoup(
                    '<tr id="' + module_name + '-job-failure" class="module-public-links">' +
                    '<td class="lbl">Job Failures:</td><td>' +
                    str(self.jobs_failures) + '</td></tr>',
                    'html.parser'))
                body.table.append(BeautifulSoup(
                    '<tr id="' + module_name + '-job-total" class="module-public-links">' +
                    '<td class="lbl">Jobs Total:</td><td>' +
                    str(self.jobs_total) + '</td></tr>',
                    'html.parser'))

            self.get_jobs_counts(registered_jobs)
            body.table.append(BeautifulSoup(
                '<tr id="totals"><td class="hdr" colspan="2">Total Jobs</td></tr>',
                'html.parser'))
            body.table.append(BeautifulSoup(
                '<tr id="totals-job-success" class="module-public-links"><td class="lbl">Success:</td><td>' +
                str(self.jobs_success) + '</td></tr>',
                'html.parser'))
            body.table.append(BeautifulSoup(
                '<tr id="totals-job-warning" class="module-public-links"><td class="lbl">Warnings:</td><td>' +
                str(self.jobs_warnings) + '</td></tr>',
                'html.parser'))
            body.table.append(BeautifulSoup(
                '<tr id="totals-job-failure" class="module-public-links"><td class="lbl">Failures:</td><td>' +
                str(self.jobs_failures) + '</td></tr>',
                'html.parser'))
            body.table.append(BeautifulSoup(
                '<tr id="totals-job-unregistered" class="module-public-links"><td class="lbl">Unregistered:</td><td>' +
                str(total_job_count - self.jobs_total) + '</td></tr>',
                'html.parser'))
            body.table.append(BeautifulSoup(
                '<tr id="totals-job-total" class="module-public-links"><td class="lbl">Total:</td><td>' +
                str(total_job_count) + '</td></tr>',
                'html.parser'))

            # build job failures table
            job_failures = self.get_job_failures(registered_jobs, max_failures)
            body.append(BeautifulSoup('<h2>Failed Jobs</h2>', 'html.parser'))
            failure_table = BeautifulSoup('<table id="failed" cellpadding="4" border="1" ' +
                                          'style="border-collapse:collapse"></table>', 'html.parser')
            failure_table.table.append(BeautifulSoup('''
                <tr id="header">
                <th class="hdr">Time</th>
                <th class="hdr">Errors</th>
                <th class="hdr">Repo</th>
                <th class="hdr">PreConvert</th>
                <th class="hdr">Converted</th>
                <th class="hdr">Destination</th>''', 'html.parser'))

            gogs_url = App.gogs_url
            if gogs_url is None:
                gogs_url = 'https://git.door43.org'

            for i in range(0, len(job_failures)):
                item = job_failures[i]

                try:
                    identifier = item.identifier
                    user_name, repo_name, commit_id = identifier.split('/')[:3]
                    source_sub_path = '{0}/{1}'.format(user_name, repo_name)
                    cdn_bucket = item.cdn_bucket
                    destination_url = 'https://{0}/u/{1}/{2}/{3}/build_log.json'.format(cdn_bucket, user_name,
                                                                                        repo_name, commit_id)
                    repo_url = gogs_url + "/" + source_sub_path
                    preconverted_url = item.source
                    converted_url = item.output
                    failure_table.table.append(BeautifulSoup(
                        '<tr id="failure-' + str(i) + '" class="module-job-id">'
                        + '<td>' + item.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") + '</td>'
                        + '<td>' + ','.join(item.errors) + '</td>'
                        + '<td><a href="' + repo_url + '">' + source_sub_path + '</a></td>'
                        + '<td><a href="' + preconverted_url + '">' + preconverted_url.rsplit('/', 1)[1] + '</a></td>'
                        + '<td><a href="' + converted_url + '">' + item.job_id + '.zip</a></td>'
                        + '<td><a href="' + destination_url + '">Build Log</a></td>'
                        + '</tr>',
                        'html.parser'))
                except Exception as e:
                    pass

            body.append(failure_table)
            self.build_language_popularity_tables(body, max_failures)
            body_html = body.prettify('UTF-8')
            dashboard['body'] = body_html

            # save to cdn in case HTTP connection times out
            try:
                self.temp_dir = tempfile.mkdtemp(suffix="", prefix="dashboard_")
                temp_file = os.path.join(self.temp_dir, "index.html")
                file_utils.write_file(temp_file, body_html)
                cdn_handler = App.cdn_s3_handler()
                cdn_handler.upload_file(temp_file, 'dashboard/index.html')
            except Exception as e:
                App.logger.debug("Could not save dashboard: " + str(e))
        else:
            App.logger.debug("No modules found.")

        App.db().close()
        return dashboard
开发者ID:unfoldingWord-dev,项目名称:tx-manager,代码行数:104,代码来源:manager.py


注:本文中的libraries.app.app.App.db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。