コード例 #1
0
ファイル: __init__.py プロジェクト: liam-middlebrook/rtphelp
def main():
    global phones
    global rtp_list

    ldap = CSHLDAP(ldap_user, ldap_password)

    phones = getPhoneUserList(ldap.members())

    # get active RTPs
    rtp_list = getPhoneUserList([rtp[1] for rtp in ldap.rtps()], True)
    app.run(debug=True, host='0.0.0.0', port=6969)
コード例 #2
0
ファイル: server.py プロジェクト: gambogi/ibutton-csh
    def get(self, ibutton):
        # Do the actual work here
        # Call out to ldap, return a json dict
        # contents: entryUUID, username
   	
	# To move to production, change these initialization values
	# to a user/pass which can search ibuttons     
	ldap = CSHLDAP('user', 'password')
	entry = ldap.search(ibutton=ibutton)[0]

	response = {
            'username': entry[1]['uid'],
            'entryUUID': entry[1]['entryUUID']
            }

        self.write(response)
コード例 #3
0
ファイル: server.py プロジェクト: nickdepinet/ibutton-csh
    def get(self):
        # Do the actual work here
        # Call out to ldap, return a json dict
        # contents: entryUUID, username
   	
	# To move to production, change these initialization values
	# to a user/pass which can search ibuttons     
	ldap = CSHLDAP('user', 'password')
	# get the ibutton from the arguments
	ibutton = self.get_argument('ibutton')
	entry = ldap.search(ibutton=ibutton)[0]
	response = {
            'username': entry[1]['uid'],
            # entryUUID temporarily disabled while I work out some permissions errors
            #'entryUUID': entry[1]['entryUUID']
            }
	# return it
        self.write(response)
コード例 #4
0
def main(user=None, password=None, apiKey=None, test=False):
    ldap = CSHLDAP(user, password)
    subject, post = message(ldap)
    if not post:
        print("No birthdays today.")
        return
    newsgroup = "csh.test" if test else "csh.noise"
    webnews = Webnews(api_key=apiKey, api_agent="WebNews Birthday Bot")
    webnews.compose(newsgroup=newsgroup, subject=subject, body=post)
    print(post)
コード例 #5
0
     peopleList[x] = your_gender_list[x][0]
 tempList[0] = -10
 finalPeopleList = []
 for x in range(len(peopleList)):
     name = peopleList[x].split("/")
     nametemp = name[len(name) - 1]
     finalPeopleList += [nametemp]
 finalPeopleList[0] = ""
 print(finalPeopleList)
 index = min(range(len(tempList)), key=lambda i: abs(round(float(tempList[i]), 3) - 11.5))
 print(finalPeopleList, tempList)
 base_dn = "ou=Users,dc=csh,dc=rit,dc=edu"
 host = "ldap://ldap.csh.rit.edu"
 password = "******"
 print("Prediction: ", finalPeopleList[index], " Confidence: ", tempList[index])
 ldap_con = CSHLDAP("<username>", password)
 name = finalPeopleList[index].split(" ")
 nameStr = name[0].strip() + " " + name[1].strip()
 print(nameStr)
 result = ldap_con.search(cn=nameStr)
 msgString = "Hello, " + nameStr
 file = open("names.txt", "a+")
 file.write(nameStr + " Confidence: " + tempList[index] + "\n")
 file.close()
 onFloor = result[0][1]["onfloor"]
 skills = []
 if "skills" in result[0][1]:
     skills = result[0][1]["skills"]
 if int(onFloor[0]):
     msgString += " you are an on floor member "
 else:
コード例 #6
0
            continue
        nameString = name[0]
        memberString = nameString + " is " + str(age) + " years old.\n"
        string += memberString
    string += "\nShower on sight!\n\n(This post was automatically generated by the WebNews Birthday Bot.)"
    return subject, string


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Find users with a birthday.')
    parser.add_argument("user", help="Specify a username.")
    parser.add_argument("password", help="Specify the password for the user.")
    parser.add_argument("apikey", help="API key for posting to WebNews")
    parser.add_argument("--test",
                        "-t",
                        action="store_true",
                        help="Posts to csh.test instead of csh.noise")
    args = parser.parse_args()
    ldap = CSHLDAP(args.user, args.password)
    subject, message = message(ldap)
    if not message:
        print("No birthdays today.")
        exit()
    if not args.apikey:
        print("No API key provided.")
        exit()
    newsgroup = "csh.test" if args.test else "csh.noise"
    webnews = Webnews(api_key=args.apikey, api_agent="WebNews Birthday Bot")
    webnews.compose(newsgroup=newsgroup, subject=subject, body=message)
    print(message)
コード例 #7
0
     peopleList[x] = your_gender_list[x][0]
 tempList[0] = -10
 finalPeopleList = []
 for x in range(len(peopleList)):
     name = peopleList[x].split("/") 
     nametemp = name[len(name) - 1]
     finalPeopleList += [nametemp]
 finalPeopleList[0] = ""
 print(finalPeopleList)
 index = min(range(len(tempList)), key=lambda i: abs(round(float(tempList[i]), 3)-11.5))
 print(finalPeopleList,tempList)
 base_dn = 'ou=Users,dc=csh,dc=rit,dc=edu'
 host = 'ldap://ldap.csh.rit.edu'
 password = '******'
 print("Prediction: ", finalPeopleList[index] , " Confidence: ", tempList[index])
 ldap_con = CSHLDAP("<put user name here>", password)
 name = finalPeopleList[index].split(" ")
 nameStr = name[0].strip() + " " + name[1].strip()
 print(nameStr)
 result = ldap_con.search(cn=nameStr)
 msgString = "Hello " + nameStr
 file = open("names.txt", "a+")
 file.write(nameStr +" Confidence: " + tempList[index]  + "\n")
 file.close()
 onFloor = result[0][1]['onfloor']
 skills =[]
 if('skills' in result[0][1]):
     skills = result[0][1]['skills']
 if(int(onFloor[0])):
     msgString += " you are an on floor member "
 else: