Пример #1
0
    def test_empty_error_message_on_invalid_order_creation(self):
        resp = self.behaviors.create_order_overriding_cfg(
            payload_content_type='text/plain')
        create_resp = resp.create_resp

        # Make sure we actually get a message back
        error_msg = json_to_dict(create_resp.content).get('title')

        self.assertEqual(create_resp.status_code, 400)
        self.assertIsNotNone(error_msg)
        self.assertNotEqual(error_msg, 'None')
Пример #2
0
    def test_empty_error_message_on_invalid_order_creation(self):
        resp = self.behaviors.create_order_overriding_cfg(
            payload_content_type='text/plain')
        create_resp = resp.create_resp

        # Make sure we actually get a message back
        error_msg = json_to_dict(create_resp.content).get('title')

        self.assertEqual(create_resp.status_code, 400)
        self.assertIsNotNone(error_msg)
        self.assertNotEqual(error_msg, 'None')
Пример #3
0
    def test_empty_error_message_on_invalid_order_creation(self):
        """Related Launchpad issue: 1269594"""
        resp = self.behaviors.create_order_overriding_cfg(
            payload_content_encoding='blarg!')
        create_resp = resp.create_resp

        # Make sure we actually get a message back
        error_msg = json_to_dict(create_resp.content).get('title')

        self.assertEqual(create_resp.status_code, 400)
        self.assertIsNotNone(error_msg)
        self.assertNotEqual(error_msg, 'None')
Пример #4
0
    def test_empty_error_message_on_invalid_order_creation(self):
        """Related Launchpad issue: 1269594"""
        resp = self.behaviors.create_order_overriding_cfg(
            payload_content_encoding='blarg!')
        create_resp = resp.create_resp

        # Make sure we actually get a message back
        error_msg = json_to_dict(create_resp.content).get('title')

        self.assertEqual(create_resp.status_code, 400)
        self.assertIsNotNone(error_msg)
        self.assertNotEqual(error_msg, 'None')
Пример #5
0
 def disks(self):
     return json_to_dict(self.get('disks'))
Пример #6
0
 def load_average(self):
     return json_to_dict(self.get('load_average'))
Пример #7
0
    #     print("TEST 5 FAILED...\n")
    #     print("INPUT: " + arg)
    #     print("Parsed: " + my_out[0])
    #     print("Unigrams: " + my_out[1])
    #     print("Bigrams: " + my_out[2])
    #     print("Trigrams: " + my_out[3])
    #     return
    # num_tests += 1

    print("* * All %d tests passed. * *" %
          num_tests)  # DO NOT REMOVE THIS LINE


########################################################################################################################################################
########################################################################################################################################################

if __name__ == "__main__":
    if len(sys.argv) == 2:
        print("Parsing file: {}".format(sys.argv[1]))
        with open(sys.argv[1], "r") as json_file:
            cleaned = []
            for line in json_file:
                comment = json_to_dict(line)['body']
                print("BEFORE: {}".format(comment))
                cleaned.append(sanitize(comment))
                print(">>> PARSED TEXT: {}".format(cleaned[-1][0]))
                print(">>> UNIGRAMS: {}".format(cleaned[-1][1]))
                print(">>> BIGRAMS: {}".format(cleaned[-1][2]))
                print(">>> TRIGRAMS: {}".format(cleaned[-1][3]))
    else:
        sys.exit("USAGE: python3 cleantext.py <filename>")
Пример #8
0
 def native(self):
     return json_to_dict(self.get('native'))
Пример #9
0
import socket
from json import loads as json_to_dict,dumps as dict_to_json
from time import time,ctime,sleep

def getUser(i):
	surnames = ['Алфьоров','Волосожар','Гладкий','Дворніцька','Збаровський','Карабінський','Кисельова','Кумпан','Лобунько','Лукашевич','Мишкарьова','Мумінов','Погребенко','Радченко','Сєров','Соловйова','Тарабара']
	return {'id':i,'surname':surnames[i%len(surnames)]+str(i//len(surnames))}

clients = [socket.socket(socket.AF_INET, socket.SOCK_STREAM) for i in range(11)]

for i in range(len(clients)):
	clients[i].connect((socket.gethostname(), 1234))
	clients[i].send(bytes(dict_to_json(getUser(i)),'utf-8'))
	# sleep(0.5)

for i in range(len(clients)):
	while True:
		data = clients[i].recv(4000)
		if data:
			data1 = json_to_dict(data.decode('utf-8'))
			print(f'Доброго дня {getUser(i)["surname"]} зараз онлайн:')
			print(' id |      прізвище      |       дата підключення       |      дата старту таймера     ')
			print('----+--------------------+------------------------------+------------------------------')
			for j in data1.keys():
				print('%3s |%19s |%29s |%29s ' % (data1[j]['id'],data1[j]['surname'],ctime(data1[j]['date']),ctime(data1[j]['timer_start']) ) )
			print('')
			break
Пример #10
0
 def db_host(self):
     return json_to_dict(self.get("db_hosts"))
Пример #11
0
print(f'{ctime(time())} : Сервер успішно запущено')

while True:
    clientsocet, address = s.accept()

    conection_time = time()
    print(f'{ctime(conection_time)} : нове з`єднання від {address}')

    if time() - timer_start_time > 11:
        timer_start_time = 0
    if timer_start_time == 0:
        timer_start_time = time()
        print(f'{ctime(timer_start_time)} : таймер стартував')

    data = json_to_dict(clientsocet.recv(1024).decode('utf-8'))

    online_list[str(data['id'])] = {
        'id': data['id'],
        'surname': data['surname'],
        'date': conection_time,
        'timer_start': timer_start_time
    }

    def sendResult(clientsocet, id):
        clientsocet.send(bytes(dict_to_json(online_list), 'utf-8'))
        clientsocet.close()
        print(
            f'{ctime(time())} : 11 секунд вийшло, дані надіслано до {online_list[str(id)]["surname"]}, з`єднання завершено'
        )
Пример #12
0
 def db_host(self):
     return json_to_dict(self.get("db_hosts"))