Exemple #1
0
    def __init__(self, startupHostsList):
        self.__memberList = []
        self.__deadList = []
        self.__t_gossip = 1000
        self.__t_cleanup = 10000
        port = 0
        myIpAddress = self.getMyIpAddress('192.168.0.0')
        self.__myAddress = (myIpAddress, port)

        for host in startupHostsList:
            member = mem.Member(host, 0, self, self.__t_cleanup)
            if host.count(myIpAddress) > 0:
                self.__me = member
                port = host[1]
                self.__myAddress = (myIpAddress, port)
            self.__memberList.append(member)

        print "Original Member List"
        print "--------------------"
        for member in self.__memberList:
            print member

        if port != 0:
            self.__server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            self.__server.bind(("", port))
        else:
            print "Cloud not find myself in startup list"
            sys.exit(-1)

        self.__deadListCond = threading.Condition()
        self.__memberListCond = threading.Condition()
Exemple #2
0
def RegisterFamily():
    firstName = input("Enter your first name: ")
    lastName = input("Enter your last name: ")
    user = member.Member(firstName, lastName)
    members.append(user)
    Family = {'members': members, 'id': fid}
    print(Family['members'][0])
Exemple #3
0
    def add_member(self):
        """Get the values from the bound variables and create a new Member."""
        if self.__name.get() != '':
            c = member.Member(self.__name.get())
            self.__members.append(c)

            # Add this Member's __str__ output to the listbox
            self.__members_list.insert(tkinter.END, str(c))

        self.after_selected_operation()
Exemple #4
0
    def setUpClass(cls):
        # called once at beginning 
        print('setUpClass()')

        # create gym instance 
        cls.gym = gym.Gym()

        # initialize gym member instances (member ID's 0-7)
        cls.connor = member.Member('Connor')
        cls.vanessa = member.Member('Vanessa')
        cls.tina = member.Member('Tina')
        cls.joe = member.Member('Joe')
        cls.seth = member.Member('Seth')
        cls.scott = member.Member('Scott')
        cls.mary = member.Member('Mary')
        cls.max = member.Member('Max')

        # initialize gym equipment instances 
        cls.benchPress = equipment.Equipment('Bench Press', 'Weight Training')
        cls.inclineBench = equipment.Equipment('Incline Bench', 'Weight Training')
        cls.declineBench = equipment.Equipment('Decline Bench', 'Weight Training')
        cls.kettleBells = equipment.Equipment('Kettle Bells', 'Weight Training')
        cls.treadmill1 = equipment.Equipment('Treadmill', 'Cardio')
        cls.treadmill2 = equipment.Equipment('Treadmill', 'Cardio')
        cls.rowMachine = equipment.Equipment('Row Machine', 'Cardio')
        cls.resistanceBands = equipment.Equipment('Resistance Bands', 'Stretching')
        cls.wobbleBoard = equipment.Equipment('Wobble Board', 'Balance')

        # add member instances to gym member set 
        cls.gym.add_member(cls.connor)
        cls.gym.add_member(cls.vanessa)
        cls.gym.add_member(cls.tina)
        cls.gym.add_member(cls.joe)
        cls.gym.add_member(cls.seth)
        cls.gym.add_member(cls.scott)
        cls.gym.add_member(cls.mary)
        cls.gym.add_member(cls.max)

        # add equipment instances to gym equipment set 
        cls.gym.add_equipment(cls.benchPress)
        cls.gym.add_equipment(cls.inclineBench)
        cls.gym.add_equipment(cls.declineBench)
        cls.gym.add_equipment(cls.kettleBells)
        cls.gym.add_equipment(cls.treadmill1)
        cls.gym.add_equipment(cls.treadmill2)
        cls.gym.add_equipment(cls.rowMachine)
        cls.gym.add_equipment(cls.resistanceBands)
        cls.gym.add_equipment(cls.wobbleBoard)
