def _display_log(self, root, issuer, profile): item = [] if profile: path = os.path.join(root, issuer, profile).replace(":", "%3A") argv = {"issuer": unquote(issuer), "profile": profile} path = with_or_without_slash(path) if path is None: resp = Response("No saved logs") return resp(self.environ, self.start_response) for _name in os.listdir(path): if _name.startswith("."): continue fn = os.path.join(path, _name) if os.path.isfile(fn): item.append((unquote(_name), os.path.join(profile, _name))) else: if issuer: argv = {'issuer': unquote(issuer), 'profile': ''} path = os.path.join(root, issuer).replace(":", "%3A") else: argv = {'issuer': '', 'profile': ''} path = root path = with_or_without_slash(path) if path is None: resp = Response("No saved logs") return resp(self.environ, self.start_response) for _name in os.listdir(path): if _name.startswith("."): continue fn = os.path.join(path, _name) if os.path.isdir(fn): item.append((unquote(_name), os.path.join(path, _name))) resp = Response(mako_template="logs.mako", template_lookup=self.lookup, headers=[]) item.sort() argv["logs"] = item return resp(self.environ, self.start_response, **argv)
def log_path(session, test_id=None): _conv = session["conv"] try: iss = _conv.entity.provider_info["issuer"] except TypeError: return "" else: qiss = quote_plus(iss) path = with_or_without_slash(os.path.join("log", qiss)) if path is None: path = os.path.join("log", qiss) prof = ".".join(to_profile(session)) if not os.path.isdir("%s/%s" % (path, prof)): os.makedirs("%s/%s" % (path, prof)) if test_id is None: test_id = session["testid"] return "%s/%s/%s" % (path, prof, test_id)
def log_path(self, test_id=None): _conv = self.session["conv"] try: iss = _conv.entity_id except (TypeError, KeyError, AttributeError): return "" else: qiss = quote_plus(iss) path = with_or_without_slash(os.path.join("log", qiss)) if path is None: path = os.path.join("log", qiss) prof = ".".join(self.to_profile()) if not os.path.isdir("{}/{}".format(path, prof)): os.makedirs("{}/{}".format(path, prof)) if test_id is None: test_id = self.session["testid"] return "{}/{}/{}".format(path, prof, test_id)