예제 #1
0
def facultyadd():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	res=request.form
	id,name,address,phone,date=res['FacultyID'],res["FacultyName"],res['Address'],res['FacultyPhone'],res['date']
	email,pwd,rpwd=res['email'],res['password'],res['repassword']
	error,success="",""
	if pwd!=rpwd:
		error="Passwords Didn't Match"
	else:
		db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
		cur=db_conn.cursor()
		A1=Admin(db_conn,session['email'])
		k=A1.AddFaculty(db_conn,email,id,name,address,phone,date)
		if k[0]:
			success=k[1]
			acct_type="faculty"
			passw=sha256_crypt.hash(pwd)
			query="INSERT INTO users(`password`,account_type,email) VALUES(%s,%s,%s)"
			cur.execute(query,(passw,acct_type,email,))
			db_conn.commit()
		else:
			error=k[1]
	db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	cur=db_conn.cursor()
	query="SELECT FacultyID,`Name` FROM faculty"
	cur.execute(query)
	res=cur.fetchall()
	if success:
		return render_template("admin_faculty.html",faculty=res,success="Faculty Successfully Added")
	return render_template("admin_faculty.html",faculty=res,error=error)
예제 #2
0
def login_admin():
    print("----Login as Admin----\n")
    email_or_user_name = input("Enter user name or email: ")
    password = input("Enter password: "******"No" in response:
            print("Incorrect User Name or Email")
            email_or_user_name = input("Enter user name or email: ")
            password = input("Enter password: "******"Wrong" in response:
            print("Incorrect Password")
            password = input("Enter password: "******"Correct" in response:
            print("Logged In Successfully...")
            Console.clear_screen(2)
            show_admin_menu(admin)
예제 #3
0
def studentadd():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	result=request.form
	srn,name,pgm,address,phone,branch=result["StudentSRN"],result["StudentName"],result["Program"],result["Address"],result["Phone"],result["Branch"]
	email,passw,repassw=result["email"],result["password"],result["repassword"]
	error,success="",""
	if passw!=repassw:
		error="Passwords Didn't Match!"
	else:
		db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
		cur=db_conn.cursor()
		A1=Admin(db_conn,session['email'])
		k=A1.AddStudent(db_conn,email,srn,name,address,phone,pgm,branch)
		if k[0]:
			success=k[1]
			acct_type='student'
			passw=sha256_crypt.hash(passw)
			query="INSERT INTO users(`password`,account_type,email) VALUES(%s,%s,%s)"
			cur.execute(query,(passw,acct_type,email,))
			db_conn.commit()
		else:
			error=k[1]
	db_conn=mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	cur=db_conn.cursor()
	query="SELECT srn,studname FROM student"
	cur.execute(query)
	res=cur.fetchall()
	if success:
		return render_template("admin_students.html",students=res,success="Student Successfully Added")
	return render_template("admin_students.html",students=res,error=error)
예제 #4
0
    def registerUser(self):
        if self.usertype.get()=="Customer":
            self.customer=Customer()
            self.customer.setEmail(self.email.get())
            self.customer.setPassword(self.password.get())
            self.customer.setUserName(self.username.get())
            self.customer.setPhoneNumber(self.phonenum.get())
            self.customer.setUserType(self.usertype.get())
            self.customer.setCustomerName(self.name.get())
            id=''.join([str(random.randint(0, 999)).zfill(3) for _ in range(2)])
            self.customer.setCustomerId(id)
            try:
                self.customer.createCustomerAccount(self.username.get(),id,self.email.get(),self.phonenum.get())
                showinfo("Sucess","Account Created")
            except:
                showinfo("Error", "Error in Creating Account ")

        if self.usertype.get()=="Admin":
            self.admin=Admin()
            self.admin.setEmail(self.email.get())
            self.admin.setPassword(self.password.get())
            self.admin.setUserName(self.username.get())
            self.admin.setPhoneNumber(self.phonenum.get())
            self.admin.setUserType(self.usertype.get())
            self.admin.setAdminName(self.name.get())
            id2= ''.join([str(random.randint(0, 999)).zfill(3) for _ in range(2)])
            self.admin.setAdminId(id2)
            try:
                self.admin.createAdminAccount(self.username.get(),id2,self.email.get(),self.phonenum.get())
                showinfo("Sucess","Admin Account Created")
            except:
                showinfo("Error","Error in Creating Account ")
예제 #5
0
def enroll_ta():
    # URL requested will look like /control/instructor_cp/modify_course/?cid=some-value
    course_id = request.args.get('cid')
    user = current_user
    username = user.get_id()
    instructor = Instructor(username)

    user2 = current_user
    username2 = user2.get_id()
    admin = Admin(username2)

    course_data = instructor.get_course_data(course_id)
    ta_list = instructor.show_tas(course_id)
    ta_ids = []
    for ta in ta_list:
        ta_ids.append(ta[0])

    user_list = admin.show_all_users()
    user_ids = []
    for use in user_list:
        user_ids.append(use[0])

    if request.method == 'POST':
        taID = request.form['taID']
        if taID not in ta_ids and len(taID) < 7 and taID in user_ids:
            instructor.enroll_ta_in_course(taID, course_id)
            return redirect(url_for('instructor_cp'))
        else:
            return redirect(url_for('instructor_cp'))
    return render_template('instr_enroll_ta.html')
예제 #6
0
def select_points():  #
    payload = request.get_json()
    print("select_point is called: ", payload)
    #print payload['keys'][0]
    # u'keys': [{u'LocName': u'Georgia Tech', u'DateTime': u'Tue, 31 Jan 2017 18:37:00 GMT'}]})
    if 'keys' in payload and len(payload['keys']) > 0:
        new_admin = Admin()
        new_admin.changeDP(payload['keys'], payload['acc'])
        # pass
    return jsonify({"succ": 0, "c": payload})
예제 #7
0
def edit_notifications():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	A1 = Admin(db_conn, session['email'])
	all_announcements = A1.ViewAnnouncements(db_conn)
	return render_template("edit_notifications.html", all_announcements = all_announcements)
예제 #8
0
def admin_cp():
    user = current_user
    username = user.get_id()
    admin = Admin(username)
    user_list = admin.show_all_users()
    course_data = admin.show_courses()
    return render_template('admin_cp.html',
                           user=user,
                           course_data=course_data,
                           user_list=user_list)
예제 #9
0
def save_account():
    payload = request.get_json()
    print('saving account [accept / reject]', payload)
    # {'id': p.id, 'status': acc? 1 : 0, 'email': p.EmailAddress}
    if 'id' in payload:  # currently only for accpet or reject accounts
        # pass
        new_admin = Admin()
        new_admin.changeCOA_one(payload['email'], payload['status'])
    else:
        pass  # won't reach here for this assignment
    return jsonify({'succ': 0, 'c': payload})
 def ShowAdmin(self, Tum):
     List = []
     for record in Tum:
         admin = Admin()
         admin.set_adminid(record[0])
         admin.set_passwd(record[1])
         admin.set_connection(record[2])
         admin.set_permission(record[3])
         List.append(admin)
     result = tuple(List)
     return result
예제 #11
0
 def __init__(self):
     self.connection = pymysql.connect(
         host="localhost",
         user="******",
         password="",
         db='UNIVERSITY1',
         charset='utf8mb4',
         cursorclass=pymysql.cursors.DictCursor)
     self.cursor = self.connection.cursor()
     self.user = User(self)
     self.admin = Admin(self)
예제 #12
0
def export_data():
    username = current_user.get_id()
    admin = Admin(username)
    user_list = admin.show_all_users()
    data = ''
    for tuple in user_list:
        data += tuple[0] + ","  # id
        data += tuple[1] + ","  # first name
        data += tuple[2] + ","  # last name
        data += tuple[3] + "<br>"  # account type
    return data
예제 #13
0
def delete_notification(NOTIF_ID = ""):
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	
	db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	A1 = Admin(db_conn, session['email'])
	print("deleting...")
	A1.RemoveAnnouncement(db_conn, ID = NOTIF_ID)
	return redirect(url_for("edit_notifications"))
예제 #14
0
def fetch_points():  # fetch pending data points
    newA = Admin()
    result = newA.pendingDP()
    '''
    return jsonify({ 'succ': 0, 'c':
    [ {"loc": 0, "attr": "AQI", "val": 31, 'id': 0, 'ts': '12-08-2014', 'status': -1}
    , {"loc": 1, "attr": "AQI", "val": 1099, 'id': 3, 'ts': '04-21-2017', 'status': -1}
    , {"loc": 1, "attr": "Mold", "val": 653, 'id': 5, 'ts': '10-02-2017', 'status': -1}
    , {"loc": 3, "attr": "Mold", "val": 9, 'id': 15, 'ts': '09-11-2015', 'status': -1}
    ]})
    '''

    return jsonify({'succ': 0, 'c': result})
예제 #15
0
def add_notification():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	
	if(request.method == "POST"):
		db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******", password = "******", database = "pesuapp")
		form_data = request.form
		print(form_data)
		A1 = Admin(db_conn, session['email'])
		A1.AddAnnouncement(db_conn, Title=form_data['Title'], Location=form_data['Location'], Description=form_data['Description'], PictureLink=form_data['PictureLink'], HyperLink=form_data['HyperLink'])
		return redirect(url_for("admin_notifications"))
	return render_template("add_notification.html")
예제 #16
0
파일: Game.py 프로젝트: hannep/PennApps
 def createFromAppEngine(id):
     users = User.createFromAppEngine()
     admins = Admin.createFromAppEngine()
     minigames = Minigame.createFromAppEngine()
     game_query = GameModel.query(GameModel.id == id)
     game = game_query.fetch(1)
     return Game(id, game[0].name, game[0].description, admins, users, minigames, game[0].duration) if len(game) > 0 else None
예제 #17
0
def view_feedback(CourseID = ""):
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	
	db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	A1 = Admin(db_conn, session['email'])

	if(CourseID):
		CourseFeedback = A1.ViewFeedback(db_conn, CourseID)
		return render_template("view_course_feedback.html", CourseFeedback = CourseFeedback, CourseID = CourseID)

	all_courses = A1.ViewCourse(db_conn)
	return render_template("view_feedback.html", all_courses = all_courses)
예제 #18
0
def LoginButtonfunction():
    User = Person()
    User.Username = UsernameField.get("1.0", END)
    User.Password = passwordField.get("1.0", END)
    if len(User.Username) - 1 != 0 and len(User.Password) - 1 != 0:
        Data = User.Login(User.Username, User.Password)
        if Data[0] and Data[1].Authorize:
            if not Data[1].Admin:
                User = Users()
            else:
                User = Admin()
            User.Username = Data[1].Username
            User.Password = Data[1].Password
            User.Folderpath = Data[1].Folderpath
            User.Authorize = Data[1].Authorize
            User.Admin = Data[1].Admin
            if not User.Admin:
                root.destroy()
                root.quit()
                from Dashboard import Dashboard
                next = Dashboard(User)
            else:
                pass
            # الى هيعمل ال admin

        else:
            tkinter.messagebox.showinfo(" Invalid Credintial",
                                        "User Doesnot exist  thank you :)")
            root.destroy()
            root.quit()
    else:
        tkinter.messagebox.showinfo("Empty fields",
                                    "Do net leave any field empty ")
예제 #19
0
 def getUserTyp(type, name):
     if type == 'user':
         return User(name)
     if type == 'translator':
         return Translator(name)
     if type == 'admin':
         return Admin(name)
    def Login_Selection(self):
        if self.Function_Dropbox.currentIndex() == 0:

            if self.linedit1.text() == "o" and self.linedit2.text() == "o":
                self.Screen_4 = Screen_4(self.width, self.height, self, root)
                self.Screen_4.show()   
                self.close()

            elif self.linedit1.text() != str(self.rows[1]):
                self.Status_Bar.showMessage("Incorrect username! Enter the correct username.")
                self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red")
            
            elif self.linedit2.text() != str(self.rows[2]):
                self.Status_Bar.showMessage("Incorrect password! Enter the correct password.")
                self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red")

        elif self.Function_Dropbox.currentIndex() == 1:
            
            if self.linedit1.text() == "a" and self.linedit2.text() == "a":
                self.Admin = Admin(self.width, self.height, self, root)
                self.Admin.show()   
                self.close()

            elif self.linedit1.text() != str(self.rows[3]):
                self.Status_Bar.showMessage("Incorrect username! Enter the correct username.")
                self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red")
            
            elif self.linedit2.text() != str(self.rows[4]):
                self.Status_Bar.showMessage("Incorrect password! Enter the correct password.")
                self.Status_Bar.setStyleSheet("font-size: 15px; color: white; background-color: red")
 def __init__(self, clientId, data, verifykey, apiEndPoint):
     self.message = data
     self.sessionkey = verifykey
     self.apiEndPoint = apiEndPoint
     self.splitUrl = apiEndPoint.split('/')
     self.auth = Authentication()
     self.master = Master()
     self.admin = Admin()
     self.role = roleManage()
     self.attendance = attendanceManage()
     self.project = projectManage()
     self.labourer = labbourerManage()
     self.labclass = labourerClass()
     self.shift = shiftManage()
     self.log = Logger()
     self.paymentDesk = paymentDesk()
     self.clientId = clientId
예제 #22
0
    def runTests(self, notifications, secondaryToken, secondaryName, lockedUserToken):
        self.notifications = notifications
        self.notifications['posting']['backer'] = 0
        self.notifications['posting']['promotion'] = 0
        self.notifications['posting']['backerPromotion'] = 0

        self.postingTags = {}
        
        self.secondaryAuthed = PyRequest(secondaryToken)
        self.lockedAuthed = PyRequest(lockedUserToken)
        print("Running posting tests")
        expectedFinances = {'code':Codes.SUCCESS}
        expectedPostingsCount = {'code':Codes.SUCCESS}
        
        admin = Admin()
        admin.addCurrency(self.username, 2000)
        admin.addCurrency(self.target, 2000)
        admin.addCurrency(secondaryName, 2000)
        
        #backingBody = {'username':self.username, 'amount':1000}
        #self.targetAuthed.expectResponse(Paths.OFFERS, PyRequest.POST, backingBody, self.expectedSuccess)
        #self.authed.expectResponse(Paths.OFFERS_ACCEPT, PyRequest.POST, None, self.expectedSuccess, self.target)
        self.backer = None
        #self.backer = self.target
        #self.notifications['backing']['offer'] += 1
        #self.notifications['backing']['accept'] += 1
        
        data = self.authed.expectResponse(Paths.FINANCES, PyRequest.GET, None, expectedFinances)
        self.balance = data['dto']['balance']
        data = self.targetAuthed.expectResponse(Paths.FINANCES, PyRequest.GET, None, expectedFinances)
        self.targetBalance = data['dto']['balance']
        
        self.postings = {}
        self.otherPostingsCount = 0
        
        data = self.authed.expectResponse(Paths.POSTINGS, PyRequest.GET, None, expectedPostingsCount, None, ['time=alltime','warning=true'])
        self.otherPostingsCount = data['page']['totalElements']
        
        self.testAddPostings()
        self.testPromotePostings()
        self.testSort()
        self.testPromotePostings()
        self.testAddPostings()
        self.testSort()
        self.testAddPostings()
        self.testAddPostings()
        self.testPromotePostings()
        self.testSort()
        self.testPostings()
        #self.testNotifications()
        
        balance = {'balance':self.balance}
        expected = self.unauthed.getDTOResponse(balance)
        self.authed.expectResponse(Paths.FINANCES, PyRequest.GET, None, expected)
        balance = {'balance':self.targetBalance}
        expected = self.unauthed.getDTOResponse(balance)
        self.targetAuthed.expectResponse(Paths.FINANCES, PyRequest.GET, None, expected)
        
        #self.testFlag()
        return self.postings.keys()
예제 #23
0
def main():
    aQueue = Queue.Queue()
    HOST = "0.0.0.0"
    PORT = 8000
    logging.basicConfig(level=logging.DEBUG)

    AdminThd = Admin(aQueue)
    AdminThd.daemon = True
    AdminThd.start()

    tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    tcpsock.bind((HOST, PORT))
    tcpsock.listen(10)

    print("En écoute...")
    while True:
        (cs, (ip, port)) = tcpsock.accept()
        cQueue = Queue.Queue()
        newThread = Client(cQueue, aQueue, ip, port, cs)
        newThread.daemon = True
        settings.cThreads.append(newThread)
        newThread.start()

    AdminThd.join()
예제 #24
0
def admin_modify_instructor():
    course_id = request.args.get('cid')
    user = current_user
    username = user.get_id()
    admin = Admin(username)
    user_list = admin.show_all_users()
    user_ids = []
    for user_id in user_list:
        user_ids.append(user_id[0])

    if request.method == 'POST':
        id = request.form['id']
        if len(id) > 0 and id in user_ids:
            admin.mod_instructor(id, course_id)
            return redirect(url_for('admin_cp'))
    return render_template('admin_modify_instructor.html',
                           user=user,
                           course_id=course_id)
예제 #25
0
def facultyedit():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	result=request.form
	id,name,address,phonenumber,courseid=result['FacultyID'],result['FacultyName'],result['Address'],result['Phone'],result['CID']
	courseid=courseid.split(",")
	courseid=[x.strip() for x in courseid]
	db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	A1=Admin(db_conn,session['email'])
	k=A1.EditFaculty(db_conn,id,name,address,phonenumber,courseid)
	cur=db_conn.cursor()
	query="SELECT FacultyID,`Name` FROM faculty"
	cur.execute(query)
	res=cur.fetchall()
	if k[0]:
		return render_template("admin_faculty.html",faculty=res,success="Faculty Successfully Edited")
	return render_template("admin_faculty.html",faculty=res,error=k[1])
예제 #26
0
def main():
    # 欢迎页面
    admin = Admin()

    # 欢迎页面
    admin.printWelcomeView()
    if admin.adminOption():
        return -1

    # 提款机对象
    # 将当前的系统中的用户信息保存到文件中
    filePath = os.path.join(os.getcwd(), 'allusers.txt')
    file = open(filePath, 'rb')
    allUsers = pickle.load(file)
    print('******************************')
    print(allUsers)

    # ATM对象
    atm = ATM(allUsers)

    while True:
        # 功能页面
        admin.printFunctionView()

        # 登陆成功, 等待用户操作
        option = input('请输入您的操作:')
        if option == '1':
            atm.creatUser()
        elif option == '2':
            atm.searchUserInfo()
        elif option == '3':
            atm.getAccountMoney()
        elif option == '4':
            atm.saveMoney()
        elif option == '5':
            atm.transformAccountMoney()
        elif option == '6':
            atm.reviseAccountPassword()
        elif option == '7':
            atm.lockAccount()
        elif option == '8':
            atm.unlockAccount()
        elif option == '9':
            atm.reserAccountCard()
        elif option == '0':
            atm.removeAccount()
        elif option == 't':
            # 将当前系统中的用户信息保存到文件中
            file1 = open(filePath, 'wb')
            pickle.dump(atm.allUsers, file1)
            file1.close()

            time.sleep(2)
            print('退出成功')
            return -1
예제 #27
0
    def LoginUser(self):
        if self.usertype.get() == "Customer":
            self.customer = Customer()
            self.customer.setUserType(self.usertype.get())
            result = self.customer.login(self.username.get(),
                                         self.password.get())

            if result == True:
                showinfo("Sucess", "Login Sucessfull")
            if result == False:
                showinfo("Error", "Login Unsucessfull")

        if self.usertype.get() == "Admin":

            self.admin = Admin()
            self.admin.setUserType(self.usertype.get())
            result = self.admin.login(self.username.get(), self.password.get())

            if result == True:
                showinfo("Sucess", "Login Sucessfull")
            if result == False:
                showinfo("Error", "Login Unsucessfull")
예제 #28
0
 def showAdminMenu(self, userTyp, adminName):
     print("\n**************** ADMIN-MENÜ ****************")
     print("Hey, " + adminName + " was möchtest du machen?")
     print(
         "(1) Nach einem Wort und dessen Übersetzungen suchen\n(2) Summer der angelegten Wörter anzeigen\n"
         "(3) Summer der Wörter in der Datenbank anzeigen\n(4) Wörter anzeigen bei denen Übersetzungen fehlen\n"
         "(5) Neue Sprache anlegen\n(6) Einem Übersetzer eine neue Sprache zuweisen\n(7) Programm beenden"
     )
     adminMenuNumber = int(input("-> Was möchtest du machen? "))
     if adminMenuNumber == 1:
         Menu.searchWord(self, userTyp, adminName)
     elif adminMenuNumber == 2:
         Admin.showCreatedWordSum(self, userTyp, adminName)
     elif adminMenuNumber == 3:
         Menu.showSumWords(self, userTyp, adminName)
     elif adminMenuNumber == 4:
         print("Hi")
     elif adminMenuNumber == 5:
         print("Hi")
     elif adminMenuNumber == 6:
         print("Hi")
     elif adminMenuNumber == 7:
         print("Programm beendet!")
예제 #29
0
def courseedit():
	try:
		if session['type']!="admin":
			return redirect(url_for("logout"))
	except:
		return redirect(url_for("logout"))
	db_conn = mysql.connector.connect(host = "localhost", port = 3306, user = "******",password="******", database = "pesuapp")
	result=request.form
	id,title,avl,details,faculties=result['CourseID'],result['CourseTitle'],result['AVL'],result['CourseDetails'],result['FID']
	faculties=faculties.split(",")
	faculties=[x.strip() for x in faculties]
	A1=Admin(db_conn,session['email'])
	k=A1.EditCourse(db_conn,id,title,faculties,details,avl)
	
	#for pushing to courses site
	cur=db_conn.cursor()
	query="SELECT courseid,coursetitle FROM course"
	cur.execute(query)
	res=cur.fetchall()
	if k[0]:
		return render_template("admin_courses.html",courses=res,success="Course Successfully Edited")
	else:
		return render_template("admin_courses.html",courses=res,error=k[1])
예제 #30
0
def save_point():
    payload = request.get_json()
    print("save_point is called: ", payload)
    # {u'loc': u'Chastain Park', u'ts': u'2017-03-19T16:00', u'val': 111, u'attr': u'Air Quality'})
    # DateTime	LocName	Status	DataType	DataValue -- pretend saving
    # addNewDataPoint(self, locationname, date, time, datatype, value) "1999/03/04", "05:06"

    # change data point status
    # print payload: {'id': p.id, 'status': acc? 1 : 0, 'datetime': p.DateTime, 'loc': p.LocName}
    if 'id' in payload:
        # update a data points
        print(
            'parsed time: ',
            datetime.strptime(payload['datetime'], '%a, %d %b %Y %H:%M:%S %Z'))
        newtime = datetime.strptime(payload['datetime'],
                                    '%a, %d %b %Y %H:%M:%S %Z')
        date, time = str(newtime.date()), str(newtime.time())
        new_date_time = date + ' ' + time
        print new_date_time
        new_admin = Admin()
        new_admin.changeDP_one(new_date_time, payload['loc'],
                               payload['status'])
    else:
        payload["id"] = 100

    if 'ts' in payload:
        print('parsed time: ',
              datetime.strptime(payload['ts'], '%Y-%m-%dT%H:%M'))
        new_scientist = CityScientist()
        newtime = datetime.strptime(payload['ts'], '%Y-%m-%dT%H:%M')
        date, time = str(newtime.date()), str(newtime.time())
        date = "/".join(date.split('-'))
        time = time[0:5]
        new_scientist.addNewDataPoint(payload['loc'], date, time,
                                      payload["attr"], payload["val"])
        print "addNewDataPoint Successfully"
    return jsonify({"succ": 0, "c": payload})
예제 #31
0
def main():
    #管理员对象
    admin = Admin()
    admin.printAdminView()
    if admin.adminOption():
        return -1
    #提款机对象
    filePath = os.path.join(os.getcwd(), "allUsers.txt")
    f = open(filePath, "rb")
    allUsers = pickle.load(f)
    allUsers = {}
    atm = ATM(allUsers)
    while True:
        admin.printsysFunctionView()
        #等待用户操作
        option = input("请输入您的操作:")
        if option == "1":
            #开户
            atm.createUser()

        elif option == "2":
            atm.searchUserInfo()
        elif option == "3":
            atm.getMoney()
        elif option == "4":
            print("存款")
        elif option == "5":
            print("转账")
        elif option == "6":
            print("改密")
        elif option == "7":
            ATM.lockUser()
        elif option == "8":
            print("解锁")
        elif option == "9":
            print("补卡")
        elif option == "0":
            print("销户")
        elif option == "t":
            if not admin.adminOption():
                #将系统中的用户信息保存到文件中
                f = open(filePath, "a")
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1

        time.sleep(2)
예제 #32
0
 def runTests(self, notifications):
     print("Running backing and offer tests")
     self.offers = 0
     self.emailOffers = 0
     self.backings = 0
     self.offersAmount = 0
     self.emailOffersAmount = 0
     self.backingAmount = 0
     self.notifications = notifications
     self.notifications['backing']['offer'] = 0
     self.notifications['backing']['withdraw'] = 0
     self.notifications['backing']['cancel'] = 0
     self.notifications['backing']['deny'] = 0
     self.notifications['backing']['accept'] = 0
     
     admin = Admin()
     admin.addCurrency(self.username, 2000)
     admin.addCurrency(self.target, 2000)
     
     self.testAddOffers()
     self.testDenyOffer()
     self.testAddOffers()
     self.testWithdrawOffer()
     self.testAddOffers()
     #self.testNotifications()
     self.testWithdrawEmailOffer()
     self.testAddOffers()
     self.testAcceptOffer()
     self.testAddOffers()
     #self.testNotifications()
     self.testRemoveBacking()
     self.testAddOffers()
     self.testAcceptOffer()
     self.testAddOffers()
     self.testWithdrawOffer()
     self.testAddOffers()
예제 #33
0
 def startSelector(self, RS, cursor, conn):
     while (True):
         if RS == 0:
             RS = login(self)
         elif (RS == 'admin'):
             Admin(cursor, conn)
             RS = 0
         elif (RS == 'user'):
             User(cursor, conn)
             RS = 0
         elif RS == 'q':
             close(self)
             print('Wyszedłeś z programu')
             break
         else:
             close(self)
             print('Wyszedłeś z programu')
             break
예제 #34
0
from Admin import Admin
from dataHandler import dataHandler
from cmd import cmd


print("La ruta hacía el proyecto, si aún no tiene proyecto indique la nueva ruta: ")
path = input()

data = dataHandler(path)
cmd = cmd()
Admin = Admin(path, cmd, data)

todo = ""
while (todo != "exit"):
	todo = input("Que desea hacer: ")
	Admin.callFunction(todo)