Exemple #5
0
def initMemberRegister():
    try:
        medreg = openpyxl.load_workbook(paths.xlsx_member_register)
        medSheet = medreg[medreg.sheetnames[0]]
        for row in range(2, medSheet.max_row + 1):
            keyCard = medSheet['A' + str(row)].value
            name = medSheet['B' + str(row)].value
            board_member = medSheet['C' + str(row)].value == 'Styret'
            latest_activity = medSheet['D' + str(row)].value
            member.Member(keyCard, name, board_member, latest_activity)
    except:
        print("Could not find member register.\n" +
              "Please place the member register in the following folder\n" +
              paths.xlsx_member_register)
Exemple #6
0
    def load_members(self):
        members_file = filedialog.askopenfile(initialdir=os.getcwd(), title="Open file",
                                              filetypes=(("text files", "*.txt"), ("all files", "*.*")))
        try:
            for person in members_file:
                c = member.Member(person[:-1])
                self.__members.append(c)
                self.__members_list.insert(tkinter.END, str(c))
        except TypeError:
            pass

        try:
            members_file.close()
        except AttributeError:
            pass

        self.after_selected_operation()
Exemple #7
0
    def create_child(self, parents, gen):
        m = member.Member(gen)

        # chooses from parent's traits randomly
        for trait_type in trait.INHERITED_TRAIT_TYPES:
            possible_trait_values = []
            for p in parents:
                possible_trait_values.append(p.get_inherited_trait(trait_type))

            choice = random.choice(possible_trait_values)

            m.set_inherited_trait(trait_type, choice)

        # log relationship in parents and child
        for p in parents:
            p.append_aquired_trait("children", m)
            m.append_aquired_trait("parents", p)

        return m
Exemple #8
0
def create_members(num_members, tf_env=None):
    """ Can go inside Population class with more parametrization options depending on use-case. """
    if tf_env is None:
        tf_env = get_tf_env()
    members = list()
    for i in range(num_members):
        actor_net, value_net = get_networks(tf_env, FP.ACTOR_FC_LAYERS,
                                            FP.VALUE_FC_LAYERS)
        agent = get_tf_ppo_agent(tf_env,
                                 actor_net,
                                 value_net,
                                 member_id=i,
                                 num_epochs=FP.PPO_NUM_EPOCHS)
        replay_buffer = get_replay_buffer(agent.collect_data_spec)
        step_metrics, train_metrics = get_metrics()
        members.append(
            member.Member(agent,
                          replay_buffer,
                          step_metrics=step_metrics,
                          train_metrics=train_metrics))
    return members
Exemple #9
0
def importNewMembers():
    try:
        medreg = openpyxl.load_workbook(paths.xlsx_new_members)
        medSheet = medreg[medreg.sheetnames[0]]
        for row in range(2, medSheet.max_row + 1):
            key_card = cardreaderParser(medSheet['A' + str(row)].value)
            name = medSheet['B' + str(row)].value
            board_member = medSheet['C' + str(row)].value == 'Styret'
            latest_activity = datetime.now().strftime("%Y-%m-%d")
            member.Member(key_card, name, board_member, latest_activity)
        medreg.close()
    except:
        print('Unable to import new members')
    medreg = openpyxl.Workbook()
    medSheet = medreg.active
    medSheet.title = 'Nya medlemmar'
    medSheet['A1'] = 'Nyckelnr'
    medSheet['B1'] = 'Namn'
    medSheet['C1'] = 'Anmärkning'
    medreg.save(paths.xlsx_new_members)
    medreg.close()
    saveMemberlistToFile()
