llcrnrlon=lonCoords[lonBounds[0]], llcrnrlat=latCoords[latBounds[0]], urcrnrlon=lonCoords[lonBounds[1]], urcrnrlat=latCoords[latBounds[1]], fix_aspect=False) x, y = m(*np.meshgrid(lons, lats)) try: m.contourf(x, y, _var.asma(), clevs, cmap=plt.cm.RdBu_r, extend='both') except Exception, err: import traceback tb = traceback.format_exc() self.debug(tb) self.debug("Region lat(%d,%d) lon(%d,%d) faled" % (latBounds[0], latBounds[1], lonBounds[0], lonBounds[1])) m.drawcoastlines() # self.debug("save to temp file") temp_image_file = os.path.join(TEMP_DIR, '%s.png' % str(uuid4())) fig.savefig(temp_image_file, dpi=100) # self.debug("convert image data to base64") with open(temp_image_file, "rb") as temp_image: base64png = base64.b64encode(temp_image.read()) os.remove(temp_image_file) return base64png if __name__ == '__main__': startNode(StreamWorker)
if expr.match(pd) != None: res += 1 if res > 0: return res except OSError: pass # Other UNIXes (heuristic) try: try: dmesg = open('/var/run/dmesg.boot').read() except IOError: dmesgProcess = subprocess.Popen(['dmesg'], stdout=subprocess.PIPE) dmesg = dmesgProcess.communicate()[0] res = 0 while '\ncpu' + str(res) + ':' in dmesg: res += 1 if res > 0: return res except OSError: pass raise Exception('Can not determine number of CPUs on this system') if __name__ == '__main__': startNode(StreamMaster)
# -*- coding: utf-8 -*- from __init__ import WebSocketNode, NodeSlot, startNode class EchoNode(WebSocketNode): def nodeFileName(self): return 'echo' @NodeSlot def echo(*args, **kwargs): return (args, kwargs) if __name__ == '__main__': startNode(EchoNode)