def init_clone_template(): template = Cache().get('clone_template') if template and len(template) > 0: return template else: template = [] clone_data = CopyArticle.objects.all() for data in clone_data: temp = { 'name': data.name, 'host': data.host, 'title': data.title, 'context': data.context, } if data.h2: temp['h2'] = data.h2 if data.h3: temp['h3'] = data.h3 if data.code: temp['code'] = data.code if data.exclude: temp['exclude'] = data.exclude template.append(temp) Cache('clone_template', template) return json.dumps(template)
def get_reptilian(host): reptilian = Cache().get('clone_reptilian') if not reptilian or len(reptilian) == 0: reptilian = [] for item in CopyLogin.objects.all(): reptilian.append({ 'host': item.host.host, 'user': item.username, 'pwd': item.password, 'signal': item.signal, 'js': item.js, 'cookie': item.cookie }) Cache('clone_reptilian', reptilian) for item in reptilian: if item.get('host') == host: item['login'] = type( 'LoginEntry', (BaseEntry, ), { 'signal': item.get('signal'), 'username': item.get('user'), 'password': item.get('pwd'), 'script': item.get('js'), 'cookie_dir': os.path.join(COOKIE_DIR, item.get('cookie')) }) return item return None