Exemple #10
0
    def __init__(self, parent=None, xmlpath=''):
        super(Ui_MemberMainWindow, self).__init__(parent)
        self.setupUi(self)

        self.member = member.Member(xmlpath)
        name = self.member.getName()
        dep = self.member.getDepartment()
        self.name_line.setText(name)
        self.dep_line.setCurrentIndex(dep)
        curDate = QtCore.QDate.currentDate()
        self.apply_date.setDate(curDate)
        self.query_fromdate.setDate(curDate)
        self.query_todate.setDate(curDate)
        self.apply_date.setEnabled(False)

        self.projectDict = self.member.getProjectsFromServer()
        for pro in self.projectDict:
            self.apply_project.addItem(pro)
            self.query_project.addItem(pro)
        self.tabWidget.setCurrentIndex(0)

        self.result_window = Ui_QueryTable()

        self.setConnections()
Exemple #11
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("member_list",
                        help="A tsv file pulled from the EHouse Genealogy")
    parser.add_argument("-o",
                        "--out_file",
                        help="The output filename (will have .pdf appended)",
                        default=DEFAULT_FILE_NAME)
    parser.add_argument("-q",
                        "--quiet",
                        action='store_true',
                        help="Does not print a list of unconnected members")

    args = parser.parse_args()
    """
	if(len(sys.argv) != 2):
		usage()
		exit()
	"""

    readFile = ""
    try:
        readFile = open(args.member_list, 'r+')
    except FileNotFoundError as e:
        print("File does not exist, try again asshole.")
        exit()

    roster = {}
    lines = []

    # ['Last Name', 'First Name', 'Nickname', 'Mentee(Formatted)', 'Name of Mentor(s)', 'Adopted Mentor(s)', 'Positions', '\n']

    lineNum = 0
    for line in readFile:
        if (lineNum != 0):
            readLine = line.split('\t')
            lines += [readLine]

            attrib = ''
            attribs = readLine[6].strip().split(',')
            for attr in attribs:
                attrib += member.strToAttr(attr.strip())

            newMem = member.Member(readLine[3], attrib, readLine[2])
            roster[newMem.name] = newMem

        lineNum += 1

    for line in lines:
        name = line[3]
        mentors = line[4].split(',')
        adoptors = line[5].split(',')
        for mentor in mentors:
            if (mentor != ''):
                roster[name].addMentor(roster[mentor.strip()])

        for adoptor in adoptors:
            if (adoptor != ''):
                roster[name].addAdoptor(roster[adoptor.strip()])

    graph = graphviz.Digraph("Relations", format='pdf')

    graph.attr(label="""<
<TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0">
	<TR><TD COLSPAN="3" BORDER="1"><B>Engineering House Lines</B></TD></TR>
	<TR><TD ALIGN="left">Dashed Line</TD><TD>--&gt;</TD><TD ALIGN="right">Adoption</TD></TR>
	<TR><TD ALIGN="left">Blue Outline</TD><TD>--&gt;</TD><TD ALIGN="right">EBoard</TD></TR>
	<TR><TD ALIGN="left">Yellow Outline</TD><TD>--&gt;</TD><TD ALIGN="right">Cabinet</TD></TR>
</TABLE>>""")
    graph.attr(labeljust='l')
    graph.attr(labelloc='t')

    if not args.quiet:
        print("Unconnected members:")

    for mem in roster:
        if not roster[mem].isIsolated():
            if (roster[mem].isEBoard()):
                graph.node(mem, mem, color='blue')
            elif (roster[mem].isCabinet()):
                graph.node(mem, mem, color='gold')
            else:
                graph.node(mem, mem)

            if (len(roster[mem].mentees) == 0
                ):  # and len(roster[mem].adoptees) == 0):
                graph.node(mem, mem, shape='egg')

            for mentee in roster[mem].mentees:
                graph.edge(mem, mentee.name)

            for adoptee in roster[mem].adoptees:
                graph.edge(mem, adoptee.name, style='dashed')
        elif not args.quiet:
            print(f'{roster[mem].name}')

    graph.render(args.out_file)
Exemple #12
0
import member
import boss
import hentai

GRP_MSG_PARSE_INIT_FLAG = True

BOSS = boss.Boss()
MEMBER = member.Member()

