• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sanetime.time函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sanetime.time函数的典型用法代码示例。如果您正苦于以下问题:Python time函数的具体用法?Python time怎么用?Python time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: possibly_sharded

    def possibly_sharded(self):
        if self.completed_at: return None
        if self.accountsyncshard_set.filter(completed_at__isnull=True).count(): return None

        now = time()
        locked = (self.__class__.objects.filter(id=self.id, sharded_at__isnull=True).update(sharded_at=now) == 1)
        if not locked: return None
        self.sharded_at = now

        from webinars_web.webinars import models as wm
        with wm.EventSync.delayed as d:
            now = time()
            for event in self.account.event_set.filter(deleted_at__isnull=True, current_sync__isnull=True, mothballed=False).select_related('account'):
                d.insert(dict(event_id=event.id, parent_id=self.id, visible=self.visible, debug=self.debug, created_at=now.us))
        from django.db import transaction
        transaction.commit_unless_managed()
        event_syncs = wm.EventSync.objects.filter(parent=self, event__account=self.account)
        if not self.debug:
            tasks = []
            for es in event_syncs:
                url = '%s%s'%(settings.APP_URL,es.kickoff_path)
                uid = 'event_sync|kickoff|%s'%es.id
                qid = es.event.account_id % settings.NUM_QUEUES
                logging.debug('TQDEBUG: qid id %s' % qid)
                tasks.append(Task(queue=settings.TASK_QUEUES[qid], url=url, method='POST', uid=uid))
            Task._enqueue(tasks)
            
        self.possibly_done()
开发者ID:godesomesh,项目名称:webinars,代码行数:28,代码来源:account_sync.py


示例2: clean_starts_at_ndt

 def clean_starts_at_ndt(self):
     if not self.kwargs_instance or not self.kwargs_instance.account.is_gtw:
         tz = self.kwargs_instance and self.kwargs_instance.starts_at.tz or self.hub.timezone
         st = time(self.cleaned_data['starts_at_ndt'], tz)
         if time() > st:
             raise ValidationError("This is in the past!")
     return self.cleaned_data['starts_at_ndt']
开发者ID:godesomesh,项目名称:webinars,代码行数:7,代码来源:event.py


示例3: get_today_local_noon_dt

def get_today_local_noon_dt(my_tz_name):
    """
    Given a timezone, get a sanetime object representing today's noon in that timezone.
    """
    now_dt = time(tz=my_tz_name)
    local_noon_dt = time(now_dt.year, now_dt.month, now_dt.day, 12, 0, 0, 0, tz=my_tz_name)
    return local_noon_dt
开发者ID:georgedorn,项目名称:share2grandma,代码行数:7,代码来源:utils.py


示例4: test_attendees

 def test_attendees(self):
     w = Webinar(self.organizer, key=2394, timezone='America/New_York', sessions=[])
     s = Session(w, key=6043, started_at=time('2012-06-01'), attendees=[])
     a1 = Registrant(webinar=w, session=s, key=9583, first_name=u'J\u00f6hn', last_name=u'Smith', email=u'[email protected]', viewings=[(time('4/1/11 12:01'), time('4/1/11 12:22'))])
     a2 = Registrant(webinar=w, session=s, key=2305, first_name=u'Suzy', last_name=u'Samwell', email=u'[email protected]', viewings=[(time('4/1/11 12:02'), time('4/1/11 12:07')),(time('4/1/11 12:12'), time('4/1/11 12:17')),(time('4/1/11 12:22'), time('4/1/11 12:27'))])
     with mocker(GetAttendees, text=self.attendees_json):
         session = Session(w, key=6043, started_at=time('2012-06-01'))
         self.assertEquals([a1,a2], session.attendees)
开发者ID:prior,项目名称:gtwpy,代码行数:8,代码来源:test_session.py


示例5: test_sleep

 def test_sleep(self):
     t1 = time()
     t2 = time()
     self.assertTrue(t2-t1 < delta(ms=10))
     t1 = time()
     delta(ms=10).sleep()
     t2 = time()
     self.assertTrue(t2-t1 >= delta(ms=10))
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py


示例6: __init__

 def __init__(self, start, delta=None, end=None):
     super(SaneSpan,self).__init__()
     self.start = time(start)
     if delta is None:
         end = time(end or 0)
         self.start = min(self.start,end)
         self.delta = end-self.start
     else:
         self.delta = delta
