This is partly because qubes/__init__.py conflicted with core3. It is also a good practice.pull/12/head
parent
b6ad625b85
commit
2a0bbe1c6f
@ -1,20 +0,0 @@
|
|||||||
PYTHON = /usr/bin/python2
|
|
||||||
PYTHON_SITEARCH = `python2 -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)'`
|
|
||||||
|
|
||||||
all:
|
|
||||||
$(PYTHON) -m compileall .
|
|
||||||
$(PYTHON) -O -m compileall .
|
|
||||||
.PHONY: all
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *.py[co]
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
install:
|
|
||||||
mkdir -p $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
|
|
||||||
ifeq (1,${DEBIANBUILD})
|
|
||||||
cp *.py $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
|
|
||||||
else
|
|
||||||
cp *.py* $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
|
|
||||||
endif
|
|
||||||
.PHONY: install
|
|
@ -0,0 +1,16 @@
|
|||||||
|
all:
|
||||||
|
python setup.py build
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
clean:
|
||||||
|
python setup.py clean
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
install:
|
||||||
|
python setup.py install -O1 --skip-build --root $(DESTDIR)
|
||||||
|
#ifeq (1,${DEBIANBUILD})
|
||||||
|
# cp *.py $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
|
||||||
|
#else
|
||||||
|
# cp *.py* $(DESTDIR)/$(PYTHON_SITEARCH)/qubes/
|
||||||
|
#endif
|
||||||
|
.PHONY: install
|
@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import cStringIO as StringIO
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import qubesimgconverter
|
||||||
|
|
||||||
|
class TestCaseImage(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.rgba = \
|
||||||
|
'\x00\x00\x00\xff' '\xff\x00\x00\xff' \
|
||||||
|
'\x00\xff\x00\xff' '\x00\x00\x00\xff'
|
||||||
|
self.size = (2, 2)
|
||||||
|
|
||||||
|
self.image = qubesimgconverter.Image(rgba=self.rgba, size=self.size)
|
||||||
|
|
||||||
|
def test_00_init(self):
|
||||||
|
self.assertEqual(self.image._rgba, self.rgba)
|
||||||
|
self.assertEqual(self.image._size, self.size)
|
||||||
|
|
||||||
|
def test_01_tint(self):
|
||||||
|
image = self.image.tint('#0000ff')
|
||||||
|
|
||||||
|
self.assertEqual(image._rgba,
|
||||||
|
'\x00\x00\x00\xff' '\x00\x00\xff\xff'
|
||||||
|
'\x00\x00\xff\xff' '\x00\x00\x00\xff')
|
||||||
|
|
||||||
|
def test_10_get_from_stream(self):
|
||||||
|
io = StringIO.StringIO('{0[0]} {0[1]}\n{1}'.format(self.size, self.rgba))
|
||||||
|
|
||||||
|
image = qubesimgconverter.Image.get_from_stream(io)
|
||||||
|
|
||||||
|
self.assertEqual(image._rgba, self.rgba)
|
||||||
|
self.assertEqual(image._size, self.size)
|
||||||
|
|
||||||
|
def test_11_get_from_stream_malformed(self):
|
||||||
|
io = StringIO.StringIO('{0[0]} {0[1]}\n{1}'.format(self.size, self.rgba[-1])) # one byte too short
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
image = qubesimgconverter.Image.get_from_stream(io)
|
||||||
|
|
||||||
|
def test_12_get_from_stream_too_big(self):
|
||||||
|
io = StringIO.StringIO('{0[0]} {0[1]}\n{1}'.format(self.size, self.rgba)) # 2x2
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
image = qubesimgconverter.Image.get_from_stream(io, max_width=1)
|
||||||
|
|
||||||
|
io.seek(0)
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
image = qubesimgconverter.Image.get_from_stream(io, max_height=1)
|
||||||
|
|
||||||
|
class TestCaseFunctionsAndConstants(unittest.TestCase):
|
||||||
|
def test_00_imghdrlen(self):
|
||||||
|
self.assertEqual(qubesimgconverter.imghdrlen(8, 15), len('8 15\n'))
|
||||||
|
|
||||||
|
def test_01_re_imghdr(self):
|
||||||
|
self.assertTrue(qubesimgconverter.re_imghdr.match('8 15\n'))
|
||||||
|
self.assertIsNone(qubesimgconverter.re_imghdr.match('8 15'))
|
||||||
|
self.assertIsNone(qubesimgconverter.re_imghdr.match('815\n'))
|
||||||
|
self.assertIsNone(qubesimgconverter.re_imghdr.match('x yx\n'))
|
||||||
|
|
||||||
|
def test_10_hex_to_float_result_00(self):
|
||||||
|
self.assertEqual(qubesimgconverter.hex_to_float('#000000'), (0.0, 0.0, 0.0))
|
||||||
|
|
||||||
|
def test_11_hex_to_float_result_ff(self):
|
||||||
|
self.assertEqual(qubesimgconverter.hex_to_float('0xffffff'), (1.0, 1.0, 1.0))
|
||||||
|
|
||||||
|
def test_12_hex_to_float_depth_3_not_implemented(self):
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
qubesimgconverter.hex_to_float('123456', depth=3)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -0,0 +1,14 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
name='qubesimgconverter',
|
||||||
|
version=open('../version').read().strip(),
|
||||||
|
author='Invisible Things Lab',
|
||||||
|
author_email='woju@invisiblethingslab.com',
|
||||||
|
description='Toolkit for secure transfer and conversion of images between Qubes VMs.',
|
||||||
|
license='GPL2+',
|
||||||
|
url='https://www.qubes-os.org/',
|
||||||
|
packages=['qubesimgconverter'],
|
||||||
|
)
|
||||||
|
|
||||||
|
# vim: ts=4 sts=4 sw=4 et
|
Loading…
Reference in new issue