def help():
    ret = '''ENE です,兰德索尔排刀助手
    (✪ω✪)
    boss/王
    出刀/申请出刀
    报刀/提交伤害
    队列
    已出刀
    未出刀
    统计
    修正/数据修正'''
    return ret

## 完成内容解析后,构造该结构用于发送到群里
def new_ret_dict(data):
    ret = { "toUser":data['FromGroupId'], 
            "sendToType":2,       
            "sendMsgType":"TextMsg",     
            "content":"",     
            "groupid":0,       
            "atUser":0,      
            "replayInfo":'null'
Exemple #13
0
    def _getTaskListByPersonal(self, project, dpt, extTask):
        """
        按组列出 人员-任务
        :param project: 项目
        :param dpt: 部门
        :param extTask:
        :return:
        """
        """mongoDB数据库
        """
        self.mongodb.connect_db(project)

        if self.landmark is None:
            _search = {
                "issue_type": {
                    "$ne": ["epic", "story"]
                },
                "$or": [{
                    "spent_time": {
                        "$ne": None
                    }
                }, {
                    "org_time": {
                        "$ne": None
                    }
                }],
                "$and": [{
                    self.whichdate: {
                        "$gte": "%s" % self.st_date
                    }
                }, {
                    self.whichdate: {
                        "$lt": "%s" % self.ed_date
                    }
                }]
            }
        else:
            _search = {
                "issue_type": {
                    "$ne": ["epic", "story"]
                },
                "landmark":
                self.landmark,
                "$or": [{
                    "spent_time": {
                        "$ne": None
                    }
                }, {
                    "org_time": {
                        "$ne": None
                    }
                }],
            }
        _cur = self.mongodb.handler('issue', 'find', _search)

        if _cur.count() == 0:
            return

        for _issue in _cur:
            if _issue['users'] is None:
                continue
            if _issue['users'] in spi_list:
                continue
            if _issue['users'] not in self.members:
                """有可能是:1)新员工;2)外包人员"""
                logging.log(logging.WARN,
                            u">>> user(%s) not in members" % _issue['users'])
                continue

            if u"项目开发" in dpt:
                if self.members[_issue['users']] not in pj_devel_dpt:
                    continue
            else:
                if self.members[_issue['users']] not in dpt:
                    continue
            if _issue['users'] not in self.personal:
                self.personal[_issue['users']] = member.Member(
                    _issue['users'], self.members[_issue['users']])
            _task = {}
            for _i in [
                    'issue', 'summary', 'status', 'org_time', 'agg_time',
                    'spent_time', 'sprint', 'created', 'updated'
            ]:
                _task[_i] = _issue[_i]

            _issue_class = _issue['issue'].split('-')[0]
            if _issue_class in handler.pd_list:
                _task['ext'] = False
                if _issue in extTask:
                    _task['ext'] = True
            else:
                _task['ext'] = True

            self.personal[_issue['users']].add_task(_task)
Exemple #14
0
 def setUp(self):
     self.node = fake_network.FakeNode()
     self.member = member.Member(self.node)
Exemple #15
0
def main():

    if (len(sys.argv) != 2):
        usage()
        exit()

    readFile = ""
    try:
        readFile = open(sys.argv[1], 'r+')
    except FileNotFoundError as e:
        print("File does not exist, try again asshole.")
        exit()

    roster = {}
    lines = []

    # ['Last Name', 'First Name', 'Nickname', 'Mentee(Formatted)', 'Name of Mentor(s)', 'Adopted Mentor(s)', 'Positions', '\n']

    lineNum = 0
    for line in readFile:
        if (lineNum != 0):
            readLine = line.split('\t')
            lines += [readLine]

            attrib = ''
            attribs = readLine[6].strip().split(',')
            for attr in attribs:
                attrib += member.strToAttr(attr.strip())

            newMem = member.Member(readLine[3], attrib, readLine[2])
            roster[newMem.name] = newMem

        lineNum += 1

    for line in lines:
        name = line[3]
        mentors = line[4].split(',')
        adoptors = line[5].split(',')
        for mentor in mentors:
            if (mentor != ''):
                roster[name].addMentor(roster[mentor.strip()])

        for adoptor in adoptors:
            if (adoptor != ''):
                roster[name].addAdoptor(roster[adoptor.strip()])

    graph = graphviz.Digraph("Relations", format='pdf')

    for mem in roster:
        if (roster[mem].isEBoard()):
            graph.node(mem, mem, color='blue')
        elif (roster[mem].isCabinet()):
            graph.node(mem, mem, color='gold')
        else:
            graph.node(mem, mem)

        for mentee in roster[mem].mentees:
            graph.edge(mem, mentee.name)

        for adoptee in roster[mem].adoptees:
            graph.edge(mem, adoptee.name, style='dashed')

    graph.render('relations')
    def post(self):
        self.response.headers.add_header("Access-Control-Allow-Origin", "*")

        STR_VERSERVER = '01060000'
        INT_VERCLIENT = 0x01060000
        STR_VERCLIENT = '1.6'

        if not os.environ.has_key('HTTPS'):
            self.resp_simple(0, 'HTTPS environment variable not found')
            return

        if not os.environ.has_key('CURRENT_VERSION_ID'):
            self.resp_simple(0, 'CURRENT_VERSION_ID environment variable not found')
            return

        HTTPS = os.environ.get('HTTPS', 'off')
        CURRENT_VERSION_ID = os.environ.get('CURRENT_VERSION_ID', STR_VERSERVER)
        
        # SSL must be enabled
        if HTTPS.__str__() != 'on':
            self.resp_simple(0, 'Secure socket required.')
            return

        minlen = 4 + 32
                
        # get the data from the post
        self.response.headers['Content-Type'] = 'application/octet-stream'
        data = self.request.body
    
        size = str.__len__(data)

        if size < minlen:
            self.resp_simple(0, 'Request was formatted incorrectly.')
            return
         
        # unpack all incoming data
        server = int(CURRENT_VERSION_ID[0:8], 16)
        client = (struct.unpack("!i", data[0:4]))[0]
        data = data[4:]
 
        # client version check
        if client < INT_VERCLIENT:
            self.resp_simple(0, ('Client version mismatch; %s required.  Download latest client release first.' % STR_VERCLIENT))
            return        

        # assign grouping id number
        num = 1
        while (num > 0):
            # we get the current numbers in the database
            query = member.Member.all()
            num = query.count()

            # we know how many are left in the current range
            if (num >= 999):
                maxUsers = 9999
            elif (num >= 99):
                maxUsers = 999
            else:
                maxUsers = 99

            # we know we can build a set of what remains
            used = []
            for m in query:
                used.append(m.usr_id)
                
                # each commitment must be unique
                if str(m.commitment) == str(data):
                    self.resp_simple(0, 'Request was formatted incorrectly.')
                    return        

            # create a super set of all items from smallest to largest
            # also don't assign 1-10 so that users won't confuse the # of users with the grouping id 
            full = set(xrange(11, maxUsers + 1))
            avail = sorted(full - set(used))   
    
            # we know can get a random number of the remaining range
            # we know what position the random number will be at
            # we know the new number
            r = random.SystemRandom()
            usrid = r.choice(avail)       

            # we check the new number against the database again
            query = member.Member.all()
            query.filter('usr_id =', usrid)
            num = query.count()

            # if number is taken by now, we start over again
            if num > 0:
                logging.info("found duplicate usr_id=" + str(usrid) + ", retrying...")
 
        # return the user id
        mem = member.Member(usr_id=usrid, commitment=data, client_ver=client)
        mem.put()
        key = mem.key()
        if not key.has_id_or_name():
            self.resp_simple(0, 'Unable to create new user.')
            return       
                              
        # version
        self.response.out.write('%s' % struct.pack('!i', server))

        # user id assigned
        self.response.out.write('%s' % struct.pack('!i', usrid))