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


Python Arrow.utcnow方法代码示例

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


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

示例1: warn

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
def warn(page):
    now_string = Arrow.utcnow().strftime("%x %X")
    err = traceback.format_exception(*sys.exc_info())
    with open("errlog", "a") as fh:
        builtins.print(now_string, repr(page.title), ":", file=fh)
        for line in err:
            builtins.print("\t" + line.rstrip(), file=fh)
开发者ID:harej,项目名称:sigmabot,代码行数:9,代码来源:archiver.py

示例2: manual_watering

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
    def manual_watering(self, watering_request):
        # pause normal schedule
        jobs_paused = self.pause_schedule()

        start, last_duration_seconds = Arrow.utcnow(), 5
        start_buffer_seconds = 5

        # for every station, set a scheduling for the duration specified
        # stations are ran serially

        for station, duration in watering_request.items():
            station_id = int(station)
            job_start = start.replace(seconds=last_duration_seconds)

            dt = job_start.format("YYYY-MM-DDTHH:mm:ssZZ").replace("-00:00", "+00:00")
            args = {"datetime": dt, "station": station_id, "fixed_duration": duration, "manual": 1}
            self.bg_scheduler.add_job(self.water, "date", run_date=job_start.datetime, args=[args])

            last_duration_seconds = duration * 60

        # reschedule the original schedule after all stations have watered
        job_start = start.replace(seconds=last_duration_seconds + start_buffer_seconds)
        self.bg_scheduler.add_job(self.resume_schedule, "date", run_date=job_start.datetime)

        # check if schedule contains: paused jobs, manual watering jobs, and extra job to resume paused jobs
        if len(self.bg_scheduler.get_jobs()) == (jobs_paused + len(watering_request) + 1):
            return True

        return False
开发者ID:cagmz,项目名称:iSprinkle,代码行数:31,代码来源:StationControl.py

示例3: parse_stamps

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
 def parse_stamps(self, expr=STAMP_RE, fmt='%H:%M, %d %B %Y (%Z)'):
     stamps = []
     algo = self.archiver.config['algo']
     try:
         maxage = str2time(re.search(r"^old\((\w+)\)$", algo).group(1))
     except AttributeError as e:
         e.args = ("Malformed archive algorithm",)
         raise ArchiveError(e)
     for thread in self.threads:
         if mwp_parse(thread['header']).get(0).level != 2:
             # the header is not level 2
             stamps = []
             continue
         for stamp in expr.finditer(thread['content']):
             # This for loop can probably be optimised, but ain't nobody
             # got time fo' dat
             #if stamp.group(1) in MONTHS:
             try:
                 stamps.append(Arrow.strptime(stamp.group(0), fmt))
             except ValueError:  # Invalid stamps should not be parsed, ever
                 continue
         if stamps:
             # The most recent stamp should be used to see if we should archive
             most_recent = max(stamps)
             thread['stamp'] = most_recent
             thread['oldenough'] = Arrow.utcnow() - most_recent > maxage
             pass  # No stamps were found, abandon thread
         stamps = []
开发者ID:harej,项目名称:sigmabot,代码行数:30,代码来源:archiver.py

示例4: utcnow

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
def utcnow():
    '''Returns an :class:`Arrow <arrow.Arrow>` object, representing "now" in UTC time.

    Usage::

        >>> import arrow
        >>> arrow.utcnow()
        <Arrow [2013-05-08T05:19:07.018993+00:00]>
    '''

    return Arrow.utcnow()
开发者ID:gurglet,项目名称:arrow,代码行数:13,代码来源:api.py

示例5: route_planner

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
def route_planner(point_list, start_point, start_time=None):
    """
    根据选出的景点进行计划规划,本模块的核心函数
    :param point_list: ScenicPoint类型的数组
    :param start_point: ScenicPoint类型的实例
    :return: TourPlan类型实例数组
    """
    if not start_time:
        start_time = Arrow.utcnow()
    pls = _gen_seq(point_list, start_point)
    route_mat = get_route_matrix(pls[0][:-1])
    for p_seq in pls:
        plan = TourPlan(start_time, p_seq)
        cost = _calc_plan_cost(plan, route_mat)
开发者ID:JayveeHe,项目名称:ProjectNavigator,代码行数:16,代码来源:tour_planner.py

示例6: nation_query

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
 def nation_query(self, variable='A020101', start_year='1949', rowcode='zb', colcode='sj'):
     wds = StatsGov.to_url_str([{'wdcode': rowcode, 'valuecode': variable}])
     dfwds = StatsGov.to_url_str([{'wdcode': colcode, 'valuecode': ''.join([start_year, '-'])}])
     retrive_url = self._stats_gov_url_template.format('QueryData', 'hgnd', rowcode, colcode, wds, dfwds)
     r = requests.get(retrive_url)
     return StatsGov.json_to_data(r.json(), condition={'zb':variable,'sj':range(int(start_year),Arrow.utcnow().year+1)})
