Mercurial > libervia-web
changeset 258:53c7f0237f1e
removed trailing spaces in libervia.tac
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Nov 2013 15:01:29 +0100 |
parents | 377de26d5bc2 |
children | a20815c75c15 |
files | libervia.tac |
diffstat | 1 files changed, 52 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia.tac Sat Nov 09 17:12:05 2013 +0100 +++ b/libervia.tac Fri Nov 15 15:01:29 2013 +0100 @@ -102,7 +102,7 @@ """Wait for an action result @param callback: method to call when action gave a result back @param action_id: action_id to wait for - @param profile: %(doc_profile)s + @param profile: %(doc_profile)s @param *args: additional argument to pass to callback @param **kwargs: idem""" action_tuple = (action_id, profile) @@ -147,7 +147,7 @@ def _errback(result): d.errback(Failure(unicode(result))) - + kwargs["callback"] = d.callback kwargs["errback"] = _errback getattr(self.sat_host.bridge, method_name)(*args, **kwargs) @@ -176,13 +176,13 @@ profile = sat_session.profile sat_session.jid = JID(self.sat_host.bridge.getParamA("JabberID", "Connection", profile_key=profile)) return sat_session.jid.full() - + def jsonrpc_disconnect(self): """Disconnect the profile""" sat_session = ISATSession(self.session) profile = sat_session.profile self.sat_host.bridge.disconnect(profile) - + def jsonrpc_getContacts(self): """Return all passed args.""" profile = ISATSession(self.session).profile @@ -215,14 +215,14 @@ def jsonrpc_getWaitingSub(self): """Return list of room already joined by user""" profile = ISATSession(self.session).profile - return self.sat_host.bridge.getWaitingSub(profile) + return self.sat_host.bridge.getWaitingSub(profile) def jsonrpc_setStatus(self, status): """Change the status""" profile = ISATSession(self.session).profile self.sat_host.bridge.setPresence('', '', 0, {'':status}, profile) - + def jsonrpc_sendMessage(self, to_jid, msg, subject, _type, options={}): """send message""" profile = ISATSession(self.session).profile @@ -255,8 +255,8 @@ if node and text: return self.sat_host.bridge.sendGroupBlogComment(node, text, profile) else: - raise Exception("Invalid data") - + raise Exception("Invalid data") + def jsonrpc_getLastMblogs(self, publisher_jid, max_item): """Get last microblogs posted by a contact @param publisher_jid: jid of the publisher @@ -290,7 +290,7 @@ def jsonrpc_getPresenceStatus(self): """Get Presence information for connected contacts""" profile = ISATSession(self.session).profile - return self.sat_host.bridge.getPresenceStatus(profile) + return self.sat_host.bridge.getPresenceStatus(profile) def jsonrpc_getHistory(self, from_jid, to_jid, size, between): """Return history for the from_jid/to_jid couple""" @@ -338,7 +338,7 @@ def jsonrpc_getRoomsJoined(self): """Return list of room already joined by user""" profile = ISATSession(self.session).profile - return self.sat_host.bridge.getRoomsJoined(profile) + return self.sat_host.bridge.getRoomsJoined(profile) def jsonrpc_launchTarotGame(self, other_players): """Create a room, invite the other players and start a Tarot game""" @@ -360,7 +360,7 @@ """Tell to the server that we are ready to start the game""" profile = ISATSession(self.session).profile self.sat_host.bridge.tarotGameContratChoosed(player_nick, referee, contrat, profile) - + def jsonrpc_tarotGamePlayCards(self, player_nick, referee, cards): """Tell to the server the cards we want to put on the table""" profile = ISATSession(self.session).profile @@ -402,7 +402,7 @@ return d else: return None - + d.addCallback(setAuthorizedParams) from sat.tools.xml_tools import paramsXml2xmlUI @@ -415,7 +415,7 @@ profile = ISATSession(self.session).profile d = self.asyncBridgeCall("asyncGetParamA", param, category, attribute, SECURITY_LIMIT, profile_key=profile) return d - + def jsonrpc_setParam(self, name, value, category): profile = ISATSession(self.session).profile if category in self.authorized_params and name in self.authorized_params[category]: @@ -427,7 +427,7 @@ def jsonrpc_launchAction(self, action_type, data): profile = ISATSession(self.session).profile return self.sat_host.bridge.launchAction(action_type, data, profile) - + def jsonrpc_chatStateComposing(self, to_jid_s): """Call the method to process a "composing" state. @param to_jid_s: contact the user is composing to @@ -494,36 +494,36 @@ - AUTH ERROR: either the profile or the password is wrong - ALREADY WAITING: a request has already be made for this profile - server.NOT_DONE_YET: the profile is being processed, the return value will be given by self._logged or self._logginError - """ - + """ + try: if request.args['submit_type'][0] == 'login': _login = request.args['login'][0] if _login.startswith('@'): raise Exception('No profile_key allowed') _pass = request.args['login_password'][0] - + elif request.args['submit_type'][0] == 'register': return self._registerNewAccount(request) - + else: raise Exception('Unknown submit type') except KeyError: return "BAD REQUEST" _profile_check = self.sat_host.bridge.getProfileName(_login) - + def profile_pass_cb(_profile_pass): if not _profile_check or _profile_check != _login or _profile_pass != _pass: request.write("AUTH ERROR") request.finish() return - + if self.profiles_waiting.has_key(_login): request.write("ALREADY WAITING") request.finish() return - + if self.sat_host.bridge.isConnected(_login): request.write(self._logged(_login, request, finish=False)) request.finish() @@ -532,12 +532,12 @@ self.profiles_waiting[_login] = request d = self.asyncBridgeCall("asyncConnect", _login) return d - + def profile_pass_errback(ignore): error("INTERNAL ERROR: can't check profile password") request.write("AUTH ERROR") request.finish() - + d = self.asyncBridgeCall("asyncGetParamA", "Password", "Connection", profile_key=_login) d.addCallbacks(profile_pass_cb, profile_pass_errback) @@ -549,16 +549,16 @@ def _connected(ignore): mblog_d = self.asyncBridgeCall("setMicroblogAccess", "open", profile) mblog_d.addBoth(lambda ignore: self.sat_host.bridge.disconnect(profile)) - + d = self.asyncBridgeCall("asyncConnect", profile) d.addCallback(_connected) def _registerNewAccount(self, request): """Create a new account, or return error - @param request: initial login request + @param request: initial login request @return: "REGISTRATION" in case of success""" #TODO: must be moved in SàT core - + try: profile = login = request.args['register_login'][0] password = request.args['register_password'][0] #FIXME: password is ignored so far @@ -574,7 +574,7 @@ request.finish() #import pudb #pudb.set_trace() - + def registeringError(failure): reason = str(failure.value) if reason == "CONFLICT": @@ -584,11 +584,11 @@ else: #import pdb #pdb.set_trace() - + error('Unknown registering error: %s' % (reason,)) request.write('Unknown error (%s)' % reason) request.finish() - + d = self.asyncBridgeCall("registerSatAccount", email, password, profile) d.addCallback(registered) d.addErrback(registeringError) @@ -610,7 +610,7 @@ request.finish() else: return answer - + self.__cleanWaiting(profile) _session = request.getSession() sat_session = ISATSession(_session) @@ -619,7 +619,7 @@ return result('SESSION_ACTIVE') sat_session.profile = profile self.sat_host.prof_connected.add(profile) - + def onExpire(): info ("Session expired (profile=%s)" % (profile,)) try: @@ -628,10 +628,10 @@ except KeyError: pass #and now we disconnect the profile - self.sat_host.bridge.disconnect(profile) - + self.sat_host.bridge.disconnect(profile) + _session.notifyOnExpire(onExpire) - + d = defer.Deferred() return result('LOGGED') @@ -644,16 +644,16 @@ _session = self.request.getSession() profile = ISATSession(_session).profile return self.sat_host.bridge.isConnected(profile) - + def jsonrpc_connect(self): _session = self.request.getSession() profile = ISATSession(_session).profile if self.profiles_waiting.has_key(profile): raise jsonrpclib.Fault('1','Already waiting') #FIXME: define some standard error codes for libervia self.profiles_waiting[profile] = self.request - self.sat_host.bridge.connect(profile) + self.sat_host.bridge.connect(profile) return server.NOT_DONE_YET - + def jsonrpc_isRegistered(self): """Tell if the user is already registered""" _session = self.request.getSession() @@ -662,7 +662,7 @@ class SignalHandler(jsonrpc.JSONRPC): - + def __init__(self, sat_host): Resource.__init__(self) self.register=None @@ -694,11 +694,11 @@ _session.expire() except IndexError: error("Deferred result should be a tuple with fonction name first") - + self.signalDeferred[profile] = defer.Deferred() self.request.notifyFinish().addBoth(unlock, profile) return self.signalDeferred[profile] - + def getGenericCb(self, function_name): """Return a generic function which send all params to signalDeferred.callback function must have profile as last argument""" @@ -714,7 +714,7 @@ self.queue[profile] = [] self.queue[profile].append((function_name, args[:-1])) return genericCb - + def connected(self, profile): assert(self.register) #register must be plugged request = self.register.getWaitingRequest(profile) @@ -733,7 +733,7 @@ if not self.queue.has_key(profile): self.queue[profile] = [] self.queue[profile].append(("disconnected",)) - + def connectionError(self, error_type, profile): assert(self.register) #register must be plugged @@ -794,8 +794,8 @@ #FIXME: the uploaded file is fully loaded in memory at form parsing time so far # (see twisted.web.http.Request.requestReceived). A custom requestReceived should # be written in the futur. In addition, it is not yet possible to get progression informations - # (see http://twistedmatrix.com/trac/ticket/288) - + # (see http://twistedmatrix.com/trac/ticket/288) + with open(filepath,'w') as f: f.write(request.args[self.NAME][0]) self._fileWritten(request, filepath) @@ -808,7 +808,7 @@ def _getFileName(self, request): return "%s.ogg" % str(uuid.uuid4()) #XXX: chromium doesn't seem to play song without the .ogg extension, even with audio/ogg mime-type - + def _fileWritten(self, request, filepath): """Called once the file is actually written on disk""" profile = ISATSession(request.getSession()).profile @@ -819,7 +819,7 @@ def _getFileName(self, request): return str(uuid.uuid4()) - + def _fileWritten(self, request, filepath): """Called once the file is actually written on disk""" profile = ISATSession(request.getSession()).profile @@ -827,10 +827,10 @@ self.sat_host.bridge.setAvatar(filepath, profile) class Libervia(service.Service): - + def __init__(self): self._cleanup = [] - root = ProtectedFile(LIBERVIA_DIR) + root = ProtectedFile(LIBERVIA_DIR) self.signal_handler = SignalHandler(self) _register = Register(self) _upload_radiocol = UploadManagerRadioCol(self) @@ -848,13 +848,13 @@ self.bridge.register("connected", self.signal_handler.connected) self.bridge.register("disconnected", self.signal_handler.disconnected) self.bridge.register("connectionError", self.signal_handler.connectionError) - self.bridge.register("actionResult", self.action_handler.actionResultCb) + self.bridge.register("actionResult", self.action_handler.actionResultCb) #core for signal_name in ['presenceUpdate', 'newMessage', 'subscribe', 'contactDeleted', 'newContact', 'entityDataUpdated', 'askConfirmation', 'newAlert']: self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) #plugins for signal_name in ['personalEvent', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat', - 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', + 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', 'radiocolStarted', 'radiocolPreload', 'radiocolPlay', 'radiocolNoUpload', 'radiocolUploadOk', 'radiocolSongRejected', 'chatStateReceived']: self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name), "plugin") @@ -889,10 +889,10 @@ print "launching cleaning methods" for callback, args, kwargs in self._cleanup: callback(*args, **kwargs) - + def run(self): reactor.run() - + def stop(self): reactor.stop()