Example #1
0
    def emit(self, record: logging.LogRecord):
        message = self.format(record)
        # print('!!!', len(message), type(message), message)

        while len(message) > 1024:
            NSLog(message[:1024])
            message = message[1024:]

        NSLog(message)
Example #2
0
    def windowWillClose_(self, notification):
        NSLog('windowWillClose')

        print "Data: "
        print "\n".join(self.todos)

        AppHelper.stopEventLoop()
Example #3
0
 def pluginStart(self):
     NSLog("pluginStart")
     try:
         self.doPluginStart()
     except:
         import traceback
         traceback.print_exc()
Example #4
0
    def tableView_setObjectValue_forTableColumn_row_(self, aTableView,
                                                     anObject, aTableColumn,
                                                     rowIndex):

        NSLog("Changed: " + self.todos[rowIndex] + " --> " + anObject)

        self.todos[rowIndex] = anObject
        self.tableView.reloadData()
Example #5
0
    def applicationDidFinishLaunching_(self, _):
        NSLog("applicationDidFinishLaunching_")

        if not axapi.ax_enabled():
            NSLog("Accessibility Permissions not enabled")

            chili.ui.prompt(
                'Accessibility permissions are required for Chili to run.\n' +
                'The Security preferences will now open, Please go to "Privacy" pane and choose "Accessibility" on the left panel.\n'
                + 'Check the box next to Chili and run the app again.')
            chili.open('/System/Library/PreferencePanes/Security.prefPane')
            self.quit()

            return

        try:
            chili.load_user_settings()
        except Exception, e:
            self.alert_exception(e)
Example #6
0
    def createNewItem_(self, sender):
        item = self.item_textfield.stringValue()

        if len(item.strip()) == 0:
            return

        self.todos.append(item)
        self.tableView.reloadData()

        NSLog('createNewItem: ' + item)

        self.item_textfield.setStringValue_('')
        self.window().makeFirstResponder_(self.item_textfield)
Example #7
0
    def handleMountNotification_(self, aNotification):

        # Find the path to the just inserted volume
        path = aNotification.userInfo()["NSDevicePath"]

        for aFile in os.listdir(path):
            if readTheseFiles.match(aFile):
                # Found a readme file, try to open it using the Workspace API

                fullPath = os.path.join(path, aFile)
                success, app, _ = workspace.getInfoForFile_application_type_(fullPath)
                if not success:
                    NSLog("Failed to find application to open file %s", fullPath)
                    return
                workspace.openFile_withApplication_(fullPath, app)
Example #8
0
        def keyboardTapCallback(proxy, type_, event, refcon):
            if type_ == Quartz.kCGEventTapDisabledByTimeout & 0xffffffff:
                # event tap timed out, re-enable.
                Quartz.CGEventTapEnable(self.tap, True)
                NSLog('event tap timed out, re-enabling')
                return None

            # Convert the Quartz CGEvent into something more useful
            keyEvent = NSEvent.eventWithCGEvent_(event)
            try:
                selector = objc.selector(self.runner.call_, signature='v@:@')
                self.runner.performSelectorOnMainThread_withObject_waitUntilDone_(
                    selector, (callback, keyEvent), False)

                if should_block(keyEvent):
                    return None
            except Exception, e:
                tb = sys.exc_info()
                print ''.join(traceback.format_exception(*tb))
                print 'Exception: ' + e.message
Example #9
0
    def createNewTaskWithCalendar_title_priority_dueDate_(
            self, calendar, title, priority, dueDate):

        # Create a new CalTask object
        newTask = CalTask.task()

        # Set the calendar, title, priority and due date on the new task
        # using the parameters passed to this method
        newTask._.calendar = calendar
        newTask._.title = title
        newTask._.priority = priority
        newTask._.dueDate = dueDate

        # Save the new task to the calendar store (CalCalendarStore) and
        # return it
        res, err = CalCalendarStore.defaultCalendarStore().saveTask_error_(newTask, None)
        if res:
            return newTask

        NSLog("error:%@", err.localizedDescription())
        return None
