def stage_changes(self, players): ''' Stage a player to an save file ''' load_file = utils.readJSON(self.saves_file) while players: player = players.pop() if not load_file or player not in load_file.keys(): json_obj = { player.telegram_id: { 'username': player.username, 'achievements': player.achievements, 'main_title': player.main_title, 'level': player.level, 'points': player.points, 'titles': player.titles, 'lattest_chat': player.lattest_chat } } utils.appendJSON(self.saves_file, json_obj) else: load_file[player.telegram_id] = { 'username': player.username, 'achievements': player.achievements, 'main_title': player.main_title, 'level': player.level, 'points': player.points, 'titles': player.titles, 'lattest_chat': player.lattest_chat } utils.writeJSON(load_file, self.saves_file)
def initCluster(self): # given the list of node to start with, construct a cluster # cleans junk from config # cleans leader/clients , leader/relation, leader/workers, cluster confType = self.leaderConfig["@name"] self.leaderConfig[confType]["clients"] = [] self.leaderConfig[confType]["relation"] = dict() self.leaderConfig[confType]["workers"] = [] self.leaderConfig[confType]["cluster"] = "" self.leaderConfig[confType]["idle_workers"] = [] self.leaderConfig[confType]["new"] = False # resets leader/workers with host host = self.leaderConfig[confType]["host"] self.leaderConfig[confType]["workers"].append(host) # resets cluster with new cluster ID clusterId = generator.genNewId() self.leaderConfig[confType]["cluster"] = clusterId utils.writeJSON(os.path.join(self.configDir, self.configFile), self.leaderConfig) print "Leader config had be changed..." pass
def getCourses(semesters): for item in semesters: courses = [] url = "http://www.losrios.edu/schedules_reader_all.php?loc=flc/" + item["endpoint"] + "/index.html" populateCourses(courses, url) filePath = utils.getAndCreateFilePath('courses', item["endpoint"]) utils.writeJSON(courses, filePath)
def getSubjects(semesters): for item in semesters: subjects = {} url = "http://www.losrios.edu/schedules_reader_all.php?loc=flc/" + item[ "endpoint"] + "/index.html" populateSubjects(subjects, url) filePath = utils.getAndCreateFilePath('subjects', item["endpoint"]) utils.writeJSON(subjects, filePath)
def getLatestSemesters(): numOfSemestersToGet = 3 semesters = [] populateCurrentSemesters(semesters, "http://www.losrios.edu/class-schedules.php", numOfSemestersToGet) populateArchivedSemesters(semesters, "http://www.losrios.edu/flc/flc_archive.php", numOfSemestersToGet - len(semesters)) semesters = sorted(semesters, key=lambda k: hashSemester(k['name'])) filePath = utils.getAndCreateFilePath('', 'semesters') utils.writeJSON(semesters, filePath) return semesters
def createFromSample(self, type): # [TODO] DO clean cluster start with only self as part of fresh cluster # for now on the fresh start we initialize using the sample config, which is created manually if(type == "leader" or type =="all"): confL = utils.readJSON("config/configL_sample.json") utils.writeJSON(os.path.join(self.configDir, self.configFile), confL) if(type == "main" or type =="all"): conf = utils.readJSON("config/config_sample.json") utils.writeJSON(os.path.join(self.configDir, self.baseConfigFile), conf) pass
def deriveAndDetailInstructors(semesters): instructors = [] for item in semesters: if utils.isLambdaEnv(): filePath = '/tmp/classes' + item["endpoint"] + '.json' else: filePath = 'classes/' + item["endpoint"] + '.json' deriveInstructorsFromClasses(instructors, json.load(open(filePath)), item["endpoint"]) getInstructorDetails(instructors, "http://www.flc.losrios.edu/academics") filePath = utils.getAndCreateFilePath('', 'instructors') utils.writeJSON(instructors, filePath)
def initClient(self): # read the raw config (Created from sample) # clean client/leader, client/worker , client/cluster confType = self.clientConfig["@name"] self.clientConfig[confType]["leader"] ="" self.clientConfig[confType]["worker"] = "" self.clientConfig[confType]["cluster"] = "" self.clientConfig[confType]["game"] = -1 self.clientConfig[confType]["new"] = False utils.writeJSON(os.path.join(self.configDir, self.configFile), self.clientConfig) print "Client config had been modified..." pass
def initWorker(self): # read the raw config (Created from sample) # clean worker/clients, worker/leader , worker/cluster, worker/game confType = self.workerConfig["@name"] self.workerConfig[confType]["clients"] =[] self.workerConfig[confType]["leader"] = "" self.workerConfig[confType]["cluster"] = "" self.workerConfig[confType]["game"] = -1 self.workerConfig[confType]["new"] = False # Setting up statu self.workerConfig["status"] = dict() utils.writeJSON(os.path.join(self.configDir, self.configFile), self.workerConfig) print "Worker config had been modified..." pass
def addClient(self, id, args ): # find arguments in args of msgbox # collects a client from the leader. # Needs some client configs: gameID, fromPath # start a subprocess to keep syncing data, for now lets start thread #msgD = self.msgObj.inbox[id] clientIP = args[0] gameID = args[1] fromPath = args[2] self.workerConfig["worker"]["clients"].append(clientIP) self.workerConfig["status"][clientIP] = { "today":{ "count": 0, "bytes": 0 }, "full": { "count": 0, "bytes": 0 }, "fromdate": "<date since when client exists>" } self.workerConfig["status"][clientIP]["fromdate"] = str(datetime.now()) utils.writeJSON(os.path.join(self.configDir, self.configFile), self.workerConfig) # [TODO] in case start cluster but not new, for each client IP who does not have process to get data, start them # start rsync job for all this client print "starting Rsync for ip: %s , gameID: %s , fromPath: %s " % ( clientIP, gameID, fromPath) print "I am alive..." msg = u.createAckMsg(id,1) self.msgObj.send(msg) self.msgObj.inbox.pop(id,0) # Starting Rsync runner print "Starting Rsync...." self.doCopy() pass
def extractEchoFeatures(directory, path, meta): echo = nest.initialize() # Retrieves Echo Nest summary summary = nest.retrieveSummary(echo, path) # Retrieves Echo Nest analysis URL = summary[u"analysis_url"] analysis = nest.retrieveAnalysis(URL) # Writes summary data meta = getSummaryMetadata(meta) summary = nest.getCleanSummary(summary, analysis, meta, path) filename = u"{}/{}".format(directory, u"info.json") utils.writeJSON(summary, filename) # Writes analysis data analysis = nest.getCleanAnalysis(analysis) for key, value in analysis.items(): filename = u"{}/{}".format(directory, key) utils.writeData(value, u"{}.tsv".format(filename))
def getDataFromClient(self): # keep pulling data from client at the rate set by client or leader try: while True: clientList = self.workerConfig["worker"]["clients"] for cl in clientList: if cl in self.workerConfig["status"].keys(): status = u.fileTransfer(cl,"~/.ssh/id_rsa","/home/moonfrog/sandbox/data/", "/home/moonfrog/sandbox/data/") # [TODO] For now full contains count and bytes of yest , goal is to have average per day. # updating today's status of client data self.workerConfig["status"][cl]["today"]["count"] += status["count"] self.workerConfig["status"][cl]["today"]["bytes"] += status["bytes"] # updating full status startDatetime = datetime.strptime(self.workerConfig["status"][cl]["fromdate"], "%Y-%m-%d %H:%M:%S.%f") diff = timedelta(days=2) now = datetime.now() if now - startDatetime >= diff: self.workerConfig["status"][cl]["full"]["count"] = self.workerConfig["status"][cl]["today"]["count"] self.workerConfig["status"][cl]["full"]["bytes"] = self.workerConfig["status"][cl]["today"]["bytes"] self.workerConfig["status"][cl]["today"]["count"] = 0 self.workerConfig["status"][cl]["today"]["bytes"] = 0 print str(self.workerConfig["status"][cl]) utils.writeJSON(os.path.join(self.configDir, self.configFile), self.workerConfig) time.sleep(60) except: logger.info(sys.exc_info()[0]) logger.info("Stopping Rsync job on all clients... reason( %s )" % (sys.exc_info()[0])) return pass
def addWorker(self, ip): # adding worker to cluster # --- print "Adding worker: " + ip existingWorkersInConfig = self.leaderConfig["leader"]["workers"] if ip not in existingWorkersInConfig: self.leaderConfig["leader"]["workers"].append(ip) #update config utils.writeJSON(os.path.join(self.configDir, self.configFile), self.leaderConfig) existingWorkersInServer = self.workers.keys() if ip not in existingWorkersInServer: print "Starting new msgClient for: ", ip self.workers[ip] = msgClient(ip) self.workers[ip].run() # Response handler for new worker coming in # If workers name print "checking worker: ", ip ret = self.checkWorker(ip) print "Found: ", str(ret) pass
def iamClient(self, id, args): # adding to specific cluster # handler for add client, message details # gets details from Leader and sets all details # sends an ack message with gameID, username(default moonfrog), fromPath # -- print "I am the Client..." self.clientConfig["client"]["leader"] = args[0] self.clientConfig["client"]["cluster"] = args[1] self.clientConfig["client"]["worker"] = args[2] utils.writeJSON(os.path.join(self.configDir, self.configFile), self.clientConfig) print "Updating Client config..." print "I am alive..." msgId = id type = "A" sName = "sqdC/iamClient" rName = "sqdL" now = datetime.now() opName = "addClient" args = (self.clientConfig["client"]["host"], self.clientConfig["client"]["game"], self.clientConfig["client"]["frompath"] ) msg = u.createMsg(msgId, type, sName, rName, now, opName, args) self.msgObj.send(msg) self.msgObj.inbox.pop(id,0) # Sets class variable with clusterUID pass
} ## Flow ## tracks = [] for filename in utils.readListFromFile(u"{}.txt".format(TRACKS)): # Loads the track for MIR and metadata extraction path = u"{}/{}".format(INPUT, filename.decode("utf-8")) # Loads the track's metadata meta = loadMetadata(path) # Displays the file's metadata in the console window displaySummary(meta) # Creates a directory for storing feature data directory = createDirectory(meta) print(directory.split("/")[-1]) # Extracts metadata for saving in tracks.json track = getBasicMetadata(meta) tracks.append(track) # Extracts local and Echo Nest feature information extractor.extractLocalFeatures(directory, path) extractor.extractEchoFeatures(directory, path, meta) utils.writeJSON(tracks, u"{}.json".format(TRACKS))
'lastName': lastname, 'personType': personType, 'party': party } peopleMetadata = {} for person in people: _id = makeId(person) peopleMetadata[_id] = makePersonMetadata( _id, person.split()[0], person.split()[1], 'candidate', data.debates[people[person]].debateMetadata.party) utils.writeJSON(peopleMetadata, "../data/people/metadata/metadata.json") ## UNSAFE!!! ## debateMetadata = utils.getJSON("../data/debates/metadata/metadata.json") utils.writeJSON(debateMetadata, "../data/debates/metadata/metadata_backup.json") for debateId in debateMetadata: debateMetadata[debateId]['participants'] = [ makeId(participant) for participant in participantsDict[debateId] ] utils.writeJSON(debateMetadata, "../data/debates/metadata/metadata.json") # ------------------------------------- VALIDATE ------------------------------------- # data.reset( ) # Reset the PDA, which resets the data manager, so the data sources that have changed get reloaded
def eventToStr(event): ''' A utility function for printing individual events when debugging parsing code. ''' if event['eventType'] == 'utterance': if event['speaker'] is not None: speaker = data.people.peopleMetadata[event['speaker']] speakerString = ' '.join([speaker.firstName, speaker.lastName]) else: speakerString = "Unknown" return ''.join([speakerString, ': ', '\'', event['text'], '\'']) else: return ''.join( [event['eventType'], ': ', '\'', event['text'], '\'']) for debate in data.debates: print("Parsing debate with id {0}...".format(debate.get('id')), end="") try: filename = "../data/debates/parsedTranscripts/{0}.json".format( debate.get('id')) utils.writeJSON( { 'id': debate.get('id'), 'events': list(TranscriptParser(debate).parse()) }, filename) print("Done!") except Exception as err: print("Error while parsing debate with id {0}".format( debate.get('id'))) raise err
u"directory": u"{}/".format(hash), u"thumb": thumb } ## Flow ## tracks = [] for filename in utils.readListFromFile(u"{}.txt".format(TRACKS)): # Loads the track for MIR and metadata extraction path = u"{}/{}".format(INPUT, filename.decode("utf-8")) # Loads the track's metadata meta = loadMetadata(path) # Displays the file's metadata in the console window displaySummary(meta) # Creates a directory for storing feature data directory = createDirectory(meta) print(directory.split("/")[-1]) # Extracts metadata for saving in tracks.json track = getBasicMetadata(meta) tracks.append(track) # Extracts local and Echo Nest feature information extractor.extractLocalFeatures(directory, path) extractor.extractEchoFeatures(directory, path, meta) utils.writeJSON(tracks, u"{}.json".format(TRACKS))
lastGen = prevData[-1] for each in lastGen['popList']: prevPopList.append(Individual(each['genes'], each['errorTuple'])) initPopulation = Population(prevPopList, lastGen['genNumber']) startGenNum = lastGen['genNumber'] else: initPopList = [] for i in range(conf.POPULATION_SIZE): curGene = conf.OVERFIT.copy() # it chooses random features to ignore initPopList.append(Individual(curGene)) print(curGene) initPopulation = Population(initPopList, 1) print(initPopulation.popList) utils.writeJSON(initPopulation) generations.append(initPopulation) utils.print_stats(generations[0], 1) avgErr = [] bestErr = [] for i in range(1, conf.NUM_GENS): curgenNum = startGenNum + i pregen = generations[-1] curgen = newGeneration(pregen) generations.append(curgen) avgErr.append(generations[-1].getMeanError()) bestErr.append(generations[-1].getFittest().error) utils.appendGenToFile(curgen)
def addClient(self, clientIp): # adding client to cluster # --- print "Adding client: " + clientIp existingClientsInConfig = self.leaderConfig["leader"]["clients"] if clientIp not in existingClientsInConfig: self.leaderConfig["leader"]["clients"].append(clientIp) #update config utils.writeJSON(os.path.join(self.configDir, self.configFile), self.leaderConfig) existingClientsInServer = self.clients.keys() if clientIp not in existingClientsInServer: self.clients[clientIp] = msgClient(clientIp) self.clients[clientIp].run() # Check for client print "Checking Client..." ret = None msgId = u.genNewId() type = "R" sName = "sqdL/addClient" rName = "sqdC" now = datetime.now() opName = "iamClient" # [TODO] for now always the last worker ip is send for testing purposes. # it should be same worker on which addClient is envoked after getting infor from client workerIp = self.leaderConfig["leader"]["workers"][-1] args = (self.leaderConfig["leader"]["host"], self.leaderConfig["leader"]["cluster"], workerIp) msg = u.createMsg(msgId, type, sName, rName, now, opName, args) if clientIp not in self.clients.keys(): print "Client (%s) not available..." % (clientIp,) else: id, M = u.resolveMsg(msg) self.clients[clientIp].outbox[id] = M self.clients[clientIp].send(msg) print "checkClient: " + msg for i in range(1,40): if id in self.clients[clientIp].inbox.keys(): ret = self.clients[clientIp].inbox[id] self.clients[clientIp].inbox.pop(id,0) self.clients[clientIp].outbox.pop(id,0) print "Info from Client..", str(ret["args"]) break else: time.sleep(2) # if got the necessary info from client # pass it on to worker if ret != None and len(ret["args"]) == 3: argsToWorker = ret["args"] ret = None idW = u.genNewId() type = "R" sName = "sqdL/addClient" rName = "sqdW" now = datetime.now() opName = "addClient" msg = u.createMsg(idW, type, sName, rName, now, opName, argsToWorker) print "keeping the message content in outbox..." curId, M = u.resolveMsg(msg) self.workers[workerIp].outbox[id] = M self.workers[workerIp].send(msg) print "Sending back to worker : ", msg for i in range(1,30): if id in self.workers[workerIp].inbox.keys(): ret = self.workers[workerIp].inbox[id] self.workers[workerIp].inbox.pop(id,0) self.workers[workerIp].outbox.pop(id,0) print "Worker sent: ", ret if ret == 1: self.leaderConfig["leader"]["relation"][clientIp] = workerIp #update config utils.writeJSON(os.path.join(self.configDir, self.configFile), self.leaderConfig) return ret else: time.sleep(2) else: print "Something went wrong while sending to worker..." return ret # Response handler for new worker coming in # If workers name pass
def run(self): """Run the main loop.""" while(True): self._captureManager.enterFrame() frame = self._captureManager.frame if frame is not None: if (self.autoBackgroundImg == None): self.autoBackgroundImg = numpy.float32(frame) rawFrame = frame.copy() # First work out the region of interest by # subtracting the fixed background image # to create a mask. #print frame #print self._background_depth_img absDiff = cv2.absdiff(frame,self._background_depth_img) benMask,maskArea = filters.getBenMask(absDiff,8) cv2.accumulateWeighted(frame, self.autoBackgroundImg,0.05) # Convert the background image into the same format # as the main frame. #bg = self.autoBackgroundImg bg = cv2.convertScaleAbs(self.autoBackgroundImg, alpha=1.0) # Subtract the background from the frame image cv2.absdiff(frame,bg,frame) # Scale the difference image to make it more sensitive # to changes. cv2.convertScaleAbs(frame,frame,alpha=100) # Apply the mask so we only see the test subject. frame = cv2.multiply(frame,benMask,dst=frame,dtype=-1) if (maskArea <= self.cfg.getConfigInt('area_threshold')): bri=(0,0,0) else: # Calculate the brightness of the test subject. bri = filters.getMean(frame,benMask) # Add the brightness to the time series ready for analysis. self._ts.addSamp(bri[0]) self._ts.addImg(rawFrame) # Write timeseries to a file every 'output_framecount' frames. if (self._outputFrameCount >= self.cfg.getConfigInt('output_framecount')): # Write timeseries to file self._ts.writeToFile("%s/%s" % \ ( self.cfg.getConfigStr('output_directory'), self.cfg.getConfigStr('ts_fname') )) self._outputFrameCount = 0 else: self._outputFrameCount = self._outputFrameCount + 1 # Only do the analysis every 15 frames (0.5 sec), or whatever # is specified in configuration file analysis_framecount # parameter. if (self._frameCount < self.cfg.getConfigInt('analysis_framecount')): self._frameCount = self._frameCount +1 else: # Look for peaks in the brightness (=movement). self._nPeaks,self._ts_time,self._rate = self._ts.findPeaks() #print "%d peaks in %3.2f sec = %3.1f bpm" % \ # (nPeaks,ts_time,rate) oldStatus = self._status if (maskArea > self.cfg.getConfigInt('area_threshold')): # Check for alarm levels if (self._rate > self.cfg.getConfigInt( "rate_warn")): self._status= self.ALARM_STATUS_OK elif (self._rate > self.cfg.getConfigInt( "rate_alarm")): self._status= self.ALARM_STATUS_WARN else: self._status= self.ALARM_STATUS_FULL else: self._status = self.ALARM_STATUS_NOT_FOUND if (oldStatus == self.ALARM_STATUS_OK and self._status == self.ALARM_STATUS_WARN) or \ (oldStatus == self.ALARM_STATUS_WARN and self._status == self.ALARM_STATUS_FULL): # Write timeseries to file self._ts.writeToFile("%s/%s" % \ ( self.cfg.getConfigStr('output_directory'), self.cfg.getConfigStr('alarm_ts_fname') ),bgImg=self._background_depth_img) # Collect the analysis results together and send them # to the web server. resultsDict = {} resultsDict['fps'] = "%3.0f" % self.fps resultsDict['bri'] = "%4.0f" % self._ts.mean resultsDict['area'] = "%6.0f" % maskArea resultsDict['nPeaks'] = "%d" % self._nPeaks resultsDict['ts_time'] = self._ts_time resultsDict['rate'] = "%d" % self._rate resultsDict['time_t'] = time.ctime() resultsDict['status'] = self._status self._ws.setAnalysisResults(resultsDict) # Write the results to file as a json string utils.writeJSON(resultsDict,"%s/%s" % \ (self._tmpdir, self.cfg.getConfigStr("data_fname"))) utils.writeLog(resultsDict,"%s/%s" % \ (self._tmpdir, "benFinder_alarms.log")) # Plot the graph of brightness, and save the images # to disk. self._ts.plotRawData( file=True, fname="%s/%s" % \ (self._tmpdir,self.cfg.getConfigStr("chart_fname"))) cv2.imwrite("%s/%s" % (self._tmpdir, self.cfg.getConfigStr( "raw_image_fname")), rawFrame) cv2.imwrite("%s/%s" % (self._tmpdir,self.cfg.getConfigStr( "masked_image_fname")), frame) self._frameCount = 0 else: print "Null frame received - assuming end of file and exiting" break self._captureManager.exitFrame()
def getSports(): events = [] populateSports(events, "http://flcfalcons.com/landing/index") filePath = utils.getAndCreateFilePath('', 'sports') utils.writeJSON(events, filePath)
def run(self): """Run the main loop.""" while (True): self._captureManager.enterFrame() frame = self._captureManager.frame if frame is not None: if (self.autoBackgroundImg == None): self.autoBackgroundImg = numpy.float32(frame) rawFrame = frame.copy() # First work out the region of interest by # subtracting the fixed background image # to create a mask. #print frame #print self._background_depth_img absDiff = cv2.absdiff(frame, self._background_depth_img) benMask, maskArea = filters.getBenMask(absDiff, 8) cv2.accumulateWeighted(frame, self.autoBackgroundImg, 0.05) # Convert the background image into the same format # as the main frame. #bg = self.autoBackgroundImg bg = cv2.convertScaleAbs(self.autoBackgroundImg, alpha=1.0) # Subtract the background from the frame image cv2.absdiff(frame, bg, frame) # Scale the difference image to make it more sensitive # to changes. cv2.convertScaleAbs(frame, frame, alpha=100) # Apply the mask so we only see the test subject. frame = cv2.multiply(frame, benMask, dst=frame, dtype=-1) if (maskArea <= self.cfg.getConfigInt('area_threshold')): bri = (0, 0, 0) else: # Calculate the brightness of the test subject. bri = filters.getMean(frame, benMask) # Add the brightness to the time series ready for analysis. self._ts.addSamp(bri[0]) self._ts.addImg(rawFrame) # Write timeseries to a file every 'output_framecount' frames. if (self._outputFrameCount >= self.cfg.getConfigInt('output_framecount')): # Write timeseries to file self._ts.writeToFile("%s/%s" % \ ( self.cfg.getConfigStr('output_directory'), self.cfg.getConfigStr('ts_fname') )) self._outputFrameCount = 0 else: self._outputFrameCount = self._outputFrameCount + 1 # Only do the analysis every 15 frames (0.5 sec), or whatever # is specified in configuration file analysis_framecount # parameter. if (self._frameCount < self.cfg.getConfigInt('analysis_framecount')): self._frameCount = self._frameCount + 1 else: # Look for peaks in the brightness (=movement). self._nPeaks, self._ts_time, self._rate = self._ts.findPeaks( ) #print "%d peaks in %3.2f sec = %3.1f bpm" % \ # (nPeaks,ts_time,rate) oldStatus = self._status if (maskArea > self.cfg.getConfigInt('area_threshold')): # Check for alarm levels if (self._rate > self.cfg.getConfigInt("rate_warn")): self._status = self.ALARM_STATUS_OK elif (self._rate > self.cfg.getConfigInt("rate_alarm")): self._status = self.ALARM_STATUS_WARN else: self._status = self.ALARM_STATUS_FULL else: self._status = self.ALARM_STATUS_NOT_FOUND if (oldStatus == self.ALARM_STATUS_OK and self._status == self.ALARM_STATUS_WARN) or \ (oldStatus == self.ALARM_STATUS_WARN and self._status == self.ALARM_STATUS_FULL): # Write timeseries to file self._ts.writeToFile("%s/%s" % \ ( self.cfg.getConfigStr('output_directory'), self.cfg.getConfigStr('alarm_ts_fname') ),bgImg=self._background_depth_img) # Collect the analysis results together and send them # to the web server. resultsDict = {} resultsDict['fps'] = "%3.0f" % self.fps resultsDict['bri'] = "%4.0f" % self._ts.mean resultsDict['area'] = "%6.0f" % maskArea resultsDict['nPeaks'] = "%d" % self._nPeaks resultsDict['ts_time'] = self._ts_time resultsDict['rate'] = "%d" % self._rate resultsDict['time_t'] = time.ctime() resultsDict['status'] = self._status self._ws.setAnalysisResults(resultsDict) # Write the results to file as a json string utils.writeJSON(resultsDict,"%s/%s" % \ (self._tmpdir, self.cfg.getConfigStr("data_fname"))) utils.writeLog(resultsDict,"%s/%s" % \ (self._tmpdir, "benFinder_alarms.log")) # Plot the graph of brightness, and save the images # to disk. self._ts.plotRawData( file=True, fname="%s/%s" % \ (self._tmpdir,self.cfg.getConfigStr("chart_fname"))) cv2.imwrite( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("raw_image_fname")), rawFrame) cv2.imwrite( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("masked_image_fname")), frame) self._frameCount = 0 else: print "Null frame received - assuming end of file and exiting" break self._captureManager.exitFrame()
def getEvents(): events = [] populateEvents(events, "http://www.flc.losrios.edu/x65?view=month") filePath = utils.getAndCreateFilePath('', 'events') utils.writeJSON(events, filePath)