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


Python NSDate.distantFuture方法代码示例

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


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

示例1: _nestedRunLoopReaderUntilEOLchars_

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
    def _nestedRunLoopReaderUntilEOLchars_(self, eolchars):
        """
        This makes the baby jesus cry.

        I want co-routines.
        """
        app = NSApplication.sharedApplication()
        window = self.textView.window()
        self.setCharacterIndexForInput_(self.lengthOfTextView())
        # change the color.. eh
        self.textView.setTypingAttributes_(
            {NSFontAttributeName: self.font(), NSForegroundColorAttributeName: self.codeColor()}
        )
        while True:
            event = app.nextEventMatchingMask_untilDate_inMode_dequeue_(
                NSUIntegerMax, NSDate.distantFuture(), NSDefaultRunLoopMode, True
            )
            if (event.type() == NSKeyDown) and (event.window() == window):
                eol = event.characters()
                if eol in eolchars:
                    break
            app.sendEvent_(event)
        cl = self.currentLine()
        if eol == "\r":
            self.writeCode_("\n")
        return cl + eol
开发者ID:shikil,项目名称:PyInterpreter,代码行数:28,代码来源:main2.py

示例2: softwareupdated_installhistory

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
def softwareupdated_installhistory(start_date=None, end_date=None):
    '''Returns softwareupdated items from InstallHistory.plist that are
    within the given date range. (dates must be NSDates)'''
    start_date = start_date or NSDate.distantPast()
    end_date = end_date or NSDate.distantFuture()
    try:
        installhistory = FoundationPlist.readPlist(INSTALLHISTORY_PLIST)
    except FoundationPlist.FoundationPlistException:
        return []
    return [item for item in installhistory
            if item.get('processName') == 'softwareupdated'
            and item['date'] >= start_date and item['date'] <= end_date]
开发者ID:munki,项目名称:munki,代码行数:14,代码来源:au.py

示例3: waituntil

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
def waituntil(conditionfunc, timeout=None):
    """
    Waits until conditionfunc() returns true, or <timeout> seconds have passed.
    (If timeout=None, this waits indefinitely until conditionfunc() returns
    true.) Returns false if the process timed out, otherwise returns true.

    Note!! You must call interruptwait() when you know that conditionfunc()
    should be checked (e.g. if you are waiting for data and you know some data
    has arrived) so that this can check conditionfunc(); otherwise it will just
    continue to wait. (This allows the function to wait for an event that is
    sent by interruptwait() instead of polling conditionfunc().)

    This allows the caller to wait while the main event loop processes its
    events. This must be done for certain situations, e.g. to receive socket
    data or to accept client connections on a server socket, since IOBluetooth
    requires the presence of an event loop to run these operations.

    This function doesn't need to be called if there is something else that is
    already processing the main event loop, e.g. if called from within a Cocoa
    application.
    """
    app = NSApplication.sharedApplication()
    starttime = time.time()
    if timeout is None:
        timeout = NSDate.distantFuture().timeIntervalSinceNow()
    if not isinstance(timeout, (int, float)):
        raise TypeError("timeout must be int or float, was %s" % \
                type(timeout))
    endtime = starttime + timeout
    while True:
        currtime = time.time()
        if currtime >= endtime:
            return False
        # use WAIT_MAX_TIMEOUT, don't wait forever in case of KeyboardInterrupt
        e = app.nextEventMatchingMask_untilDate_inMode_dequeue_(NSAnyEventMask, NSDate.dateWithTimeIntervalSinceNow_(min(endtime - currtime, WAIT_MAX_TIMEOUT)), NSDefaultRunLoopMode, True)
        if e is not None:
            if (e.type() == NSApplicationDefined and e.subtype() == LIGHTBLUE_NOTIFY_ID):
                if conditionfunc():
                    return True
            else:
                app.postEvent_atStart_(e, True)
开发者ID:640Labs,项目名称:lightblue-0.4,代码行数:43,代码来源:_macutil.py

示例4: Application

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
    NSKeyDown, NSKeyUp, NSMouseMoved, NSLeftMouseDown, NSSystemDefined, \
    NSCommandKeyMask, NSPasteboard, NSStringPboardType, NSModalPanelRunLoopMode
NSAnyEventMask = 0xffffffff
from GUI import Globals, GApplications
from GUI import application, export
from GUI.GApplications import Application as GApplication
from GUI import Event

#------------------------------------------------------------------------------

Globals.ns_screen_height = None
Globals.ns_last_mouse_moved_event = None
Globals.pending_exception = None
Globals.ns_application = None

ns_distant_future = NSDate.distantFuture()

#------------------------------------------------------------------------------

class Application(GApplication):
    #  _ns_app          _PyGui_NSApplication
    #  _ns_pasteboard   NSPasteboard
    #  _ns_key_window   Window
    
    _ns_menubar_update_pending = False
    _ns_files_opened = False
    _ns_using_clargs = False
    _ns_menus_updated = False

    def __init__(self, **kwds):
        self._ns_app = Globals.ns_application
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:33,代码来源:Application.py

示例5: check_if_running

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
def check_if_running(username):
    """ checks if self-control is already running. """
    defaults = get_selfcontrol_settings(username)
    return defaults.has_key("BlockStartedDate") and not NSDate.distantFuture().isEqualToDate_(
        defaults["BlockStartedDate"]
    )
开发者ID:andreasgrill,项目名称:auto-selfcontrol,代码行数:8,代码来源:auto-selfcontrol.py

示例6: check_if_running

# 需要导入模块: from Foundation import NSDate [as 别名]
# 或者: from Foundation.NSDate import distantFuture [as 别名]
def check_if_running(username):
    """ checks if self-control is already running and stops auto-selfcontrol if so. """
    defaults = get_selfcontrol_settings(username)
    if not NSDate.distantFuture().isEqualToDate_(defaults["BlockStartedDate"]):
        syslog.syslog(syslog.LOG_ALERT, "SelfControl is already running, ignore current execution of Auto-SelfControl.")
        exit(2)
开发者ID:slambert,项目名称:auto-selfcontrol,代码行数:8,代码来源:auto-selfcontrol.py


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