Skip to content

Commit

Permalink
Make compatible with Python 2.7 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
terwilligergreen committed Oct 14, 2015
1 parent 3d9c8a2 commit 570a34a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is early code. There may be errors!

## Requirements

- Python 2.7
- Python 2.7 or 3.4+
- xsltproc - to perform XSL transformations
- PyYAML

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is early code. There may be errors!

Requirements
------------
- Python 2.6.6 or 2.7+
- Python 2.7 or 3.4+
- xsltproc - to perform XSL transformations
- PyYAML - to generate YAML

Expand Down
17 changes: 13 additions & 4 deletions compliancelib/seccontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@
import subprocess
import re

# sys.path.append(os.path.join('xsl'))
# sys.path.append(os.path.join('data'))
def getstatusoutput(cmd):
"""Return (status, output) of executing cmd in a shell."""
"""This new implementation should work on all platforms."""
import subprocess
pipe = subprocess.Popen(cmd, shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = str.join("", pipe.stdout.readlines())
sts = pipe.wait()
if sts is None:
sts = 0
return sts, output


class SecControl(object):
Expand All @@ -44,7 +53,7 @@ def _load_control_from_xml(self):
xslfile = os.path.join(os.path.dirname(__file__), 'xsl/control2json.xsl')
xmlfile = os.path.join(os.path.dirname(__file__), 'data/800-53-controls.xml')

results = subprocess.getstatusoutput("xsltproc --stringparam controlnumber '%s' %s %s" % (self.id, xslfile, xmlfile))
results = getstatusoutput("xsltproc --stringparam controlnumber '%s' %s %s" % (self.id, xslfile, xmlfile))

if (results[0] == 0) and (len(results[1]) > 0):
self.details = json.loads(results[1])
Expand All @@ -62,7 +71,7 @@ def _load_control_enhancement_from_xml(self):
"load control enhancement as a control from 800-53 xml"
xslfile = os.path.join(os.path.dirname(__file__), 'xsl/controlenhancement2json.xsl')
xmlfile = os.path.join(os.path.dirname(__file__), 'data/800-53-controls.xml')
results = subprocess.getstatusoutput("xsltproc --stringparam controlnumber '%s' %s %s" % (self.id, xslfile, xmlfile))
results = getstatusoutput("xsltproc --stringparam controlnumber '%s' %s %s" % (self.id, xslfile, xmlfile))

if (results[0] == 0) and (len(results[1]) > 0):
self.details = json.loads(results[1])
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ def readme():
return f.read()

setup(name='compliancelib',
version='0.2.5',
version='0.3.2',
description='A python library of IT Compliance Standards',
long_description=readme(),
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.0',
'Topic :: Text Processing :: Linguistic',
],
keywords='compliance FISMA DICAP PCI',
Expand Down

0 comments on commit 570a34a

Please sign in to comment.