开发者ID:Mondego,项目名称:pyreco,代码行数:9,代码来源:allPythonContent.py


示例7: test_hashability

 def test_hashability(self):
     t1 = time(JAN_MICROS, tz='UTC')
     t2 = time(JAN_MICROS, tz='America/New_York')
     t3 = time(JAN_MICROS+1)
     s = set([t1,t2,t3])
     self.assertEquals(2, len(s))
     self.assertIn(t1, s)
     self.assertIn(t2, s)
     self.assertIn(t3, s)
开发者ID:Mondego,项目名称:pyreco,代码行数:9,代码来源:allPythonContent.py


示例8: test_registrants

 def test_registrants(self):
     w = Webinar(self.organizer, key=2394, timezone='America/New_York', sessions=[])
     s = Session(w, key=6043, started_at=time('2012-06-01'), attendees=[])
     r1 = Registrant(webinar=w, session=s, key=9583, first_name=u'J\u00f6hn', last_name=u'Smith', email=u'[email protected]', registered_at='5/1/12 18:01', join_url='http://bit.ly/482024', status='APPROVED', viewings=[(time('4/1/11 12:01'), time('4/1/11 12:22'))])
     r2 = Registrant(webinar=w, session=s, key=2305, first_name=u'Suzy', last_name=u'Samwell', email=u'[email protected]', registered_at='5/2/12 18:02', join_url='http://bit.ly/8592932', status='APPROVED', viewings=[(time('4/1/11 12:02'), time('4/1/11 12:07')),(time('4/1/11 12:12'), time('4/1/11 12:17')),(time('4/1/11 12:22'), time('4/1/11 12:27'))])
     r3 = Registrant(webinar=w, session=s, key=4203, first_name=u'Todd', last_name=u'Kells', email=u'[email protected]', registered_at='5/3/12 18:03', join_url='http://bit.ly/9293842', status='WAITING', viewings=[])
     with mocker(GetAttendees, text=self.attendees_json):
         with mocker(GetRegistrations, text=self.registrants_json):
             session = Session(w, key=6043, started_at=time('2012-06-01'))
             self.assertEquals([r1,r2,r3], session.registrants)
开发者ID:prior,项目名称:gtwpy,代码行数:10,代码来源:test_session.py


示例9: calc_hashcode

 def calc_hashcode(kls, **kwargs):
     key = mget(kwargs,'remote_id', 'session_key', 'universal_key')
     if key: 
         source = key
     else:
         title = mget(kwargs,'title','subject')
         us_starts_at = kwargs.get('_time_starts_at',kwargs.get('starts_at',time(0)).us)
         us_ends_at = kwargs.get('_time_ends_at',kwargs.get('ends_at',time(0)).us)
         source = '%s|%s|%s'%(title,us_starts_at,us_ends_at)
     return int(int(hashlib.md5(source).hexdigest(),16)%2**31)
开发者ID:godesomesh,项目名称:webinars,代码行数:10,代码来源:event.py


示例10: lock

 def lock(self, timeout=None, poll_rate=None): # poll_rate & timeout as deltas or micros
     timeout = ndelta(timeout) or self.timeout or delta(0)
     poll_rate = ndelta(poll_rate) or self.poll_rate
     start = time()
     while not self._attempt_lock():
         if poll_rate:
             poll_rate.sleep()
         if time() > start + timeout: 
             break
     return self.locked
开发者ID:prior,项目名称:grabbag,代码行数:10,代码来源:os.py


示例11: test_universal_key

 def test_universal_key(self):
     w = Webinar(self.organizer, key=4918, timezone='America/New_York', sessions=[])
     sa = Session(w, key=2058, started_at=time('2012-06-01'))
     sb = Session(w, key=2023, started_at=time('2012-06-02'))
     sc = Session(w, key=2084, started_at=time('2012-06-03'))
     w.sessions.append(sa)
     w.sessions.append(sb)
     w.sessions.append(sc)
     self.assertEquals('4918-1', sa.universal_key)
     self.assertEquals('4918-2', sb.universal_key)
     self.assertEquals('4918-3', sc.universal_key)
开发者ID:prior,项目名称:gtwpy,代码行数:11,代码来源:test_session.py


