我正在尝试在下面运行以下代码,但始终会出现标题错误:
回溯(最近通话最近): 响应文件“ /usr/local/lib/python2.7/dist-packages/cherrypy/_cprequest.py”,第670行 response.body = self.handler() 调用中的文件“ /usr/local/lib/python2.7/dist-packages/cherrypy/lib/encoding.py”,第217行 self.body = self.oldhandler(* args,** kwargs) 调用中的文件“ /usr/local/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py”,第61行 返回self.callable(* self.args,** self.kwargs) 系列中的文件“ web / 800-53-server.py”,第79行 control_list.append('%s-%d-%s'%(id,control,id,control,sc.title.title)) AttributeError:'NoneType'对象没有属性'title'
似乎出错的代码块如下:
@cherrypy.expose
def family(self, id="AC", format="html"):
id = id.upper()
family_control_count = {"AC": 25, "AU": 16, "AT": 5, "CM": 11, "CP": 13, "IA": 11, "IR": 10, "MA": 6, "MP": 8,
"PS": 8, "PE": 20, "PL": 9, "PM": 16, "RA": 6, "CA": 9, "SC": 44, "SI": 17, "SA": 22}
families = {"AC": "Access Control", "AU": "Audit and Accountability", "AT": "Awareness and Training", "CM": "Configuration Management",
"CP": "Contingency Planning", "IA": "Identification and Authentication", "IR": "Incident Response", "MA": "Maintenance",
"MP": "Media Protection", "PS": "Personnel Security", "PE": "Physical and Environmental Protection", "PL": "Planning",
"PM": "Program Management", "RA": "Risk Assessment", "CA": "Security Assessment and Authorization",
"SC": "System and Communications Protection", "SI": "System and Information Integrity", "SA": "System and Services Acquisition"}
control_list = []
for control in range(1,family_control_count[id]+1):
sc = SecControl("%s-%d" % (id, control))
control_list.append('<div><a href="/control?id=%s-%d">%s-%d</a> - %s</div>' % (id, control, id, control, sc.title.title))
return """<html>
以下更多程序:
`#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, os.path
import sys
import random
import string
import json
import yaml
import cherrypy
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('web/templates'))
sys.path.append(os.path.join('lib'))
sys.path.append(os.path.join('data'))
from seccontrol import SecControl
from seccontrolviz import SecControlViz
from utilities import *
class StringGenerator(object):
@cherrypy.expose
def index(self):
return """<html>
<head>
<title>800-53 Controls</title>
<link rel="stylesheet" type="text/css" href="/assets/css/main.css">
</head>`
答案 0 :(得分:2)
包GovReady
(我假设它是基于import语句使用的)依赖于xsltproc
。您可能已将其安装在mac OS上,但未安装在其他计算机上。根据您的Linux风格,它需要安装sudo apt install xsltproc
或等效版本,因为它不是pip软件包。
尝试从您的xsltproc --stringparam controlnumber 'AC-1' control2json.xsl ../data/800-53-controls.xml
目录运行800-53-server/lib
。您正在调用的函数是该命令的包装器。
安装该程序后,我得到
{ "id": "AC-1",
"title": "ACCESS CONTROL POLICY AND PROCEDURES",
...
}