def startLoops(self): # Timers for taking screenshots when idle, and showing experience-sample window s = objc.selector(self.runMaxScreenshotLoop,signature='v@:') self.screenshotTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(self.screenshot_time_max, self, s, None, False) s = objc.selector(self.runExperienceLoop,signature='v@:') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(self.exp_time, self, s, None, False) # Timer for checking if thumbdrive/memory card is available s = objc.selector(self.defineCurrentDrive,signature='v@:') self.thumbdriveTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(self.thumbdrive_time, self, s, None, True) self.thumbdriveTimer.fire() # get location immediately
def startLoops(self): # Timers for taking screenshots when idle, and showing experience-sample window s = objc.selector(self.runMaxScreenshotLoop, signature='v@:') self.screenshotTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.screenshot_time_max, self, s, None, False) s = objc.selector(self.runExperienceLoop, signature='v@:') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.exp_time, self, s, None, False) # Timer for checking if thumbdrive/memory card is available s = objc.selector(self.defineCurrentDrive, signature='v@:') self.thumbdriveTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.thumbdrive_time, self, s, None, True) self.thumbdriveTimer.fire() # get location immediately
def toggleAudioPlay_(self, sender): try: if self.playingAudio: self.playingAudio = False s = NSAppleScript.alloc().initWithSource_( "tell application \"QuickTime Player\" \n stop the front document \n close the front document \n end tell" ) s.executeAndReturnError_(None) self.reviewController.playAudioButton.setTitle_("Play Audio") else: self.playingAudio = True s = NSAppleScript.alloc().initWithSource_( "set filePath to POSIX file \"" + self.audio_file + "\" \n tell application \"QuickTime Player\" \n open filePath \n tell application \"System Events\" \n set visible of process \"QuickTime Player\" to false \n repeat until visible of process \"QuickTime Player\" is false \n end repeat \n end tell \n play the front document \n end tell" ) s.executeAndReturnError_(None) audio = mutagen.mp4.MP4(self.audio_file) length = audio.info.length s = objc.selector(self.stopAudioPlay, signature='v@:') self.audioTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( length, self, s, None, False) self.reviewController.playAudioButton.setTitle_("Stop Audio") except: showAlert( "Problem playing audio. Please delete audio file and try again." )
def initWithDocument_andConfig_(self, document, config): self = super(LLDBPlugin, self).initWithDocument_andConfig_(document, config) # setup debugger self.debugger = lldb.SBDebugger.Create() self.debugger.SetAsync(True) self.debugger.SetTerminalWidth( 80) # XXX: should really be set in resize handler self.interpreter = self.debugger.GetCommandInterpreter() self.listener = self.debugger.GetListener() self.listener.StartListeningForEvents( self.interpreter.GetBroadcaster(), lldb.SBCommandInterpreter.eBroadcastBitThreadShouldExit | lldb.SBCommandInterpreter.eBroadcastBitResetPrompt | lldb.SBCommandInterpreter.eBroadcastBitQuitCommandReceived | lldb.SBCommandInterpreter.eBroadcastBitAsynchronousOutputData | lldb.SBCommandInterpreter.eBroadcastBitAsynchronousErrorData) self.event_timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( 0.05, self, '_event_handler', None, YES) loop = NSRunLoop.currentRunLoop() loop.addTimer_forMode_(self.event_timer, NSDefaultRunLoopMode) self.first_stop = True self.launch_info = None return self
def imageGrowLoop(self): img = self.samples[self.currentSample]['screenshot'][:] path = os.path.join(self.datadrive, "screenshots", self.samples[self.currentSample]['screenshot']) cueImage = NSImage.alloc().initByReferencingFile_(path) max_height = min(cueImage.size().height, self.viewH) if(self.cueH <= max_height-20 and self.growImage): print 'increasing size' self.cueH = self.cueH + 20 self.cueW = self.cueH * self.cueRatio targetImage = NSImage.alloc().initWithSize_(NSMakeSize(self.cueW, self.cueH)) if(self.samples[self.currentSample]['snippet']): x = float(path.split("_")[-2]) y = float(path.split("_")[-1].split('-')[0].split('.')[0]) fromRect = CG.CGRectMake(x-self.cueW/2, y-self.cueH/2, self.cueW, self.cueH) toRect = CG.CGRectMake(0.0, 0.0, self.cueW, self.cueH) else: fromRect = CG.CGRectMake(0.0, 0.0, cueImage.size().width, cueImage.size().height) toRect = CG.CGRectMake(0.0, 0.0, self.cueW, self.cueH) targetImage.lockFocus() cueImage.drawInRect_fromRect_operation_fraction_( toRect, fromRect, NSCompositeCopy, 1.0 ) targetImage.unlockFocus() self.reviewController.mainPanel.setImage_(targetImage) s = objc.selector(self.imageGrowLoop,signature='v@:') self.imageLoop = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(2, self, s, None, False)
def runMaxScreenshotLoop(self): self.screenshot_time_max = NSUserDefaultsController.sharedUserDefaultsController().values().valueForKey_('imageTimeMax') time_since_last_screenshot = time.time() - self.last_screenshot if (time_since_last_screenshot > self.screenshot_time_max): self.take_screenshot() time_since_last_screenshot = 0.0 sleep_time = self.screenshot_time_max - time_since_last_screenshot + 0.01 s = objc.selector(self.runMaxScreenshotLoop,signature='v@:') self.screenshotTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(sleep_time, self, s, None, False)
def runMaxScreenshotLoop(self): self.screenshot_time_max = NSUserDefaultsController.sharedUserDefaultsController( ).values().valueForKey_('imageTimeMax') time_since_last_screenshot = time.time() - self.last_screenshot if (time_since_last_screenshot > self.screenshot_time_max): self.take_screenshot() time_since_last_screenshot = 0.0 sleep_time = self.screenshot_time_max - time_since_last_screenshot + 0.01 s = objc.selector(self.runMaxScreenshotLoop, signature='v@:') self.screenshotTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( sleep_time, self, s, None, False)
def runExperienceLoop(self): experienceLoop = NSUserDefaultsController.sharedUserDefaultsController().values().valueForKey_('experienceLoop') if(experienceLoop): NSLog("Showing Experience Sampling Window on Cycle...") expController = sniffer.ExperienceController.show() expController.user_initiated = False self.last_experience = time.time() s = objc.selector(self.runExperienceLoop,signature='v@:') self.exp_time = NSUserDefaultsController.sharedUserDefaultsController().values().valueForKey_('experienceTime') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(self.exp_time, self, s, None, False)
def runExperienceLoop(self): experienceLoop = NSUserDefaultsController.sharedUserDefaultsController( ).values().valueForKey_('experienceLoop') if (experienceLoop): NSLog("Showing Experience Sampling Window on Cycle...") expController = sniffer.ExperienceController.show() expController.user_initiated = False self.last_experience = time.time() s = objc.selector(self.runExperienceLoop, signature='v@:') self.exp_time = NSUserDefaultsController.sharedUserDefaultsController( ).values().valueForKey_('experienceTime') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.exp_time, self, s, None, False)
def toggleAudioPlay_(self, sender): if self.playingAudio: self.stopAudioPlay() else: self.playingAudio = True self.debriefController.playAudioButton.setTitle_("Stop Audio") s = NSAppleScript.alloc().initWithSource_("set filePath to POSIX file \"" + self.audio_file + "\" \n tell application \"QuickTime Player\" \n open filePath \n tell application \"System Events\" \n set visible of process \"QuickTime Player\" to false \n repeat until visible of process \"QuickTime Player\" is false \n end repeat \n end tell \n play the front document \n end tell") s.executeAndReturnError_(None) # Stop playback once end of audio file is reached length = mutagen.mp4.MP4(self.audio_file).info.length s = objc.selector(self.stopAudioPlay,signature='v@:') self.playbackTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(length, self, s, None, False)
def checkExperienceOnPrefChange_(self, notification): if(self.experienceTimer): self.experienceTimer.invalidate() self.exp_time = NSUserDefaultsController.sharedUserDefaultsController().values().valueForKey_('experienceTime') time_since_last_experience = time.time() - self.last_experience experienceLoop = NSUserDefaultsController.sharedUserDefaultsController().values().valueForKey_('experienceLoop') if(experienceLoop): if (time_since_last_experience > self.exp_time): self.runExperienceLoop() else: sleep_time = self.exp_time - time_since_last_experience + 0.01 s = objc.selector(self.runExperienceLoop,signature='v@:') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(sleep_time, self, s, None, False)
def checkExperienceOnPrefChange_(self, notification): if (self.experienceTimer): self.experienceTimer.invalidate() self.exp_time = NSUserDefaultsController.sharedUserDefaultsController( ).values().valueForKey_('experienceTime') time_since_last_experience = time.time() - self.last_experience experienceLoop = NSUserDefaultsController.sharedUserDefaultsController( ).values().valueForKey_('experienceLoop') if (experienceLoop): if (time_since_last_experience > self.exp_time): self.runExperienceLoop() else: sleep_time = self.exp_time - time_since_last_experience + 0.01 s = objc.selector(self.runExperienceLoop, signature='v@:') self.experienceTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( sleep_time, self, s, None, False)
def toggleAudioPlay_(self, sender): try: if self.playingAudio: self.playingAudio = False s = NSAppleScript.alloc().initWithSource_("tell application \"QuickTime Player\" \n stop the front document \n close the front document \n end tell") s.executeAndReturnError_(None) self.reviewController.playAudioButton.setTitle_("Play Audio") else: self.playingAudio = True s = NSAppleScript.alloc().initWithSource_("set filePath to POSIX file \"" + self.audio_file + "\" \n tell application \"QuickTime Player\" \n open filePath \n tell application \"System Events\" \n set visible of process \"QuickTime Player\" to false \n repeat until visible of process \"QuickTime Player\" is false \n end repeat \n end tell \n play the front document \n end tell") s.executeAndReturnError_(None) audio = mutagen.mp4.MP4(self.audio_file) length = audio.info.length s = objc.selector(self.stopAudioPlay,signature='v@:') self.audioTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(length, self, s, None, False) self.reviewController.playAudioButton.setTitle_("Stop Audio") except: showAlert("Problem playing audio. Please delete audio file and try again.")
def imageGrowLoop(self): img = self.samples[self.currentSample]['screenshot'][:] path = os.path.join(self.datadrive, "screenshots", self.samples[self.currentSample]['screenshot']) cueImage = NSImage.alloc().initByReferencingFile_(path) max_height = min(cueImage.size().height, self.viewH) if (self.cueH <= max_height - 20 and self.growImage): print 'increasing size' self.cueH = self.cueH + 20 self.cueW = self.cueH * self.cueRatio targetImage = NSImage.alloc().initWithSize_( NSMakeSize(self.cueW, self.cueH)) if (self.samples[self.currentSample]['snippet']): x = float(path.split("_")[-2]) y = float(path.split("_")[-1].split('-')[0].split('.')[0]) fromRect = CG.CGRectMake(x - self.cueW / 2, y - self.cueH / 2, self.cueW, self.cueH) toRect = CG.CGRectMake(0.0, 0.0, self.cueW, self.cueH) else: fromRect = CG.CGRectMake(0.0, 0.0, cueImage.size().width, cueImage.size().height) toRect = CG.CGRectMake(0.0, 0.0, self.cueW, self.cueH) targetImage.lockFocus() cueImage.drawInRect_fromRect_operation_fraction_( toRect, fromRect, NSCompositeCopy, 1.0) targetImage.unlockFocus() self.reviewController.mainPanel.setImage_(targetImage) s = objc.selector(self.imageGrowLoop, signature='v@:') self.imageLoop = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( 2, self, s, None, False)
def bookmark_(self, notification): self.statusitem.setImage_(self.iconBook) NSNotificationCenter.defaultCenter().postNotificationName_object_('recordBookmark',self) s = objc.selector(self.changeIcon,signature='v@:') self.screenshotTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(3, self, s, None, False)