Example #10
0
    def createNewEventWithCalendar_title_startDate_endDate_(
            self, calendar, title, startDate, endDate):

        # Create a new CalEvent object
        newEvent = CalEvent.event()

        # Set the calendar, title, start date and end date on the new event
        # using the parameters passed to this method
        newEvent._.calendar = calendar
        newEvent._.title = title
        newEvent._.startDate = startDate
        newEvent._.endDate = endDate

        # Save the new event to the calendar store (CalCalendarStore) and
        # return it
        res, err = CalCalendarStore.defaultCalendarStore(
        ).saveEvent_span_error_(newEvent, 0, None)
        if res:
            return newEvent

        NSLog("error:%@", err.localizedDescription())
        return None
Example #11
0
    def tableViewSelectionDidChange_(self, notification):
        row = self.tableView.selectedRow()

        NSLog('Selected: ' + str(row))
Example #12
0
 def applicationShouldTerminateAfterLastWindowClosed_(self, sender):
     NSLog('applicationShouldTerminateAfterLastWindowClosed')
     return True
Example #13
0
        scrollView.setHasHorizontalScroller_(False)
        scrollView.setAutoresizingMask_(NSViewWidthSizable
                                        | NSViewHeightSizable)
        contentSize = scrollView.contentSize()
        textView = NSTextView.alloc().initWithFrame_(
            ((0, 0), scrollView.contentSize()))
        textView.setMinSize_((0, contentSize.height))
        textView.setMaxSize_((FLT_MAX, FLT_MAX))
        textView.setVerticallyResizable_(True)
        textView.setHorizontallyResizable_(False)
        textView.setAutoresizingMask_(NSViewWidthSizable)

        textView.textContainer().setContainerSize_(
            (contentSize.width, FLT_MAX))
        textView.textContainer().setWidthTracksTextView_(True)

        scrollView.setDocumentView_(textView)
        self.addSubview_(scrollView)

        self.pyInterpreter = PyInterpreter.alloc().initWithTextView_(textView)

        self.pyInterpreter.interpreterLocals()["container"] = self.container()

    def objectForWebScript(self):
        return self


NSLog("loaded WebKitInterpreter")

objc.removeAutoreleasePool()
Example #14
0
 def awakeFromNib(self):
     NSLog('awakeFromNib')
Example #15
0
        # Find the path to the just inserted volume
        path = aNotification.userInfo()["NSDevicePath"]

        for aFile in os.listdir(path):
            if readTheseFiles.match(aFile):
                # Found a readme file, try to open it using the Workspace API

                fullPath = os.path.join(path, aFile)
                success, app, _ = workspace.getInfoForFile_application_type_(fullPath)
                if not success:
                    NSLog("Failed to find application to open file %s", fullPath)
                    return
                workspace.openFile_withApplication_(fullPath, app)


# Create an instance of our notification handler, and ask the workspace
# notification center to tell us when a new volume is mounted.
workspace = NSWorkspace.sharedWorkspace()
notificationCenter = workspace.notificationCenter()
notificationHandler = NotificationHandler.new()
notificationCenter.addObserver_selector_name_object_(
    notificationHandler,
    "handleMountNotification:",
    NSWorkspaceDidMountNotification,
    None,
)

NSLog("Listening for mount notifications....")
AppHelper.runConsoleEventLoop()
Example #16
0
 def windowWillClose_(self, notification):
     NSLog('windowWillClose')
     AppHelper.stopEventLoop()
Example #17
0
 def pluginStart(self):
     NSLog("pluginStart")
     try:
         self.doPluginStart()
     except:  # noqa: E722, B001
         traceback.print_exc()
Example #18
0
 def windowDidLoad(self):
     NSWindowController.windowDidLoad(self)
     NSLog('windowDidLoad')
Example #19
0
 def pluginViewWithArguments_(cls, arguments):
     self = super(WebKitInterpreter, cls).alloc().initWithFrame_(NSZeroRect)
     NSLog("pluginViewWithArguments:")
     NSLog(arguments)
     self.arguments = arguments
     return self
Example #20
0
 def windowShouldClose_(self, sender):
     NSLog('windowShouldClose')
     return True