def shutdown(request): """ shuts down the system and powers off the system """ if not request.session.get("allow_shutdown"): return HttpResponseRedirect('/') request.session.pop("allow_shutdown") return render(request, 'system/shutdown.html', { 'sw_name': get_sw_name(), 'sw_version': get_sw_version(), })
def reboot(request): """ reboots the system """ if not request.session.get("allow_reboot"): return HttpResponseRedirect('/') request.session.pop("allow_reboot") return render(request, 'system/reboot.html', { 'sw_name': get_sw_name(), 'sw_version': get_sw_version(), })
def adminInterface(request, objtype=None): try: console = Advanced.objects.all().order_by('-id')[0].adv_consolemsg except: console = False try: hostname = GlobalConfiguration.objects.order_by('-id')[0].gc_hostname except: hostname = None sw_version = get_sw_version() return render(request, 'freeadmin/index.html', { 'consolemsg': console, 'hostname': hostname, 'sw_name': get_sw_name(), 'sw_version': sw_version, 'cache_hash': hashlib.md5(sw_version).hexdigest(), })
def shutdown(request): """ shuts down the system and powers off the system """ if not request.session.get("allow_shutdown"): return HttpResponseRedirect("/") request.session.pop("allow_shutdown") return render(request, "system/shutdown.html", {"sw_name": get_sw_name(), "sw_version": get_sw_version()})
def reboot(request): """ reboots the system """ if not request.session.get("allow_reboot"): return HttpResponseRedirect("/") request.session.pop("allow_reboot") return render(request, "system/reboot.html", {"sw_name": get_sw_name(), "sw_version": get_sw_version()})
def get_traceback_html(self): """ Copied from debug.ExceptionReporter The Template was replaced to use 500_metanas.html instead of the hard-coded one Return HTML code for traceback." """ if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist): self.template_does_not_exist = True self.loader_debug_info = [] for loader in template_source_loaders: try: module = import_module(loader.__module__) if hasattr(loader, '__class__'): source_list_func = loader.get_template_sources else: # NOTE: Remember to remove this branch when we deprecate old template loaders in 1.4 source_list_func = module.get_template_sources # NOTE: This assumes exc_value is the name of the template that # the loader attempted to load. template_list = [{'name': t, 'exists': os.path.exists(t)} \ for t in source_list_func(str(self.exc_value))] except (ImportError, AttributeError): template_list = [] if hasattr(loader, '__class__'): loader_name = loader.__module__ + '.' + loader.__class__.__name__ else: # NOTE: Remember to remove this branch when we deprecate old template loaders in 1.4 loader_name = loader.__module__ + '.' + loader.__name__ self.loader_debug_info.append({ 'loader': loader_name, 'templates': template_list, }) if (settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source') and isinstance(self.exc_value, TemplateSyntaxError)): self.get_template_exception_info() frames = self.get_traceback_frames() for i, frame in enumerate(frames): if 'vars' in frame: frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']] frames[i] = frame unicode_hint = '' if self.exc_type and issubclass(self.exc_type, UnicodeError): start = getattr(self.exc_value, 'start', None) end = getattr(self.exc_value, 'end', None) if start is not None and end is not None: unicode_str = self.exc_value.args[1] unicode_hint = smart_unicode(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace') t = get_template("500_metanas.html") #t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 template') c = Context({ 'is_email': self.is_email, 'unicode_hint': unicode_hint, 'frames': frames, 'request': self.request, 'settings': debug.get_safe_settings(), 'sys_executable': sys.executable, 'sys_version_info': '%d.%d.%d' % sys.version_info[0:3], 'server_time': datetime.datetime.now(), 'sw_version': get_sw_version(), 'sys_path': sys.path, 'template_info': self.template_info, 'template_does_not_exist': self.template_does_not_exist, 'loader_debug_info': self.loader_debug_info, }) # Check whether exception info is available if self.exc_type: c['exception_type'] = self.exc_type.__name__ if self.exc_value: c['exception_value'] = smart_unicode(self.exc_value, errors='replace') if frames: c['lastframe'] = frames[-1] return t.render(c)