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


Python Date.today方法代码示例

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


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

示例1: main

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
def main():

    try:
        settings = startup.read_settings()
        constants.set(settings.constants)
        Log.start(settings.debug)

        some_failures = http.post_json("http://activedata.allizom.org/query", data={
            "from": "unittest",
            "select": [
                {"name": "branch", "value": "build.branch"},
                {"name": "revision", "value": "build.revision12"},
                {"name": "suite", "value": "run.suite"},
                {"name": "chunk", "value": "run.chunk"},
                {"name": "test", "value": "result.test"}
            ],
            "where": {"and": [
                {"eq": {"result.ok": False}},
                {"gt": {"run.timestamp": Date.today() - WEEK}},
                {"missing": "treeherder.job.note"}
            ]},
            "format": "list",
            "limit": 10
        })


        th = TreeHerder(settings={})

        # th.get_job_classification("mozilla-inbound", "7380457b8ba0")
        for f in some_failures.data:
            th.get_job_classification(f.branch, f.revision)

    except Exception, e:
        Log.error("Problem with etl", e)
开发者ID:klahnakoski,项目名称:Activedata-ETL,代码行数:36,代码来源:update_w_th.py

示例2: _delete_old_indexes

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
 def _delete_old_indexes(self, candidates):
     for c in candidates:
         timestamp = unicode2Date(c.index[-15:], "%Y%m%d_%H%M%S")
         if timestamp + self.rollover_interval < Date.today() - self.rollover_max:
             # Log.warning("Will delete {{index}}", index=c.index)
             try:
                 self.cluster.delete_index(c.index)
             except Exception, e:
                 Log.warning("could not delete index {{index}}", index=c.index, cause=e)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例3: _get_queue

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
    def _get_queue(self, row):
        row = wrap(row)
        if row.json:
            row.value, row.json = convert.json2value(row.json), None
        timestamp = Date(self.rollover_field(wrap(row).value))
        if timestamp == None or timestamp < Date.today() - self.rollover_max:
            return Null

        rounded_timestamp = timestamp.floor(self.rollover_interval)
        queue = self.known_queues.get(rounded_timestamp.unix)
        if queue == None:
            candidates = jx.run({
                "from": self.cluster.get_aliases(),
                "where": {"regex": {"index": self.settings.index + "\d\d\d\d\d\d\d\d_\d\d\d\d\d\d"}},
                "sort": "index"
            })
            best = None
            for c in candidates:
                c = wrap(c)
                c.date = unicode2Date(c.index[-15:], elasticsearch.INDEX_DATE_FORMAT)
                if timestamp > c.date:
                    best = c
            if not best or rounded_timestamp > best.date:
                if rounded_timestamp < wrap(candidates[-1]).date:
                    es = elasticsearch.Index(read_only=False, alias=best.alias, index=best.index, settings=self.settings)
                else:
                    try:
                        es = self.cluster.create_index(create_timestamp=rounded_timestamp, settings=self.settings)
                        es.add_alias(self.settings.index)
                    except Exception, e:
                        if "IndexAlreadyExistsException" not in e:
                            Log.error("Problem creating index", cause=e)
                        return self._get_queue(row)  # TRY AGAIN
            else:
                es = elasticsearch.Index(read_only=False, alias=best.alias, index=best.index, settings=self.settings)

            with suppress_exception:
                es.set_refresh_interval(seconds=60 * 10, timeout=5)

            self._delete_old_indexes(candidates)

            queue = self.known_queues[rounded_timestamp.unix] = es.threaded_queue(max_size=self.settings.queue_size, batch_size=self.settings.batch_size, silent=True)
开发者ID:,项目名称:,代码行数:44,代码来源:

示例4: find_some_work

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
def find_some_work(th):
    # th.get_markup("fx-team", "036f62007472", "B8kS5IJ5Rom8l-kcSIRIlA")
    # th.get_markup("mozilla-inbound", "971c1ee26cad", "fNuzNmZxS6m3i_p9jDh8iA")

    # GET SOME TASKS
    result = http.post_json(url="http://activedata.allizom.org/query", data={
        "from": "task",
        "select": ["build.branch", "build.revision", "task.id"],
        "where": {"and": [
            {"gt": {"task.run.start_time": (Date.today() - DAY).unix}},
            {"exists": "build.revision"},
            {"exists": "build.branch"}
        ]},
        "format": "list"
    })


    # TRY TO GET THEM OUT OF OUR CACHE
    for r in result.data:
        Log.note("look for task {{task_id}}", task_id=r.task.id)
        th.get_markup(r.build.branch, r.build.revision, r.task.id)
开发者ID:klahnakoski,项目名称:MoTreeherder,代码行数:23,代码来源:etl_treeherder.py

示例5: loop_all_days

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
def loop_all_days(destination, please_stop):
    try:
        today = Date.today()

        # WHICH DAYS DO WE NEED TO CALCULATE
        # ALL BUILD DATES WITH WITH ETL TIMESTAMP OF A WEEK AGO
        # ALL BUILD DATES THAT HAVE NOT BEEN PROCESSED YET
        build_dates = http.post_json(config.source.url, json={
            "from": "unittest",
            "edges": [
                {
                    "name": "date",
                    "value": "build.date",
                    "allowNulls": False,
                    "domain": {
                        "type": "time",
                        "min": "today-week",
                        "max": "eod",
                        "interval": "day"
                    }
                }
            ],
            "where": {"gte": {"etl.timestamp": (today - WEEK).unix}},
            "sort": {"value": "build.date", "sort": -1},
            "limit": 14,
            "format": "list"
        })

        build_dates.data = jx.sort(build_dates.data, {"value": "date", "sort": -1})

        for d in build_dates.data:
            if please_stop:
                return
            agg(Date(d.date), destination, please_stop=please_stop)
    finally:
        please_stop.go()
开发者ID:klahnakoski,项目名称:TestFailures,代码行数:38,代码来源:app.py

示例6: today

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
def today():
    return int((Date.today() - ZERO_DATE).floor(DAY) / DAY)
开发者ID:klahnakoski,项目名称:MoDataSubmission,代码行数:4,代码来源:storage.py

示例7: today

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
 def today():
     return Date.today().value
开发者ID:theharshest,项目名称:alert_manager,代码行数:4,代码来源:config.py

示例8:

# 需要导入模块: from pyLibrary.times.dates import Date [as 别名]
# 或者: from pyLibrary.times.dates.Date import today [as 别名]
from pyLibrary import convert
from pyLibrary.debugs import constants, startup
from pyLibrary.debugs.logs import Log
from pyLibrary.dot import Dict, set_default
from pyLibrary.env import http, big_data
from pyLibrary.env.files import File
from pyLibrary.queries.unique_index import UniqueIndex
from pyLibrary.times.dates import Date
from pyLibrary.times.durations import WEEK

RECENT = Date.today() - 1 * WEEK


blacklist = [
        'automation.py',
        'remoteautomation.py',
        'Shutdown',
        'undefined',
        'Main app process exited normally',
        'Traceback (most recent call last):',
        'Return code: 0',
        'Return code: 1',
        'Return code: 2',
        'Return code: 9',
        'Return code: 10',
        'Exiting 1',
        'Exiting 9',
        'CrashingThread(void *)',
        'libSystem.B.dylib + 0xd7a',
        'linux-gate.so + 0x424',
        'TypeError: content is null',
开发者ID:klahnakoski,项目名称:intermittents,代码行数:33,代码来源:get_data.py


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