def false(condition, message_on_fail): try: assert not condition, message_on_fail except AssertionError as err: err_type = err.__class__.__name__ log.error(err_type) raise err
def base_driver_setup(request): test_name = request.node.test_name_ version = "{}: {} - {}".format(config.DEVICE_NAME, config.PLATFORM_NAME, config.PLATFORM_VERSION) log.debug("Start test: '{}'.".format(test_name)) log.debug("Appium Server: {}".format(config.APPIUM_SERVER_URL)) driver = Drivers.create_mobile(config.APPIUM_SERVER_URL, DC.set_capabilities()) request.cls.driver = driver yield # TODO: Implement process listener # if request.node.rep_setup.failed or request.node.rep_call.failed: # try: # driver.save_screenshot_as_file(project_constants.version + "_" + test_name) # except Exception as e: # log.error("Could not create screenshot or save html source. Error: {}. " # "\n May be driver was not initialized".format(e)) try: driver.save_screenshot_as_file(version + "_" + test_name) except Exception as e: log.error( "Could not create screenshot or save html source. Error: {}. " "\n May be driver was not initialized".format(e)) driver.quit()
def equals(expected, actual, message_on_fail): try: assert expected == actual, message_on_fail except AssertionError as err: err_type = err.__class__.__name__ log.error(err_type) log.debug("\n\texpected: %s \n\tactual: %s", expected, actual) raise err
def not_equals(expected, actual, message_on_fail): try: assert expected is not actual, message_on_fail except AssertionError as err: err_type = err.__class__.__name__ log.error(err_type) log.debug("%s should not be equal to %s", expected, actual) raise err
def contains(expected, actual, message_on_fail): try: assert expected in actual, message_on_fail except AssertionError as err: err_type = err.__class__.__name__ log.debug("\n\texpected: %s value contains actual: %s", expected, actual) log.error(err_type) raise err
def is_full_view_open(self): log.debug('Is full view image opened') full_view = self.driver.find_elements_by_id(self.FULL_VIEW_ID) if full_view: return True else: log.error('Full view not find') return False
def is_gallery_screen(self): log.debug('Gallery screen displayed') title = self.driver.find_element_by_id(self.TITLE_SCREEN_ID) if title.get_attribute('value') == 'GALLERY': return True else: log.error('Find screen "{}"'.format(title.get_attribute('value'))) return False
def parser(client, payload, main_number, friend_number, status): data = bert.decode(bytes(payload)) global main_id global friend_id if status == mime_enums.FRIEND_BAN: if data[0] == Atom("Profile"): for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] if field[0] == Atom('Contact') and field[1].split( b'_')[0] == string_to_bytes(friend_number): friend_id = field[1] client.publish(topic="events/1//api/anon//", payload=bytearray( friend(my_id=main_id, friend_id=friend_id, status=Atom(status))), qos=2, retain=False) if data[0] == Atom("Contact") and data[-1] == Atom('banned'): log.debug('Contact banned') client.disconnect() if status == mime_enums.FRIEND_UNBAN: if data[0] == Atom("Profile"): for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] if field[-1] == Atom('banned'): friend_id = field[1] client.publish(topic="events/1//api/anon//", payload=bytearray( friend(my_id=main_id, friend_id=friend_id, status=Atom(status))), qos=2, retain=False) if data[0] == Atom("Contact") and data[-1] == Atom('friend'): log.debug('Contact Unbanned') client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect()
def parser(client, payload, main_number, mime, message_type=None): data = bert.decode(bytes(payload)) global main_id global friend_id global chat global message_id if data[0] == Atom("Profile"): for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] friend_id = field[1] chat = p2p(from_user=main_id, to=main_id) client.publish(topic="events/1//api/anon//", payload=bytearray( message_model(mime, container=Atom('chain'), feed_id=chat, from_user=main_id, to=main_id)), qos=2, retain=False) if data[0] == Atom( 'Message') and message_type == 'delete for me' and data[-1] == []: message_id = data[1] client.publish(topic="events/1//api/anon//", payload=bytearray( send_message(main_id, friend_id, chat, mime, message_id, message_type, main_id)), qos=2, retain=False) elif data[0] == Atom('Message') and data[-1] == Atom('delete'): log.debug('Verify group patched') Verify.true(data[1], "No message ID") client.disconnect() elif data[0] == Atom('Message'): log.debug('Verify group patched') Verify.true(data[1], "No message ID") client.disconnect() elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def tap_add_contact(self, name): log.debug("Send friend request to: '{}'".format(name)) new_cont_list = self.driver.find_elements(*self.CONTACT_CELL) for element in new_cont_list: if element.find_element( *self.CONTACT_NAME).get_attribute('value') == name: self.el.tap_btn(self.ADD_BTN) break else: log.error("No {} in the list".format(name)) raise NoSuchElementException
def tap_contact(self, name): log.debug("Tap contact '{}'".format(name)) contacts = self.driver.find_elements(*self.CONTACT_CELL) for element in contacts: if element.find_element( *self.CONTACT_NAME).get_attribute('value') == name: self.el.tap_element(element) break else: log.error("No {} in the list".format(name)) raise NoSuchElementException
def add_user(self, user): log.debug("Add '{}' to group".format(user)) table = self.driver.find_elements(*self.PARTICIPANT_CELL) for cell in table: name = cell.find_element_by_id( self.PARTICIPANT_TITLE).get_attribute('value') if name == user: self.el.tap_element(cell) break else: log.error('No {} in list'.format(user)) raise NoSuchElementException
def parser(client, payload, first_name, last_name, user_name=None): data = bert.decode(bytes(payload)) global userid if data[0] == Atom('Profile') and (data[-1]) == Atom('init'): roaster = (bert.decode(bytes(payload))[3]) global user_id user_id = roaster[0][1] rost = roster(user_id=user_id, first_name=first_name, last_name=last_name, status=Atom('patch')) client.publish(topic="events/1//api/anon//", payload=bytearray(rost), qos=2, retain=False) elif data[0] == Atom('Roster') and (data[-1]) == Atom('patch'): log.debug(user_id) log.debug(user_name) rost = roster(user_id=user_id, my_username=user_name, status=Atom('nick')) log.debug(rost) client.publish(topic="events/1//api/anon//", payload=bytearray(rost), qos=2, retain=False) elif user_name and data[0] == Atom('Roster') and ( data[-1]) == Atom('nick'): log.info("Verify roster/nick updated") Verify.true(data[5] == string_to_bytes(user_name), 'Username does not set') client.disconnect() elif data[0] == Atom('Roster') and ( data[-1]) == Atom('patch') and user_name is None: log.info("Verify user register") Verify.true(data[2] == string_to_bytes(first_name), 'First Name doesnt update') client.disconnect() elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") elif data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def is_compressed(self): log.debug("Get last image size") image_msgs = self.driver.find_elements(*self.IMAGE_MESSAGE_BOX) last_msg = image_msgs[-1] texts = last_msg.find_elements_by_xpath(self.STATIC_TEXT) for text in texts: if re.findall(r'kB', text.get_attribute('value')): size = text.get_attribute('value').split(' ')[0] if int(float(size.replace(',', '.'))) in range(100, 200): return True log.error("Size equals '{}'".format( text.get_attribute('value'))) return False
def generateExternalLink(self, username, otp, config_param): try: if not username or not otp: raise Exception("username can't be none") site_url = self.env.get_item('general', 'site_url') token = "{0}:{1}".format(username, otp) full_url = "{0}{1}?code={2}".format(site_url, config_param, base64.encodestring(token)) return full_url except Exception as e: print(e.message) log.error(msg=e.message) return None
def generateExternalLink_forfile_user(self, username, filename): try: if not username: raise Exception("username can't be none") site_url = self.env.get_item('general', 'site_url') portal_url = self.env.get_item('general', 'portal_url') error_upload = self.env.get_item('general', 'error_upload') full_url = "{0}/{1}/{2}/?file={3}".format(site_url, portal_url, error_upload, filename) return full_url except Exception as e: print(e.message) log.error(msg=e.message) return None
def parser(client, payload, main_number, friend_phone): data = bert.decode(bytes(payload)) if data[0] == Atom('Profile') and data[8] == 'init': roas = (bert.decode(bytes(payload))[3]) global user_id user_id = roas[0][1] client.publish(topic="events/1//api/anon//", payload=bytearray( search(user_id=user_id, ref='phone', field='phone', type_r=Atom('=='), value=[friend_phone], status=Atom('contact'))), qos=2, retain=False) if data[0] == Atom('io') and data[1] == (Atom('ok'), b'phone'): if data[2][6]: friend_id = data[2][6][0][1] my = main_number + '_' + str(user_id) log.debug("Add user {} \r\n".format(str(friend_id))) client.publish(topic="events/1//api/anon//", payload=bytearray( friend(my_id=my, friend_id=friend_id, status=Atom('request'))), qos=2, retain=False) if not data[2][6]: log.debug('Contact not found') log.debug(data) client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect()
def send_email_msg(self, subject, message, recipient_list, html_message=True): try: if html_message: email_now(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=False, html_message=message) else: email_now(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=False) log.info("Email Was Sent to : {0} , Subject: {1}".format( recipient_list, subject)) except Exception as e: self.retry(e, countdown=3, max_retries=3) log.error(e.message)
def parser(client, payload, new_alias): data = bert.decode(bytes(payload)) global room_id global member_id if data[0] == Atom("Profile"): for field in data: if field and list == type(field): for room in field[0]: if room and list == type(room) and room[0][0] == Atom( 'Room'): for member_field in room[-1]: if member_field and list == type(member_field) and tuple == type(member_field[0]) \ and member_field[0][0] == Atom('Member'): global member_id member_id = member_field[0][1] client.publish(topic="events/1//api/anon//", payload=bytearray( member(member_id=member_id, container=Atom('chain'), alias=new_alias, status=Atom('patch'))), qos=2, retain=False) if data[0] == Atom('Member'): log.debug('Verify member patched') Verify.equals(string_to_bytes(new_alias), data[11], 'Not new alias') client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(client, payload, main_number): data = bert.decode(bytes(payload)) for node in data: if node == Atom('Profile') and data[8] == 'init': roster = (bert.decode(bytes(payload))[3]) user_id = roster[0][1] my = main_number + '_' + str(user_id) contacts = data[3][0][6] for field in contacts: if field[0] == Atom('Contact') and field[-1] == Atom('authorization'): client.publish(topic="events/1//api/anon//", payload=bytearray( friend(my_id=my, friend_id=field[1], status=Atom('confirm'))), qos=2, retain=False) if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(client, payload, room_name): data = bert.decode(bytes(payload)) global room_id global my_alias if data[0] == Atom("Profile"): for field in data: if field and list == type(field): for room in field[0]: if room and list == type(room) and room[0][0] == Atom('Room'): global room_id room_id = room[-1][1] global my_alias my_alias = data[3][0][4] if data[3][0][4] else data[3][0][2]+data[3][0][3] client.publish(topic="events/1//api/anon//", payload=bytearray( patch_group(room_id, room_name)), qos=2, retain=False) if data[0] == Atom('Message'): log.debug('Verify group patched') for field in data: if field and list == type(field) and tuple == type(field[0]): print(field[0][3]) Verify.equals(b'Group is renamed to "'+string_to_bytes(room_name)+b'"', field[0][3], 'No message about patch') client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(client, payload, name, main_number, friend_phone, avatar=False, alias_check=False, group_avatar=None): data = bert.decode(bytes(payload)) global user_id global main_id global main_first_name global main_last_name global main_alias global friend_id global friend_first_name global friend_last_name global friend_alias if data[0] == Atom('Profile') and data[8] == 'init': contacts = data[3][0][6] for field in contacts: if field[0] == Atom('Contact') and field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') user_id = main_id = field[1] main_first_name = field[3] main_last_name = field[4] main_alias = [] if field[5]: main_alias = field[5] if field[0] == Atom('Contact') and field[-1] == Atom('friend') and \ field[1].split(b'_')[0] == string_to_bytes(friend_phone): friend_id = field[1] friend_first_name = field[3] friend_last_name = field[4] friend_alias = [] if field[5]: friend_alias = field[5] room_id = 'Autotest_group_id'+str(time.time()).split('.')[0] friend_member = member(container=Atom('chain'), phone_id=friend_id, names=friend_first_name, surnames=friend_last_name, alias=friend_alias, status=Atom('member')) main_admin = member(container=Atom('chain'), phone_id=main_id, names=main_first_name, surnames=main_last_name, alias=main_alias, status=Atom('admin')) room_data = [] if group_avatar: avatar_module = Atom('Desc') avatar_id = 'Autotest_avatar' + str(time.time()).split('.')[0] mime = 'image' avatar_payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/Image_" \ "153310818583129_86FC1EF5-C297-4A1A-9FA1-A7D3C5E27E0E1533108186.jpg" parentid = [] avatar_data = [] room_data = [(avatar_module, avatar_id, mime, avatar_payload, parentid, avatar_data)] client.publish(topic="events/1//api/anon//", payload=bytearray( room(room_id=room_id,name=name,members=[bert.decode(friend_member)], admins=[bert.decode(main_admin)], data=room_data, room_status=Atom('create'))), qos=2, retain=False) if data[0] == Atom('Room') and alias_check: log.info('Verify group created and alias exist') Verify.true((data[15][10][0][3] == user_id + b' created the group' and ([field[0][11] for field in data if field and list == type(field) and int != type(field[0]) and field[0][-1] == Atom("admin")][0] == main_first_name + main_last_name)), "No message about creation") client.disconnect() elif data[0] == Atom('Room'): log.info("Verify group creation") Verify.true((data[15][10][0][3] == user_id + b' created the group' and (data[8] != [] if avatar else True)), "No message about creation") client.disconnect() elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") elif data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(chat_type, client, payload, main_number, friend_number, mime, message_type=None): data = bert.decode(bytes(payload)) global main_id global friend_id global p2p_chat global group_chat global message_id global member_id global group_friend_id if data[0] == Atom("Profile"): for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[8]: p2p_chat = field[8][3] group_chat = data[3][0][7][-1][7][0][3] group_friend_id = data[3][0][7][-1][1] if chat_type == 'p2p' or chat_type == 'myself': for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] if chat_type == 'myself': friend_id = main_id message_id = field[8][1] p2p_chat = field[8][3] if chat_type == 'p2p': if field[0] == Atom('Contact') and field[-1] == Atom('friend') and \ field[1].split(b'_')[0] == string_to_bytes(friend_number): friend_id = field[1] if field[8]: message_id = field[8][1] p2p_chat = field[8][3] feature_model = feature(id='Autotest_feature_id' + str(time.time()).split('.')[0], key='TimeZone', value='Europe/Kiev', group='JOB_TIMEZONE') message_model = bert.decode( send_message(main_id, friend_id, p2p_chat, mime, data[1], message_type)) act_model = act(name='publish', data=main_id) time_plus_ten_min = (int(str(time.time()).split('.')[0]) + 6000) * 1000 client.publish(topic="events/1//api/anon//", payload=bytearray( job(feed_id=act_model, time=time_plus_ten_min, data=[message_model], settings=feature_model, status=Atom('init'))), qos=2, retain=False) if chat_type == 'group': for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] message_id = data[3][0][7][-1][15][1] friend_id = data[3][0][7][-1][1] member_id = data[3][0][7][-1][7][0][1] log.debug('Send job') feature_model = feature(id='Autotest_feature_id' + str(time.time()).split('.')[0], key='TimeZone', value='Europe/Kiev', group='JOB_TIMEZONE') message_model = bert.decode( send_message(main_id, group_friend_id, group_chat, mime, data[1], message_type)) act_model = act(name='publish', data=main_id) time_plus_ten_min = (int(str(time.time()).split('.')[0]) + 600) * 1000 client.publish(topic="events/1//api/anon//", payload=bytearray( job(feed_id=act_model, time=time_plus_ten_min, data=[message_model], settings=feature_model, status=Atom('init'))), qos=2, retain=False) elif data[0] == Atom('Job') and data[-1] == Atom('pending'): log.debug('Verify job go to pending') Verify.true(data[0] == Atom('Job') and data[-1] == Atom('pending'), 'Job not in pending') client.disconnect() elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(client, payload, main_number, friend_phone, avatar=False, alias_check=False): data = bert.decode(bytes(payload)) global user_id global main_first_name global main_last_name if data[0] == Atom('Profile') and data[8] == 'init': contacts = data[3][0][6] for field in contacts: if field[0] == Atom('Contact') and field[1].split( b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') user_id = main_id = field[1] main_first_name = field[3] main_last_name = field[4] main_alias = [] if field[5]: main_alias = field[5] if field[0] == Atom('Contact') and field[-1] == Atom('friend') and \ field[1].split(b'_')[0] == string_to_bytes(friend_phone): friend_id = field[1] friend_first_name = field[3] friend_last_name = field[4] friend_alias = [] if field[5]: friend_alias = field[5] client.publish(topic="events/1//api/anon//", payload=bytearray( create_group(main_id, main_first_name, main_last_name, main_alias, friend_id, friend_first_name, friend_last_name, friend_alias, avatar)), qos=2, retain=False) if data[0] == Atom('Room') and alias_check: log.info('Verify group created and alias exist') Verify.true( (data[15][10][0][3] == user_id + b' created the group' and ([ field[0][11] for field in data if field and list == type(field) and int != type(field[0]) and field[0][-1] == Atom("admin") ][0] == main_first_name + main_last_name)), "No message about creation") client.disconnect() elif data[0] == Atom('Room'): log.info("Verify group creation") Verify.true((data[15][10][0][3] == user_id + b' created the group' and (data[8] != [] if avatar else True)), "No message about creation") client.disconnect() if data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(client, payload, first_name=None, last_name=None, user_name=None, avatar=None): data = bert.decode(bytes(payload)) if data[0] == Atom('Profile') and (data[-1]) == Atom('init'): roas = (bert.decode(bytes(payload))[3]) userid = roas[0][1] if user_name: first_name = '' last_name = '' avatar = [] status = Atom('nick') elif avatar: first_name = [] last_name = [] user_name = '' status = Atom('patch') else: avatar = [] status = Atom('patch') client.publish(topic="events/1//api/anon//", payload=bytearray( roster(user_id=userid, first_name=first_name, last_name=last_name, my_username='', avatar=avatar, status=status)), qos=2, retain=False) if data[0] == Atom('Roster') and (data[-1]) == Atom('nick'): log.info("Verify roster/nick updated") Verify.true(data[5] == string_to_bytes(user_name), 'Username does not set') client.disconnect() elif data[0] == Atom('Roster') and (data[-1]) == Atom('patch') and avatar: log.info("Verify roster/avatar updated") Verify.true(data[11] == string_to_bytes(avatar), 'Username does not set') client.disconnect() elif data[0] == Atom('Roster') and (data[-1]) == Atom('patch'): log.info("Verify roster/name updated") Verify.true(data[2] == string_to_bytes(first_name), 'Username does not set') client.disconnect() elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b'') or data == \ (Atom('io'), (Atom('error'), Atom('invalid_nick')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")
def parser(chat_type, client, payload, main_number, friend_number, mime, message_type=None): data = bert.decode(bytes(payload)) global main_id global friend_id global p2p_chat global group_chat global message_id global member_id global group_friend_id if data[0] == Atom("Profile"): for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[8]: p2p_chat = field[8][3] group_chat = data[3][0][7][-1][7][0][3] group_friend_id = data[3][0][7][-1][1] for field in data[3][0][6]: if field[0] == Atom('Contact') and field[-1] == Atom('friend') and \ field[1].split(b'_')[0] == string_to_bytes(friend_number): friend_id = field[1] if chat_type == 'p2p': for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] if field[0] == Atom('Contact') and field[-1] == Atom('friend') and \ field[1].split(b'_')[0] == string_to_bytes(friend_number): friend_id = field[1] if field[8]: message_id = field[8][1] d = send_message(main_id, friend_id, p2p_chat, mime, message_id, message_type, message_text=message_text) log.info('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(bert.decode(d)) + '\r\n') client.publish(topic="events/1//api/anon//", payload=bytearray(d), qos=2, retain=False) if chat_type == 'group': for field in data[3][0][6]: if field[-1] == Atom('friend'): if field[1].split(b'_')[0] == string_to_bytes(main_number): log.debug('Main profile found') main_id = field[1] message_id = data[3][0][7][-1][15][1] member_id = data[3][0][7][-1][7][0][1] d = send_message(main_id, group_friend_id, group_chat, mime, message_id, message_type, message_text=message_text) log.info('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(bert.decode(d)) + '\r\n') client.publish(topic="events/1//api/anon//", payload=bytearray(d), qos=2, retain=False) elif data[0] == Atom('Message') and data[11] == [Atom('forward')]: log.debug('Verify') log.debug(data) client.disconnect() elif data[0] == Atom('Message'): log.debug('Send job') message_model = [] if chat_type == 'p2p': message_model = bert.decode( send_message(main_id, group_friend_id, group_chat, mime, data[1], message_type='forward', message_text=message_text)) elif chat_type == 'group': message_model = bert.decode( send_message(main_id, friend_id, p2p_chat, mime, data[1], message_type='forward', message_text=message_text)) act_model = act(name='publish', data=main_id) client.publish(topic="events/1//api/anon//", payload=bytearray( job(feed_id=act_model, data=[message_model], status=Atom('init'))), qos=2, retain=False) elif data == (Atom('io'), (Atom('error'), Atom('invalid_data')), b''): log.error("Something going wrong") client.disconnect() raise InvalidData("Invalid data response") if data == (Atom('io'), (Atom('error'), Atom('permission_denied')), b''): log.error("Something going wrong") client.disconnect() raise PermissionDenied("No permission")