示例12: random

 def random(kls, account, count=None):
     events = []
     for i in xrange(count or 1):
         guid = ''.join(str(uuid.uuid4()).split('-'))
         now = time(s=time().s,tz='America/New_York')
         events.append( Event(
                 account, 
                 title = u'unittest #%s &<>\xfc\u2603 ' % guid[:16],
                 description = u'#%s:  An event created by unittests.  If you\'re seeing this, then something went wrong.  All events created by unittests are immediately cleaned up. &<>\xfc\u2603 ' % guid,
                 starts_at = now+15*60*10**6,
                 ends_at = now+30*60*10**6))
     return count is None and events[0] or events
开发者ID:prior,项目名称:webexpy,代码行数:12,代码来源:event.py


示例13: test_arithmetic

    def test_arithmetic(self):
        t1 = time(JAN_MICROS)
        t2 = time(JAN_MICROS+1)

        self.assertEquals(t2.us, (t1+1).us)
        self.assertEquals(t1.us,(t2-1).us)

        self.assertEquals(1, t2 - t1)
        self.assertEquals(-1, t1 - t2)

        self.assertEquals(t1.us,t1*1)
        self.assertEquals(t1.us,t1/1)
开发者ID:Mondego,项目名称:pyreco,代码行数:12,代码来源:allPythonContent.py


示例14: get_fresh_last_modified_at

def get_fresh_last_modified_at(hub, guid):
    leads_client = hapi.leads.LeadsClient(settings.HUBSPOT_API_KEY, hub_id=hub.id, env=settings.API_ENV)
    leads = leads_client.get_leads(
            time_pivot = 'lastModifiedAt',
            sort = 'lastModifiedAt',
            dir = 'desc',
            max = 1,
            form_guid = guid)
    if leads:
        return time(us=leads[0]['lastModifiedAt']*1000 + 1000)
    else:
        return time(0)
开发者ID:godesomesh,项目名称:webinars,代码行数:12,代码来源:events.py


示例15: test_switching_timezones

 def test_switching_timezones(self):
     t1 = time(JAN_MICROS)
     self.assertEquals(pytz.timezone('America/New_York'), t1.with_tz('America/New_York').tz)
     self.assertEquals(t1, time(t1).set_tz('America/New_York'))
     self.assertEquals(t1, t1.with_tz('America/New_York'))
     self.assertNotEquals(t1.tz, time(t1).set_tz('America/New_York').tz)
     self.assertNotEquals(t1.tz, t1.with_tz('America/New_York').tz)
     self.assertEquals(pytz.timezone('America/New_York'), time(t1).set_tz('America/New_York').tz)
     self.assertEquals(pytz.timezone('America/New_York'), t1.with_tz('America/New_York').tz)
     t1_id = id(t1)
     self.assertEquals(t1_id, id(t1.set_tz('America/New_York')))
     self.assertNotEquals(t1_id, id(t1.with_tz('America/New_York')))
开发者ID:Mondego,项目名称:pyreco,代码行数:12,代码来源:allPythonContent.py


示例16: test_max_timing

 def test_max_timing(self):  # against all known accounts, and all their events:
     from pprint import pprint
     max_info = (None, 0)
     for k in self.th._accounts_dict.keys():
         pprint(self.th[k])
         for e in self.th[k].events:
             started = time()
             registrants = e.registrants
             elapsed = (time()-started).s
             if elapsed > max_info[1]: 
                 max_info = ("%s %s %s %s" % (e.account.site_name, e.session_key, e.title, len(registrants)), elapsed)
                 print max_info
     print max_info
开发者ID:prior,项目名称:webexpy,代码行数:13,代码来源:test_registrant.py


示例17: test_huge_crud

 def test_huge_crud(self):
     size = 3000
     event = Event.random(self.account).create()
     registrants = dict((r.email,r) for r in Registrant.random(event, size))
     start = time()
     expected = dict((r.email,r) for r in event.create_registrants(registrants.values()))
     after_create = time()
     actual = dict((r.email,r) for r in event.general_registrants)
     after_listing = time()
     self.assertEquals(registrants, expected)
     self.assertEquals(expected, actual)
     self.assertEquals(size, len(expected))
     print "\nCREATE TIMING: %sms\nLISTING TIMING: %sms" % ((after_create-start).ms, (after_listing-after_create).ms,)
开发者ID:prior,项目名称:webexpy,代码行数:13,代码来源:test_registrant.py