开发者ID:plutoese,项目名称:webscraper,代码行数:8,代码来源:class_statgov.py

示例7: get

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
def get(*args, **kwargs):
    '''Returns an :class:`Arrow <arrow.Arrow>` object based on flexible inputs.

    Usage::

        >>> import arrow

    **No inputs** to get current UTC time::

        >>> arrow.get()
        <Arrow [2013-05-08T05:51:43.316458+00:00]>

    **One str**, **float**, or **int**, convertible to a floating-point timestamp, to get that timestamp in UTC::

        >>> arrow.get(1367992474.293378)
        <Arrow [2013-05-08T05:54:34.293378+00:00]>

        >>> arrow.get(1367992474)
        <Arrow [2013-05-08T05:54:34+00:00]>

        >>> arrow.get('1367992474.293378')
        <Arrow [2013-05-08T05:54:34.293378+00:00]>

        >>> arrow.get('1367992474')
        <Arrow [2013-05-08T05:54:34+00:00]>

    **One str**, convertible to a timezone, or **tzinfo**, to get the current time in that timezone::

        >>> arrow.get('local')
        <Arrow [2013-05-07T22:57:11.793643-07:00]>

        >>> arrow.get('US/Pacific')
        <Arrow [2013-05-07T22:57:15.609802-07:00]>

        >>> arrow.get('-07:00')
        <Arrow [2013-05-07T22:57:22.777398-07:00]>

        >>> arrow.get(tz.tzlocal())
        <Arrow [2013-05-07T22:57:28.484717-07:00]>

    **One** naive **datetime**, to get that datetime in UTC::

        >>> arrow.get(datetime(2013, 5, 5))
        <Arrow [2013-05-05T00:00:00+00:00]>

    **One** aware **datetime**, to get that datetime::

        >>> arrow.get(datetime(2013, 5, 5, tzinfo=tz.tzlocal()))
        <Arrow [2013-05-05T00:00:00-07:00]>

    **Two** arguments, a naive or aware **datetime**, and a timezone expression (as above)::

        >>> arrow.get(datetime(2013, 5, 5), 'US/Pacific')
        <Arrow [2013-05-05T00:00:00-07:00]>

    **Two** arguments, both **str**, to parse the first according to the format of the second::

        >>> arrow.get('2013-05-05 12:30:45', 'YYYY-MM-DD HH:mm:ss')
        <Arrow [2013-05-05T12:30:45+00:00]>

    **Three or more** arguments, as for the constructor of a **datetime**::

        >>> arrow.get(2013, 5, 5, 12, 30, 45)
        <Arrow [2013-05-05T12:30:45+00:00]>
    '''

    arg_count = len(args)

    if arg_count == 0:
        return Arrow.utcnow()

    if arg_count == 1:
        arg = args[0]
        timestamp = None

        try:
            timestamp = float(arg)
        except:
            pass

        # (int), (float), (str(int)) or (str(float)) -> from timestamp.
        if timestamp is not None:
            return Arrow.utcfromtimestamp(timestamp)

        # (datetime) -> from datetime.
        elif isinstance(arg, datetime):
            return Arrow.fromdatetime(arg)

        # (tzinfo) -> now, @ tzinfo.
        elif isinstance(arg, tzinfo):
            return Arrow.now(arg)

        # (str) -> now, @ tzinfo.
        elif isinstance(arg, str):
            _tzinfo = parser.TzinfoParser.parse(arg)
            return Arrow.now(_tzinfo)

        else:
            raise TypeError('Can\'t parse single argument type of \'{0}\''.format(type(arg)))

#.........这里部分代码省略.........
开发者ID:gurglet,项目名称:arrow,代码行数:103,代码来源:api.py

示例8: timedelta

# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import utcnow [as 别名]
from datetime import timedelta
from ceterach.api import MediaWiki
from ceterach.page import Page
from ceterach import exceptions as exc
from passwords import lcsb3

import mwparserfromhell as mwp

API_URL = "https://en.wikipedia.org/w/api.php"
LOGIN_INFO = "Lowercase sigmabot III", lcsb3
SHUTOFF = "User:Lowercase sigmabot III/Shutoff"
ARCHIVE_TPL = "User:MiszaBot/config"

locale.setlocale(locale.LC_ALL, "en_US.utf8")
STAMP_RE = re.compile(r"\d\d:\d\d, \d{1,2} (\w*?) \d\d\d\d \(UTC\)")
THE_FUTURE = Arrow.utcnow() + timedelta(365)
MONTHS = (None, "January", "February", "March", "April", "May", "June",
          "July", "August", "September", "October", "November", "December"
)


class ArchiveError(exc.CeterachError):
    """Generic base class for archive exceptions"""


class ArchiveSecurityError(ArchiveError):
    """Archive is not a subpage of page being archived and key not specified
    (or incorrect)."""


if True:
开发者ID:harej,项目名称:sigmabot,代码行数:33,代码来源:archiver.py


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