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)
def windowWillClose_(self, notification): NSLog('windowWillClose') print "Data: " print "\n".join(self.todos) AppHelper.stopEventLoop()
def pluginStart(self): NSLog("pluginStart") try: self.doPluginStart() except: import traceback traceback.print_exc()
def tableView_setObjectValue_forTableColumn_row_(self, aTableView, anObject, aTableColumn, rowIndex): NSLog("Changed: " + self.todos[rowIndex] + " --> " + anObject) self.todos[rowIndex] = anObject self.tableView.reloadData()
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)
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)
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)
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
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
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
def tableViewSelectionDidChange_(self, notification): row = self.tableView.selectedRow() NSLog('Selected: ' + str(row))
def applicationShouldTerminateAfterLastWindowClosed_(self, sender): NSLog('applicationShouldTerminateAfterLastWindowClosed') return True
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()
def awakeFromNib(self): NSLog('awakeFromNib')
# 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()
def windowWillClose_(self, notification): NSLog('windowWillClose') AppHelper.stopEventLoop()
def pluginStart(self): NSLog("pluginStart") try: self.doPluginStart() except: # noqa: E722, B001 traceback.print_exc()
def windowDidLoad(self): NSWindowController.windowDidLoad(self) NSLog('windowDidLoad')
def pluginViewWithArguments_(cls, arguments): self = super(WebKitInterpreter, cls).alloc().initWithFrame_(NSZeroRect) NSLog("pluginViewWithArguments:") NSLog(arguments) self.arguments = arguments return self
def windowShouldClose_(self, sender): NSLog('windowShouldClose') return True