示例18: setUp

    def setUp(self):
        self.userdata = {'username':'xenuuu',
                         'password':'test_pass'}

        self.user = User.objects.create_user(**self.userdata)
        self.user = User.objects.get_by_natural_key('xenuuu')
        
        self.recipient = Recipient.objects.create(sender=self.user,
                                                  sender_name='bob',
                                                  sender_phone='000-000-0000',
                                                  name='granny',
                                                  email='[email protected]',
                                                  timezone='America/Los_Angeles'
                                                )
        self.subscription = TumblrSubscription.objects.create(recipient=self.recipient,
                                                              short_name='bobs_monkeys',
                                                              pretty_name="Bob's Monkey Photos",
                                                              avatar='monkey.jpg') #supplying all fields to avoid call to tumblr

        start_dt = time() - delta(hours=1 * 7 * 24)
        end_dt = time() + delta(hours=1 * 7 * 24)
        self.vacation = Vacation.objects.create(recipient=self.recipient,
                                                start_date=start_dt.datetime,
                                                end_date=end_dt.datetime
                                                )

        #urls of things that require you to be logged in to access        
        self.login_required_urls = [
                               reverse_lazy('subscription_create_tumblr'),
                               reverse_lazy('subscription_list'),
                               reverse_lazy('subscription_detail_tumblr', kwargs={'pk':self.subscription.pk}),
                               reverse_lazy('subscription_delete_tumblr', kwargs={'pk':self.subscription.pk}),
                               reverse_lazy('recipient_create'),
                               reverse_lazy('recipient_detail', kwargs={'pk':self.recipient.pk}),
                               reverse_lazy('vacation_create', kwargs={'recipient_id':self.recipient.pk}),
                               reverse_lazy('vacation_cancel', kwargs={'pk':self.vacation.pk})

                               #todo:  delete the recipient
                       
                       ]
        
        #urls of things that you must own the object in question (or a related one) in order to access.
        #these will just be tested by being logged in as a user other than xenuuu
        self.ownership_required_urls = [
                               reverse_lazy('subscription_detail_tumblr', kwargs={'pk':self.subscription.pk}),
                               reverse_lazy('subscription_delete_tumblr', kwargs={'pk':self.subscription.pk}),
                               reverse_lazy('recipient_detail', kwargs={'pk':self.recipient.pk}),
                               reverse_lazy('vacation_create', kwargs={'recipient_id':self.recipient.pk}),
                               reverse_lazy('vacation_cancel', kwargs={'pk':self.vacation.pk})
                               ]
        self.login_url = reverse('auth_login')
开发者ID:georgedorn,项目名称:share2grandma,代码行数:51,代码来源:views.py


示例19: get_id

def get_id(timezone_label):
    if timezone_label in PYTZ_LABEL_TO_WEBEX_TIMEZONE_ID_MAP:
        return PYTZ_LABEL_TO_WEBEX_TIMEZONE_ID_MAP[timezone_label]

    us = time().us
    dt = time(us).naive_datetime
    st = time(dt, tz=timezone_label)
    for tuple_ in TIMEZONE_DATA:
        for pytz_label in tuple_[2:]:
            testing_st = time(dt, tz=pytz_label)
            if st == testing_st:
                PYTZ_LABEL_TO_WEBEX_TIMEZONE_ID_MAP[timezone_label] = webex_timezone_id
                break
    return PYTZ_LABEL_TO_WEBEX_TIMEZONE_ID_MAP.get(timezone_label)
开发者ID:prior,项目名称:webexpy,代码行数:14,代码来源:timezone.py


示例20: test_viewings

 def test_viewings(self):
     event = Event.random(self.account)
     r = Registrant(event, email="[email protected]")
     self.assertIsNone(r.started_at)
     self.assertIsNone(r.stopped_at)
     self.assertIsNone(r.duration_in_minutes)
     r.merge(Registrant(event, email="[email protected]", viewings=[[time(s=60*10),time(s=60*30)]]))
     self.assertEquals(60*10, r.started_at.s)
     self.assertEquals(60*30, r.stopped_at.s)
     self.assertEquals(20, r.duration_in_minutes)
     r.merge(Registrant(event, email="[email protected]", viewings=[[time(s=60*50),time(s=60*55)]]))
     self.assertEquals(60*10, r.started_at.s)
     self.assertEquals(60*55, r.stopped_at.s)
     self.assertEquals(45, r.duration_in_minutes)
开发者ID:prior,项目名称:webexpy,代码行数:14,代码来源:test_registrant.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sanguo.Sanguo类代码示例发布时间:2022-05-27
下一篇:
Python sandesh_http.SandeshHttp类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap