def update(self): try: duration = parse_timedelta(self.duration_field.text) if duration.seconds < 0: raise ValueError() self.duration = duration except ValueError: alert("stop", "Invalid duration. Requires 'hour:minute:second'.") return if self.live_checkbox.value: try: end = self.manager.get_last_filetime() except IndexError: print "No _ext.fits files exist in the given directory tree." return start = end - self.duration else: try: self.time = parse_datetime(self.time_field.text) except ValueError: alert("stop", "Invalid time. Requires 'year/month/day hour:minute:second'.") return start = self.time end = start + self.duration self.manager.set_interval(start, end) self.manager.read_data() self.update_plotwindow()
def plot( self ): global option_window options = option_window.parse() if options is None: return pairs = [(frame.refs, frame.get_channels()) for frame in self.selection_frames if frame.refs and frame.get_channels()] try: psplot.plot(pairs, options) except ValueError as e: alert('stop', e.message)
def parse( self ): try: resolution = float(self.resolution_field.text) except ValueError: alert('stop', "Resolution field requires a float.") return try: frequency = float(self.frequency_field.text) except ValueError: alert('stop', "Frequency field requires a float.") return try: start,stop,step = [int(x) for x in self.slice_field.text.split(':')] except ValueError: alert('stop', "Range field requires start:stop:step, e.g. 50:1000:10 to plot every tenth sample from the fiftieth to thousandth") return detrending = self.detrending_group.value windowing = self.windowing_group.value xscale = ('log' if self.xscale_box.value else 'linear') yscale = ('log' if self.yscale_box.value else 'linear') sqrt = self.sqrt_box.value against_time = self.against_time_box.value return { 'resolution':resolution, 'frequency':frequency, 'detrending':detrending, 'xscale':xscale, 'yscale':yscale, 'sqrt':sqrt, 'against_time':against_time, 'windowing':windowing, 'slice':slice(start,stop,step)}
def printComments(comments): for user, comment in comments: print(user + " says...") print(comment) printLine() gameID = input("Enter your game id: ") comments = getExtracted(gameID) printComments(comments) noOfComments = len(comments) print("\n\n\n" + str(noOfComments) + " comments in total.") time = int(input("How often should I check for more (seconds)? ")) Application() while (True): print(".", end="", flush=True) sleep(time) comments = getExtracted(gameID) if (len(comments) > noOfComments): numberOfNew = noOfComments - len(comments) new = comments[numberOfNew:] alert('note', 'New Comment!') print("\n****** NEW COMMENTS ******") printLine() printComments(new) noOfComments = len(comments)
def do_alert(): alert(the_kind(), "The pudding factory is haunted.")
for user, comment in comments: print(user + " says...") print(comment) printLine() gameID = input("Enter your game id: ") comments = getExtracted(gameID) printComments(comments) noOfComments = len(comments) print("\n\n\n" + str(noOfComments) + " comments in total.") time = int(input("How often should I check for more (seconds)? ")) Application() while(True): print(".",end="",flush=True) sleep(time) comments = getExtracted(gameID) if (len(comments) > noOfComments): numberOfNew = noOfComments - len(comments) new = comments[numberOfNew:] alert('note', 'New Comment!') print("\n****** NEW COMMENTS ******") printLine() printComments(new) noOfComments = len(comments)