run-test:
docker rm -v sirius-database-test || true
- docker-compose -f docker-compose.yml -f docker-compose.test.yml up
\ No newline at end of file
+ docker-compose -f docker-compose.yml -f docker-compose.test.yml up --build
\ No newline at end of file
sirius:
depends_on:
- sirius-database-test
+ command: "bin/wait-for-it.sh sirius-database-test:5432 -- bin/docker-entrypoint.sh"
environment:
- - DATABASE_URL=postgresql://postgres:plop@sirius-database/sirius-test
+ - DATABASE_URL=postgresql://postgres:plop@sirius-database-test/sirius-test
sirius-database-test:
container_name: sirius-database-test
environment:
- POSTGRES_DB=sirius-test
- POSTGRES_PASSWORD=plop
+
+ sirius-web:
+ ports:
+ - "8880:80"
+ - "8443:443"
dockerfile: ./Dockerfile
depends_on:
- sirius-web
- command:
- [
- "bin/wait-for-it.sh",
- "sirius-database:5432",
- "--",
- "bin/docker-entrypoint.sh",
- ]
+ command: "bin/wait-for-it.sh sirius-database:5432 -- bin/docker-entrypoint.sh"
environment:
- OPENSSL_CONF=/etc/ssl/
# Pad with the original length encoded as a 16bit int
# Python3
- #input = input + bytes( [((input_length * 8) >> 8 & 0xff)] )
- #input = input + bytes( [((input_length * 8) >> 0 & 0xff)] )
+ input = input + bytes( [((input_length * 8) >> 8 & 0xff)] )
+ input = input + bytes( [((input_length * 8) >> 0 & 0xff)] )
# Python2
- input = input + chr((input_length * 8) >> 8 & 0xff)
- input = input + chr((input_length * 8) >> 0 & 0xff)
+ # input = input + chr((input_length * 8) >> 8 & 0xff)
+ # input = input + chr((input_length * 8) >> 0 & 0xff)
elif input_length != ZBEE_SEC_CONST_BLOCKSIZE:
raise InvalidClaimCode("cannot handle input size %d" % input_length)
# We encrypt the salt and the input bytes
- # blocks = [bytes(CLAIM_CODE_SALT), input] # Python3
- blocks = [str(bytearray(CLAIM_CODE_SALT)), input] # Python2
+ blocks = [bytes(CLAIM_CODE_SALT), input] # Python3
+ # blocks = [str(bytearray(CLAIM_CODE_SALT)), input] # Python2
- #output = bytes(16) # Works in Python3
- output = bytearray(16) # Works in Python2
+ output = bytes(16) # Works in Python3
+ # output = bytearray(16) # Works in Python2
for block in blocks:
- # aes_encoder = AES.new(output, AES.MODE_ECB) # Python3
- aes_encoder = AES.new(str(output), AES.MODE_ECB) # Python2
+ aes_encoder = AES.new(output, AES.MODE_ECB) # Python3
+ # aes_encoder = AES.new(str(output), AES.MODE_ECB) # Python2
h = aes_encoder.encrypt(block)
output = bytearray(16)
for i in range(len(output)):
- # output[i] = h[i] ^ block[i] # Python3
- output[i] = ord(h[i]) ^ ord(block[i]) # Python2
+ output[i] = h[i] ^ block[i] # Python3
+ # output[i] = ord(h[i]) ^ ord(block[i]) # Python2
output = bytes(output)
return output
# Generate our own CRC from the raw_value, and confirm it matches the extracted crc
data_for_crc = struct.pack("<Q", raw_value & 0xffffffffffffffff)
- #server_crc = crc16(data_for_crc) # this works in Python3
- server_crc = crc16( bytearray(data_for_crc) ) # this works in Python2
+ server_crc = crc16(data_for_crc) # this works in Python3
+ # server_crc = crc16( bytearray(data_for_crc) ) # this works in Python2
if server_crc != crc:
raise InvalidClaimCode("CRC problem")
'name': 'add_device_encryption_key',
'params': {
'device_address': command.device_address,
- 'encryption_key': claiming.key_from_claim_code(command.claim_code),
+ 'encryption_key': base64.b64encode(
+ claiming.key_from_claim_code(command.claim_code)
+ ).decode('utf-8'),
},
},
})
elif type(command) == messages.SetDeliveryAndPrint:
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x1, _payload_from_pixels(command.pixels), command_id)),
+ 0x1, _payload_from_pixels(command.pixels), command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
elif type(command) == messages.SetDelivery:
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x2, _payload_from_pixels(command.pixels), command_id)),
+ 0x2, _payload_from_pixels(command.pixels), command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
elif type(command) == messages.SetDeliveryAndPrintNoFace:
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x11, _payload_from_pixels(command.pixels), command_id)),
+ 0x11, _payload_from_pixels(command.pixels), command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
elif type(command) == messages.SetDeliveryNoFace:
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x12, _payload_from_pixels(command.pixels), command_id)),
+ 0x12, _payload_from_pixels(command.pixels), command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x0102, payload, command_id)),
+ 0x0102, payload, command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x0101, payload, command_id)),
+ 0x0101, payload, command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
return make({
'binary_payload': base64.b64encode(_encode_printer_message(
- 0x202, payload, command_id)),
+ 0x202, payload, command_id)).decode('utf-8'),
'device_address': command.device_address,
'type': 'DeviceCommand',
})
# note that the .html suffix is required to make phantomjs
# pick up the mime-type and render correctly.
with tempfile.NamedTemporaryFile(suffix='.html') as f:
- if isinstance(html, unicode):
+ if isinstance(html, str):
f.write(html.encode('utf8'))
else:
f.write(html)
image = Image.open(data)
image = image_encoding.crop_384(image)
- image = image_encoding.threshold(image)
+ # image = image_encoding.threshold(image)
n_bytes, _ = image_encoding.rle_from_bw(image)
self.assertEquals(n_bytes, 3072)
)
)
db.session.add(self.testuser)
+ db.session.flush()
+ db.session.refresh(self.testuser)
def tearDown(self):
db.session.rollback()
f0, _ = self.u0.signed_up_friends()
f1, _ = self.u1.signed_up_friends()
- self.assertItemsEqual(f0, [
+ self.assertCountEqual(f0, [
user.Friend('twitter1', 't1', ''),
user.Friend('twitter2', 't2', '')])
- self.assertItemsEqual(f1, [
+ self.assertCountEqual(f1, [
user.Friend('twitter2', 't2', '')])
def test_print_ok(self):
r = self.client.post(self.get_print_url(), data=dict(
- target_printer=self.printer.id, message='hello'))
- print(r.headers)
+ target_printer=self.printer.id,
+ face='default',
+ message='hello'
+ ))
self.assertRedirects(r, '/printer/1')
def test_print_wrong_printer(self):
r = self.client.post(self.get_print_url(), data=dict(
- target_printer='10', message='hello2'))
- self.assertIn('Not a valid choice', r.data)
+ target_printer='10',
+ face='default',
+ message='hello2'
+ ))
+ self.assertIn('Not a valid choice', r.data.decode('utf-8'))
self.assert200(r)