def get_output_data(unc_gr): output_list = [] for group in unc_gr: try: group = Group(group) output_list.append(group.get_group_data()) except Exception as e: pass return output_list
def __get_group(self, group_type_desc, group_label: Optional[str], part_of_label) -> Optional[Group]: if not group_label: return None group_type_label = group_label group_type = _group_types[group_type_desc] part_of_group = (self.__get_group(part_of_label, (), ()) if part_of_label else None) group = Group(self._graph, group_label, group_type) if part_of_group: group.add_relationship(Nampi_type.Core.is_part_of, part_of_group) return group
def test_edit_group(app, db, check_ui): if app.group.count() == 0: app.group.create_group( Group(name="username", header="testheader", footer="testfooter")) old_group = db.get_group_list() group = Group(name="_test_to_check_edit222", header="_test_to_check_edit222", footer="_test_to_check_edit222") group_random = random.choice(old_group) app.group.edit_group_by_id(group, group_random.id) assert len(old_group) == app.group.count() new_group = db.get_group_list() if (check_ui): assert sorted(new_group, key=Group.id_or_max) == sorted( app.group.get_group_list(), key=Group.id_or_max)
def get_related_group_contact(self): for yx in self.get_all_group_id(): li = self.get_contacts_in_group(Group(id=yx)) if len(li) > 0: return li[0].id, yx else: return False
def loginRobot(): logger.info("Robot login") if not settings.IS_TEST_ENV: Slack.sendLoginNotice("Robot *{}* had login.".format( robotName, robotId)) robot.releaseLoginRobot(robotId) robot.updateHeartBeat(robotId) try: _thread.start_new_thread(robot.online, (robotId, )) except: logger.error("Error: unable to start thread") sys.exit(0) group = Group(newInstance, robotId) try: _thread.start_new_thread(group.fetechAndAddGroupRepeat, ()) except: logger.error("Error: unable to start thread") sys.exit(0) try: _thread.start_new_thread(group.fetechAndInvitRequestRepeat, ()) except: logger.error("Error: unable to start thread") sys.exit(0)
def get_not_related_group_contact(self): for y in self.get_all_group_id(): l = self.get_contacts_not_in_group(Group(id=y)) if len(l) > 0: return l[0].id, y else: return False
def __get_group(self, group_label: Optional[str]) -> Optional[Group]: if not group_label: return None group_type_label = self.__sheet.get_from_table(Table.GROUPS, Column.name, group_label, Column.type) part_of_label = self.__sheet.get_from_table(Table.GROUPS, Column.name, group_label, Column.part_of) group_type = (_group_types[group_type_label] if group_type_label else Nampi_type.Core.group) part_of_group = self.__get_group( part_of_label) if part_of_label else None group = Group(self._graph, group_label, group_type) if part_of_group: group.add_relationship(Nampi_type.Core.is_part_of, part_of_group) return group
def test_add_contact_to_group(app): if (len(db.get_contact_list()) == 0): app.contact.new_contact_creation( Contact(firstname="Test_Firstname", middlename="Test_Middlename", lastname="Test_lastname", nickname="Test_Nickname", title="Test_title", company="Company", address="Test_adress", home="Home", mobile="mobile", work="Test_work", fax="Test_fax", email="Test_email", email1="Test_email1", email2="Test_email2", email3="Test_email3", address2="Test_adress2", homepage="Test_homepage", bday="5", bmounth="July", byear="1982", aday="2", amonth="July", ayear="2003", phone2="Test_phone2", notes="Test_notes")) if app.group.count() == 0: app.group.create_group(Group(name="username", header="testheader", footer="testfooter")) if db.get_related_group_contact() == False: free_contact, free_group = db.get_not_related_group_contact() app.contact.add_contact_to_group(free_contact, str(free_group)) related_contact, related_group = db.get_related_group_contact() app.contact.delete_contact_from_group(related_contact, str(related_group)) assert str(related_contact) not in db.get_list_id_contact_in_group(Group(id=related_group))
def get_group_list(self): if self.cache_group is None: wd = self.app.wd self.open_groups_page() self.cache_group = [] for element in wd.find_elements_by_xpath("//body//span"): text = element.text id = element.find_element_by_name("selected[]").get_attribute("value") self.cache_group.append(Group(name = text, id = id)) return list(self.cache_group)
def group(): try: session['email'] session['group'] if not Group.checkIfGroupIsRated(session['email'], session['group'], conn): return render_template('groupPage.html', group=session['group']) else: return render_template('groupPage.html', group=session['group'], rated=True) except: return redirect('/login')
def getRatingAverage(): try: ratingSum = 0 ratings = Group.getRatings(session['group'], conn) if len(ratings) == 0: return json.dumps({'averageRating': 5}) for rating in ratings: ratingSum += rating['rating'] return json.dumps({'averageRating': ratingSum / len(ratings)}) except: return json.dumps({'averageRating': -1})
def test_delete_some_group(app, db, check_ui): if len(db.get_group_list()) == 0: app.group.create_group( Group(name="username", header="testheader", footer="testfooter")) old_group = db.get_group_list() group = random.choice(old_group) app.group.delete_group_by_id(group.id) new_group = db.get_group_list() old_group.remove(group) assert old_group == new_group if (check_ui): assert sorted(new_group, key=Group.id_or_max) == sorted( app.group.get_group_list(), key=Group.id_or_max)
def get_group_list(self): list = [] cursor = self.connection.cursor() try: cursor.execute( "select group_id, group_name, group_header, group_footer from group_list" ) for row in cursor: (id, name, header, footer) = row list.append( Group(id=str(id), name=name, header=header, footer=footer)) finally: cursor.close() return list
def leaveGroup(message): try: if not activeGroups: return group = getGroupObject(session['group']) if group is None: return group.getMutex().acquire() clients = group.getClients() clients.remove(request.sid) if not clients: Group.removeGroup(session['group'], conn) activeGroups.remove(group) finally: try: group.getMutex().release() except: pass leave_room(session['group']) emit('update', {'msg': datetime.datetime.now().strftime('[%I:%M:%S %p] ') + session['username'] + ' left the group.'}, room=session['group']) session['group'] = None
def createGroupAuth(): email = session['email'] groupName = request.form['GroupName'] if not Group.checkIfGroupExists(groupName, conn): Group.insertGroupDetails(email, groupName, conn) newGroup = Group(groupName, User.fetchUsername(session['email'], conn)) activeGroups.append(newGroup) session['group'] = newGroup.name newGroup.startDJRotateThread() return redirect('/group') else: error = 'A group with this name already exists! Please try again.' return render_template('createGroup.html', error=error)
def clean(group): return Group(id=group.id, name=group.name.strip())
def rateGroupRating(message): try: Group.insertGroupRating(session['email'], session['group'], int(message['msg']), conn) except: pass
def test_insertGroupRating(): Group.insertGroupRating(email1, group1, rating1, conn) assert Group.getRatings(group1, conn) == [{'rating': 4}] Group.insertGroupRating(email2, group2, rating2, conn) assert Group.getRatings(group2, conn) == [{'rating': 5}] assert Group.getRatings(group3, conn) == ()
def test_checkIfGroupIsRated(): assert Group.checkIfGroupIsRated(email1, group1, conn) == {'email': '*****@*****.**', 'groupName': 'Psychedelic Rock', 'rating': 4} assert Group.checkIfGroupIsRated(email2, group2, conn) == {'email': '*****@*****.**', 'groupName': 'Anton LaVey Chants', 'rating': 5} assert Group.checkIfGroupIsRated(email3, group3, conn) == None
def test_removeGroup(): Group.removeGroup(group1, conn) assert Group.checkIfGroupExists(group1, conn) == None Group.removeGroup(group2, conn) assert Group.checkIfGroupExists(group2, conn) == None assert Group.checkIfGroupExists(group3, conn) == None
from modules.group import Group import random import string testdata = [ Group(name="testname1569", header="testheader15478", footer="testfooter101478") ] ''' def random_string(prefix, maxlen): symbols = string.ascii_letters + string.digits + string.punctuation + " "*10 return prefix + '_'.join([random.choice(symbols) for i in range(random.randrange(maxlen))]) test_data = [Group(name="testname", header="testheader", footer="testfooter")] + [ Group(name = random_string("name", 10), header= random_string("header", 20), footer = random_string("footer", 15)) for i in range(2)] '''
def test_insertGroupDetails(): Group.insertGroupDetails(email1, group1, conn) assert Group.checkIfGroupExists(group1, conn) == {'ownerEmail': '*****@*****.**', 'groupName': 'Psychedelic Rock'} Group.insertGroupDetails(email2, group2, conn) assert Group.checkIfGroupExists(group2, conn) == {'ownerEmail': '*****@*****.**', 'groupName': 'Anton LaVey Chants'} assert Group.checkIfGroupExists(group3, conn) == None
if not os.path.exists(LOG_PATH): os.makedirs(LOG_PATH) logging.basicConfig(format=u'%(levelname)-8s [%(asctime)s] %(message)s', level=logging.INFO, filename=u'{}{}.log'.format(LOG_PATH, LOG_NAME)) logging.info('\n') # Отделять логи пустой строкой REMOTE_FTP_SERVER_HOSTNAME = CONFIG['ftp_server'] REMOTE_FTP_SERVER_USERNAME = CONFIG['ftp_username'] REMOTE_FTP_SERVER_PASSWORD = CONFIG['ftp_password'] SWDB = DB() ZABBIX_HOST = Host() ZABBIX_GROUP = Group() ZABBIX_HOSTINTERFACE = Hostinterface() ABK_PROXY_ID = CONFIG['abk_proxyid'] BRK_PROXY_ID = CONFIG['brk_proxyid'] # irk_proxyid = config['irk_proxyid'] KNS_PROXY_ID = CONFIG['kns_proxyid'] KRK_PROXY_ID = CONFIG['krk_proxyid'] def download_file(): # Загрузка файла выгрузки СВДБ с удаленного фтп сервера ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(REMOTE_FTP_SERVER_HOSTNAME,
def convert(group): return Group(id=str(group.id), name=group.name, header=group.header, footer=group.footer)