def post(self): logging.info("Request[%s] from '%s' to '%s'", "post", self.request.remote_ip, "adm->users") if not self.groups_allowed_access(["admins"]): return action = self.get_argument("action", None) if not action: logging.error("Unspecified action type!") return elif action == "get-users": self.write(json.dumps(self.users.get_users(100, 0))) elif action == "get-groups": self.write(json.dumps(self.users.get_groups())) elif action == "user-add": login = self.get_argument("login", None) passwd = self.get_argument("passwd", None) group = self.get_argument("group", None) self.users.create_user(login, passwd, group) elif action == "user-edit": uiid = self.get_argument("id", None) login = self.get_argument("login", None) passwd = self.get_argument("passwd", None) group = self.get_argument("group", None) self.users.user_update(uiid, login, passwd, group) elif action == "user-remove": uiid = self.get_argument("id", None) self.users.remove_user(uiid) elif action == "group-add": name = self.get_argument("name", None) self.users.create_group(name) elif action == "group-edit": gid = self.get_argument("id", None) name = self.get_argument("name", None) self.users.group_edit(gid, name) elif action == "group-remove": gid = self.get_argument("id", None) self.users.remove_group(gid)
def publish(self, name, value, options=dict()): self.channel.queue_declare(queue=str(name)) self.channel.basic_publish( exchange='', routing_key=str(name), body=dumps(value), )
def publish(self, name, value, options = dict()): self.channel.queue_declare(queue = str(name)) self.channel.basic_publish( exchange = '', routing_key = str(name), body = dumps(value), )
def save(self): info = self.save_info() info = self.save_chapters(info) logging.info("Saving info into file: %s", self.p_info) with open(self.p_info, 'w') as f: f.write(json.dumps(info, indent=2))
def post(self): logging.info("Request[%s] from '%s' -> '%s'", "post", self.request.remote_ip, self.request.body) action = self.get_argument("action", None) if action in ["load"]: articles = int(self.get_argument("articles", 10)) offset = int(self.get_argument("offset", 0)) data = json.dumps(self.manga.get_index_manga(articles, offset)) self.write(data)
def publish(self, name, value, options = dict()): with self.conn.temporary_use(name): self.conn.put( dumps(value), delay=max( 0, math.ceil(dict(options).get('delay', 0))) )
def to_mongo(self, value, **kwargs): return super().to_mongo( json.dumps(value), **kwargs)
def validate(self, value): try: json.dumps(value) except: super().validate(value)
def msg(self, obj): self.write_message(json.dumps(obj))
def publish(self, name, value, options=dict()): self.conn.publish(str(self.name), dumps(dict( channel=name, data=dict(value), )))
def publish(self, name, value, options = dict()): self.conn.publish(str(self.name), dumps(dict( channel = name, data = dict(value), )) )
import os import yaml import re import logging import jinja2 from core.conf import settings from core.util.json import dumps, loads from core.ext.plugin import renderers from dicttoxml import dicttoxml TYPES = dict( text = lambda c: str(c), json = lambda c: dumps(c), xml = lambda c: dicttoxml(c, attr_type=False).decode('utf-8'), ) TYPES.update(renderers) class Undefined(jinja2.Undefined): def operate(self, *args, **kwargs): return self.__class__() __add__ = __radd__ = __mul__ = __rmul__ = __div__ = __rdiv__ = \ __truediv__ = __rtruediv__ = __floordiv__ = __rfloordiv__ = __mod__ = \ __rmod__ = __pos__ = __neg__ = __call__ = __getitem__ = __lt__ = \ __le__ = __gt__ = __ge__ = __int__ = __float__ = __complex__ = __pow__ = \ __rpow__ = __getattr__ = operate environment = jinja2.Environment(