def post(self): spacket = self.get_argument("packet") packet = {} try: packet = json.loads(spacket) except ValueError: L.error("Error: packet not valid json:" + spacket) if "request" not in packet: L.error("Error: Received packet without request:" + spacket) return user = self.get_current_user() reply = RH.ajax_request(user, packet) # convert the reply to JSON and then to bytes response = str.encode(json.dumps(reply)) self.set_header("Content-type", 'text/plain') self.set_header("Content-Encoding", 'gzip') t_1 = time.time() gzip_compress = zlib.compressobj(9, zlib.DEFLATED, zlib.MAX_WBITS | 16) content = gzip_compress.compress(response) + gzip_compress.flush() L.info("compression time:%f" % (time.time() - t_1)) compressed_content_length = len(content) self.set_header("Content-Length", compressed_content_length) self.write(content)
def new_client(self, user, client): """ invoked whenever a new client joins the service webtail""" L.info("received new client") self.listeners[client] = {"user": user} # new user means possibly more directories and files to monitor self.update_files_to_monitor(user, True) return True
def update_files_to_monitor(self, user, newclient): """ read user file monitor prefs and update monitoring paths if required """ if user not in self.config: self.config[user] = {} user_config = self.config[user] if "monitored_files" not in user_config: user_config["monitored_files"] = {} if "regexes" not in user_config: user_config["regexes"] = [] user_watched_files = user_config["monitored_files"] # L.info("==============") # L.info(user_watched_files) resave_config = False for filepath in user_watched_files: if filepath in self.path_filter and newclient: L.info(filepath + ": file already being monitored by another client") self.path_filter[filepath] += 1 # increase reference count continue if not self.get_fp(filepath): L.error("Bad file path for:" + filepath) user_watched_files[filepath]['follow'] = 0 resave_config = True continue # First subscription to monitor this file self.path_filter[filepath] = 1 if resave_config: # Some bad file paths encountered and were marked. Resave users configurations # with the marked bad paths so that they can be displayed on the client side self.save_config()
def addCapsule(self, request): """add a new capsule, edit and delete is not allowed """ # probabilmente ci deve essere un sistema migliore di fare # questo passaggio dei parametri openingDate = request.openingDate closingDate = request.closingDate lat = request.lat lng = request.lng tll = request.tll anonymous = request.anonymous encrypt = request.encrypted content = request.content user = TSCEndpoint.get_current_user() TSCid = TSCController.addCapsule(openingDate, closingDate, \ lat, lng, tll, anonymous, encrypt, user, content) if TSCid is None: response = TSCResponseMessage( TSCid = None, status = TSCController.TSCCTRL_KO, statusMessage = 'Capsule not created.', content = '', items = [] ) else: L.info("Capsule created") response = TSCResponseMessage( TSCid = TSCid, status = TSCController.TSCCTRL_OK, statusMessage = 'Capsule correctly created', content = '', items = [] ) return response
def addCapsule(self, request): """add a new capsule, edit and delete is not allowed """ # probabilmente ci deve essere un sistema migliore di fare # questo passaggio dei parametri openingDate = request.openingDate closingDate = request.closingDate lat = request.lat lng = request.lng tll = request.tll anonymous = request.anonymous encrypt = request.encrypted content = request.content user = TSCEndpoint.get_current_user() TSCid = TSCController.addCapsule(openingDate, closingDate, \ lat, lng, tll, anonymous, encrypt, user, content) if TSCid is None: response = TSCResponseMessage(TSCid=None, status=TSCController.TSCCTRL_KO, statusMessage='Capsule not created.', content='', items=[]) else: L.info("Capsule created") response = TSCResponseMessage( TSCid=TSCid, status=TSCController.TSCCTRL_OK, statusMessage='Capsule correctly created', content='', items=[]) return response
def _distVincenty(self, lat1, lon1) : """ Return distance in meters beteewn 2 points. """ lat2 = self.positionLat lon2 = self.positionLng a = 6378137 b = 6356752.3142 f = 1/298.257223563 # WGS-84 ellipsiod L0 = math.radians(lon2-lon1) U1 = math.atan( (1-f) * math.tan(math.radians(lat1)) ) U2 = math.atan( (1-f) * math.tan(math.radians(lat2)) ) sinU1 = math.sin(U1) cosU1 = math.cos(U1) sinU2 = math.sin(U2) cosU2 = math.cos(U2) lambda1 = L0 lambdaP = 0 iterLimit = 100 while True: L.info(iterLimit) sinLambda = math.sin(lambda1) cosLambda = math.cos(lambda1) sinSigma = math.sqrt((cosU2*sinLambda) * (cosU2*sinLambda) + (cosU1*sinU2-sinU1*cosU2*cosLambda) * (cosU1*sinU2-sinU1*cosU2*cosLambda)) if sinSigma==0 : return 0 try: cosSigma = sinU1*sinU2 + cosU1*cosU2*cosLambda sigma = math.atan2(sinSigma, cosSigma) sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma cosSqAlpha = 1 - sinAlpha*sinAlpha cos2SigmaM = cosSigma - 2*sinU1*sinU2/cosSqAlpha except: cos2SigmaM = 0 # equatorial line: cosSqAlpha=0 (§6) C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha)) lambdaP = lambda1 lambda1 = L0 + (1-C) * f * sinAlpha *\ (sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*\ (-1+2*cos2SigmaM*cos2SigmaM))) iterLimit = iterLimit - 1 if abs(lambda1-lambdaP) > 1e-12 and iterLimit>0 : break if iterLimit==0 : return None # formula failed to converge uSq = cosSqAlpha * (a*a - b*b) / (b*b) A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))) B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq))) deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma* (-1+2*cos2SigmaM*cos2SigmaM)- B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)* (-3+4*cos2SigmaM*cos2SigmaM))) s = b*A*(sigma-deltaSigma); return s
def post(self): """ Tornado post authentication credentials """ incorrect = self.get_secure_cookie("incorrect") if incorrect and int(incorrect) > 20: self.write('<center>blocked</center>') return getusername = tornado.escape.xhtml_escape( self.get_argument("username")) getpassword = tornado.escape.xhtml_escape( self.get_argument("password")) L.info("%s,%s\n" % (getusername, getpassword)) if getusername == "demo" and getpassword == "demo": self.set_secure_cookie("user", self.get_argument("username")) self.set_secure_cookie("incorrect", "0") self.redirect(self.reverse_url("main")) else: incorrect = self.get_secure_cookie("incorrect") or 0 increased = str(int(incorrect) + 1) self.set_secure_cookie("incorrect", increased) self.write("""<center> Something Wrong With Your Data (%s)<br /> <a href="/">Go Home</a> </center>""" % increased)
def on_close_websock(self, client): """ existing websoock has been closed """ self.listeners.remove(client) if len(self.listeners) == 0: pass L.info("websock closed") if hasattr(client, "service"): RH.websock_close_connection(client)
def new_message(self, user, client, message): """ invoked whenever a client sends a new message to service webtail""" L.info("received new message:" + message) if client not in self.listeners: L.error("received message from unregiatered client") return reply_str = self.process_message(user, message) client.write_message(reply_str)
def register_ajax_handler(self, request, function): """ component registers its ajax requests handlers via this method""" if request in self.ajax_handlers: L.error("Error: request:" + request + " is already registered") return False self.ajax_handlers[request] = function L.info("registered:" + request) return True
def radar(TSCid=None, lat=None, lng=None): """ Return how meters are we far away the capsule. """ L.info("radar Called") L.debug({'TSCid': TSCid, 'lat': lat, 'lng': lng}) tsc = TimespaceCapsule.getByTSCid(TSCid) if tsc is None: return (TSCController.TSCCTRL_BADTSCID, None) return (TSCController.TSCCTRL_OK, tsc.distance(lat, lng))
def addCapsule( openingDate=None, closingDate=None, lat=None, lng=None, tll=0, anonymous=True, encrypt=False, user=None, content=None, password=None ): """ Add a new capsule Create a new capsule and assign it to current user ( owner ) content is uniencoded in : all the defining capsule parameters out : TSCid if ok, None otherwise """ L.info("addCapsule called") L.debug({ 'openingDate' : openingDate, 'closingDate' : closingDate, 'lat' : lat, 'lng' : lng, 'ttl' : tll, 'anonymous' : anonymous, 'encrypt' : encrypt, 'user' : user, 'content' : content, 'pwd len' : len(password) if password is not None else -1 }) try: tsc = \ TimespaceCapsule( openingDate = openingDate, closingDate = closingDate, content = content, positionLat = lat, positionLng = lng, positionTll = tll, anonymous = anonymous, owner = user, encrypt = encrypt, password = password ) tsc.put() except Exception as e: L.warning("Got exception!") L.exception(e) return None else: L.info("Capsule created") return tsc.TSCid
def addCapsule(openingDate=None, closingDate=None, lat=None, lng=None, tll=0, anonymous=True, encrypt=False, user=None, content=None, password=None): """ Add a new capsule Create a new capsule and assign it to current user ( owner ) content is uniencoded in : all the defining capsule parameters out : TSCid if ok, None otherwise """ L.info("addCapsule called") L.debug({ 'openingDate': openingDate, 'closingDate': closingDate, 'lat': lat, 'lng': lng, 'ttl': tll, 'anonymous': anonymous, 'encrypt': encrypt, 'user': user, 'content': content, 'pwd len': len(password) if password is not None else -1 }) try: tsc = \ TimespaceCapsule( openingDate = openingDate, closingDate = closingDate, content = content, positionLat = lat, positionLng = lng, positionTll = tll, anonymous = anonymous, owner = user, encrypt = encrypt, password = password ) tsc.put() except Exception as e: L.warning("Got exception!") L.exception(e) return None else: L.info("Capsule created") return tsc.TSCid
def radar( TSCid=None, lat=None, lng=None): """ Return how meters are we far away the capsule. """ L.info("radar Called") L.debug({ 'TSCid':TSCid, 'lat': lat, 'lng':lng }) tsc = TimespaceCapsule.getByTSCid(TSCid) if tsc is None: return (TSCController.TSCCTRL_BADTSCID, None) return (TSCController.TSCCTRL_OK, tsc.distance( lat, lng ))
def openCapsule(TSCid=None, lat=None, lng=None, password=None, user=None): """ openCapsule will assign the capsule is mode is not anonymous and then will return to caller Is capsule is anonymous or already assigned, it will try to open it """ L.info("openCapsule Called") L.debug({ 'dumping parameters': '', 'TSCid': TSCid, 'lat': lat, 'lng': lng, 'pwd len': len(password) if password is not None else -1, 'user': user }) # capsule not found tsc = TimespaceCapsule.getByTSCid(TSCid) if tsc is None: return (TSCController.TSCCTRL_BADTSCID, None) # if not anonymous here we require a valid user. if not tsc.anonymous and tsc.user is None: if user is None: return (TSCController.TSCCTRL_BADUSER, None) L.info("TSC is not anonymous, binding ...") L.info(user) tsc.assignToUser(user) return (TSCController.TSCCTRL_ASSIGNED, None) # try to open L.info("try to disclose") response = tsc.disclose(lat=lat, lng=lng, user=user, password=password) return (TSCController.TSCCTRL_OK, response)
def gen_folders(json_result, path, parent): path = abs_path(path) if valid_folder(path): files = os.listdir(path) L.info("+ dir: %s", path) for name in files: full_path = join_path(path, name) if os.path.isdir(full_path): json_result = gen_folders(json_result, full_path, join_path(parent, name)) elif os.path.isfile(full_path): json_result = gen_files(json_result, parent, name) else: L.warning("- dir: %s", path) return json_result
def close_client(self, client): """ invoked whenever a new client joins the service webtail""" info = self.listeners[client] user = info['user'] user_watched_files = self.config[user]["monitored_files"] for filepath in user_watched_files: if user_watched_files[filepath]["follow"]: self.path_filter[filepath] -= 1 if self.path_filter[filepath] == 0: L.info("reference count 0 for file " + filepath) self.tailed_file_ptrs[filepath].close() del self.tailed_file_ptrs[filepath] del self.path_filter[filepath] del self.listeners[client] L.info("webtail - client closed")
def listCapsule(self, request): """list capsule depending on search parameters This will be the most used api """ user = TSCEndpoint.get_current_user() ( rc, items ) = TSCController.searchCapsule( TSCid = request.TSCid, \ seen = request.seen, \ anonymous = request.anonymous, \ encrypt=request.encrypt, \ user = user) L.info("Logging degli items") L.info(items) if not rc == TSCController.TSCCTRL_OK : raise endpoints.InternalServerErrorException("Something goes bad") return TSCResponseMessage( TSCid = None, status = TSCController.TSCCTRL_OK, \ statusMessage = '', items = items )
def execute_func(key, args): key = key.strip().lower() if key in config.key: if key == 'info': info.main(args) if key == 'gen': gen.main(args) if key == 'cdn': update_manifest.main(args) if key == 'update-dev': gv.cdn_set_package_url(network.update_host(gv.cdn_package_url())) gv.save() if key == "update-cdn-url": gv.cdn_set_package_url(network.update_host(gv.cdn_package_url())) gv.save() if key == "android-gen": android_build.main(args) if key == 'cdn-run': print(gv.ROOT_DIR) path = os.path.join(gv.ROOT_DIR, "http_server.py") path = os.path.abspath(path) # cmd = "python {0} -port {1} -path {2}".format(path, gv.cdn_port(), utils.abs_path(gv.cdn_path())) print(gv.cdn_package_url()) http_server.run(gv.cdn_port(), "", utils.abs_path(gv.cdn_path())) # os.system(cmd) if key == 'jslist': cmd = 'jslist -f "{0}"'.format( utils.abs_path( utils.join_path(gv.client_path(), "./project.json"))) print(cmd) os.system(cmd) if key == 'run': cmd = 'cocos run --proj-dir="{0}" -p web -m debug'.format( utils.abs_path(gv.client_path())) print(cmd) os.system(cmd) if key == 'quit' or key == 'exit' or key == 'q': L.info(">>Quit!") sys.exit(0) pass
def listCapsule(self, request): """list capsule depending on search parameters This will be the most used api """ user = TSCEndpoint.get_current_user() ( rc, items ) = TSCController.searchCapsule( TSCid = request.TSCid, \ seen = request.seen, \ anonymous = request.anonymous, \ encrypt=request.encrypt, \ user = user) L.info("Logging degli items") L.info(items) if not rc == TSCController.TSCCTRL_OK: raise endpoints.InternalServerErrorException("Something goes bad") return TSCResponseMessage( TSCid = None, status = TSCController.TSCCTRL_OK, \ statusMessage = '', items = items )
def on_msg_websock(self, client, user, message): """ new message from existing websock """ L.info("websock message:" + message) if not hasattr(client, "service"): # first time we hear from this connection (i.e service request) packet = {} try: packet = json.loads(message) except ValueError: errstr = "websock initial packet not valid json" L.error(errstr) reply = {"status": "error", "msg": errstr} client.write_message(json.dumps(reply)) return if 'service' not in packet: errstr = "no service specification in request" reply = {"status": "error", "msg": errstr} client.write_message(json.dumps(reply)) return service = packet['service'] if not RH.websock_new_connection(user, client, service): msg = "service " + service + " unavailable" L.error(msg) reply = {"status": "error", "msg": msg} client.write_message(json.dumps(reply)) return reply = { "status": "ok", "msg": "Service accepted", "service": service } client.write_message(json.dumps(reply)) client.service = service return RH.websock_message(user, client, message)
def openCapsule( TSCid=None, lat=None, lng=None, password=None, user=None ): """ openCapsule will assign the capsule is mode is not anonymous and then will return to caller Is capsule is anonymous or already assigned, it will try to open it """ L.info("openCapsule Called") L.debug({ 'dumping parameters': '', 'TSCid' : TSCid, 'lat' : lat, 'lng' : lng, 'pwd len': len(password) if password is not None else -1, 'user':user }) # capsule not found tsc = TimespaceCapsule.getByTSCid(TSCid) if tsc is None: return (TSCController.TSCCTRL_BADTSCID, None) # if not anonymous here we require a valid user. if not tsc.anonymous and tsc.user is None: if user is None: return (TSCController.TSCCTRL_BADUSER, None) L.info("TSC is not anonymous, binding ...") L.info(user) tsc.assignToUser( user ) return (TSCController.TSCCTRL_ASSIGNED, None ) # try to open L.info("try to disclose") response = tsc.disclose( lat=lat, lng=lng, user=user, password=password ) return ( TSCController.TSCCTRL_OK, response)
def load_plugins(): ''' Dynamically load and initialize all the Mymon plugins ''' L.info(" --> loading plugins") plugins = [] currdir = os.path.dirname(os.path.abspath(__file__)) plugins_dir = os.path.join(currdir, 'plugins') dirs = [x for x in os.listdir(plugins_dir) \ if os.path.isdir(plugins_dir+os.sep+x)] for dirname in dirs: subdir = os.path.join(plugins_dir, dirname) # get the UI order for this plugin directory pbasedir = os.path.basename(os.path.normpath(subdir)) puipos = 999999 plugins_order = mmconf.OPT['plugins_order'] if pbasedir in plugins_order: puipos = plugins_order[pbasedir] # Make sure each plugin has import access to the # other modules in its directory (for some reason # this is sometimes not needed - haven't figured # why yet... ) L.info(' -> ' + subdir) if puipos == 0: L.info(" ... Skipping plugin (config.json)") continue sys.path.append(subdir) # Go over all the python files in the plugin folder and inspect their # classes. and if a class is derived from Mymon plugin, instantiate it # and add it to the list of plugins # TODO: Make sure that only one MymonPlugin derived class exists within # a plugin directory. files = [x for x in os.listdir(subdir) \ if os.path.isfile(os.path.join(subdir, x)) and x.endswith(".py")] for filename in files: plugin_candidate = os.path.join(subdir, filename) plugin_module = loadmodule.load_module(plugin_candidate) plugin_classes = inspect.getmembers(plugin_module, inspect.isclass) modname, extname = os.path.splitext(filename) for plugin_class in plugin_classes: pcls = plugin_class[1] if issubclass(pcls, MymonPlugin) and pcls.__module__ == modname: ipcls = pcls() ipcls.dir = subdir.replace(currdir + os.sep, '') ipcls.uipos = puipos plugins.append(ipcls) # Sort the loaded plugins according to their configured UI position plugins.sort(key=lambda o: o.uipos) return plugins
def put(self, *args, **dic): """Store the TSC and before that does check, raise exception if something is not correct. Failure reasons are 1) closingDate < openingDate 2) encripted flag set and no password provided 3) empty content """ L.info("Storing the TSC") L.info("Dumping the anonymous " + str( self.anonymous )) L.info("Dumping the content " + str( self.content )) if self.encrypt and self.password is not None and len(self.password)==0: raise Exception("Can't store an encripted TSC with no password") if self.closingDate < self.openingDate: raise Exception("closing date is before the opening date ") if len( self.content ) == 0: raise Exception("empty content ") return super( TimespaceCapsule, self).put(*args, **dic)
def searchCapsule( TSCid=None, seen=False, anonymous=True, notified=False, assigned=False, encrypt=False, user=None ): """ Search a TSC depending on the given parameters, if tscid is provided extra parameters are ignored. """ L.info("searchCapsule called ") L.debug({ 'Dumping paramters' : '', 'anonymous' : anonymous, 'notified' : notified, 'assigned' : assigned, 'encrypt' : encrypt, 'user' : user }) # if TSCid is provided SEARCH only by TSCid. if TSCid is not None: L.info("TSCid is not None") tsc = TimespaceCapsule.getByTSCid( TSCid ) tscList = [tsc] if tsc is not None else [] else: # more elements tscList = TimespaceCapsule.getList( user=user, seenFlag=seen, assignedFlag=assigned, notifiedFlag=notified, encryptFlag=encrypt ) items = [ tsc.toEndPointMessage() for tsc in tscList ] if any(items): L.info( "No capsule found!") return ( TSCController.TSCCTRL_OK, items )
def put(self, *args, **dic): """Store the TSC and before that does check, raise exception if something is not correct. Failure reasons are 1) closingDate < openingDate 2) encripted flag set and no password provided 3) empty content """ L.info("Storing the TSC") L.info("Dumping the anonymous " + str(self.anonymous)) L.info("Dumping the content " + str(self.content)) if self.encrypt and self.password is not None and len( self.password) == 0: raise Exception("Can't store an encripted TSC with no password") if self.closingDate < self.openingDate: raise Exception("closing date is before the opening date ") if len(self.content) == 0: raise Exception("empty content ") return super(TimespaceCapsule, self).put(*args, **dic)
def searchCapsule(TSCid=None, seen=False, anonymous=True, notified=False, assigned=False, encrypt=False, user=None): """ Search a TSC depending on the given parameters, if tscid is provided extra parameters are ignored. """ L.info("searchCapsule called ") L.debug({ 'Dumping paramters': '', 'anonymous': anonymous, 'notified': notified, 'assigned': assigned, 'encrypt': encrypt, 'user': user }) # if TSCid is provided SEARCH only by TSCid. if TSCid is not None: L.info("TSCid is not None") tsc = TimespaceCapsule.getByTSCid(TSCid) tscList = [tsc] if tsc is not None else [] else: # more elements tscList = TimespaceCapsule.getList(user=user, seenFlag=seen, assignedFlag=assigned, notifiedFlag=notified, encryptFlag=encrypt) items = [tsc.toEndPointMessage() for tsc in tscList] if any(items): L.info("No capsule found!") return (TSCController.TSCCTRL_OK, items)
def on_open_websock(self, client, user): """ new websoock has connected """ self.listeners.append(client) L.info("websock connected")
def _distVincenty(self, lat1, lon1): """ Return distance in meters beteewn 2 points. """ lat2 = self.positionLat lon2 = self.positionLng a = 6378137 b = 6356752.3142 f = 1 / 298.257223563 # WGS-84 ellipsiod L0 = math.radians(lon2 - lon1) U1 = math.atan((1 - f) * math.tan(math.radians(lat1))) U2 = math.atan((1 - f) * math.tan(math.radians(lat2))) sinU1 = math.sin(U1) cosU1 = math.cos(U1) sinU2 = math.sin(U2) cosU2 = math.cos(U2) lambda1 = L0 lambdaP = 0 iterLimit = 100 while True: L.info(iterLimit) sinLambda = math.sin(lambda1) cosLambda = math.cos(lambda1) sinSigma = math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)) if sinSigma == 0: return 0 try: cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda sigma = math.atan2(sinSigma, cosSigma) sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma cosSqAlpha = 1 - sinAlpha * sinAlpha cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha except: cos2SigmaM = 0 # equatorial line: cosSqAlpha=0 (§6) C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)) lambdaP = lambda1 lambda1 = L0 + (1-C) * f * sinAlpha *\ (sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*\ (-1+2*cos2SigmaM*cos2SigmaM))) iterLimit = iterLimit - 1 if abs(lambda1 - lambdaP) > 1e-12 and iterLimit > 0: break if iterLimit == 0: return None # formula failed to converge uSq = cosSqAlpha * (a * a - b * b) / (b * b) A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))) B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))) deltaSigma = B * sinSigma * ( cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM))) s = b * A * (sigma - deltaSigma) return s
def getCapsuleListForUser(user): L.info("Getting TSC list for user {0}".format(*user.get_email())) return TimespaceCapsule.all().filter("owner =", user)
def getCapsuleListForUser( user): L.info("Getting TSC list for user {0}".format(* user.get_email())) return TimespaceCapsule.all().filter("owner =",user )
def open(self): L.info("WebsockHandler open") user = self.get_secure_cookie("user").decode('utf-8') L.info("user=" + user) self.app.on_open_websock(self, user)
def initialize(self, app): ''' remember who the web app is ''' L.info("initializing WebsockHandler") self.app = app
def on_message(self, message): user = self.get_secure_cookie("user").decode('utf-8') L.info("user=" + user) self.app.on_msg_websock(self, user, message)