コード例 #1
0
ファイル: main.py プロジェクト: geraldoandradee/VoterChat
def delete_user(username):
    """
    Delete a user.
    """
    user.delete(username)
    app.logger.info("[USER] User '{}' has been deleted.".format(username))
    return "", 200
コード例 #2
0
def recieve_message(message):
    """
    Caller function to start moving conversation.

    Parameters
    ----------
    message : dictionary
        Message information recieved from the API.

    Attributes
    ----------
    None

    Methods
    -------
    None
    """
    try:
        user_id = message['user_id']
        if user.get_user_type(user_id) == 'user':
            set_pending_conversation(message, user_id)
        move_conversation(message)
    except Exception as e:
        print(e)
        exception_flow(message)
        tb = traceback.format_exc()
        user.delete(user_id)
        print(tb)
    return True
コード例 #3
0
 def test_delete_user(self):
     users = user_api.read_all()
     user = users[randint(0, len(users))]
     try:
         user_api.delete(user.get('user_id'))
     except Exception as e:
         self.assertTrue('Working outside of application context' in str(e))
コード例 #4
0
def _delete():
    global _book_catalog, _author_lst, _deleted
    size = len(_author_lst)
    while True:
        author_num = randint(0, size - 1)
        author = _author_lst[author_num]

        if len(_book_catalog[author]) == 0:
            continue

        books = list(_book_catalog[author])
        books_num = len(books)

        num = randint(0, books_num - 1)
        title = books[num]

        _book_catalog[author].remove(title)
        _deleted.add((author, title))

        t = time.time()
        user.delete(author, title)
        t1 = time.time()
        dt = t1 - t
        dt *= 100000

        if dt < 800:
            return True
        return False
コード例 #5
0
def delete_user(username):
    """
    Delete a user.
    """
    user.delete(username)
    app.logger.info("[USER] User '{}' has been deleted.".format(username))
    return "", 200
コード例 #6
0
    def update_information(self, update):

        __mt_gl = sniff.get_keys_and_values_from_gitlab(self, update)
        __mt_rd_id = sniff.get_keys_from_redis(self, update)
        __mt_gl_id = __mt_gl.keys()

        # Generate difference and intersection metadata
        __mt_diff = set(__mt_gl_id).difference(set(__mt_rd_id))
        __mt_int = set(__mt_gl_id).intersection(set(__mt_rd_id))
        __mt_mod = list(__mt_diff.union(__mt_int))
        __mt_del = list(set(__mt_rd_id).difference(set(__mt_gl_id)))

        # Print alert
        if config.DEBUGGER:
            config.print_message("- [ %s ] New or possible updates: %d | Deleted: %d" %
                                 (update, len(__mt_mod), len(__mt_del)))

        # Insert / Modify Information
        for i in __mt_mod:
            if update == "users":
                util_user.save(self, i, __mt_gl[i])
            elif update == "groups":
                util_group.save(self, i, __mt_gl[i])
            elif update == "projects":
                util_project.save(self, i, __mt_gl[i])

        # Delete Information
        for i in __mt_del:
            if update == "users":
                util_user.delete(self, i)
            elif update == "groups":
                util_group.delete(self, i)
            elif update == "projects":
                util_project.delete(self, i)
コード例 #7
0
ファイル: testDashboard.py プロジェクト: mobyle2/mf-pyramid
 def setUp(self):
     Dashboard.__klasses = []
     collection = connection.User.find()
     for user in collection:
         user.delete()
     collection = connection.Group.find()
     for group in collection:
         group.delete()
コード例 #8
0
ファイル: views.py プロジェクト: kaibinyuan/python_reboot
def del_user():
    name = request.args.get("username")

    if name in user.info():
        user.delete(name)
        return redirect("/index")
    else:
        return "username not found"
コード例 #9
0
ファイル: dodoru.py プロジェクト: AugustLONG/learn_in_python
def delete_user(id):
    username = request.cookies.get('username')
    if username == 'admin':
        print 'delete user data : ', user.search_id(id)
        user.delete(id)
        return render_template('user_list.html')
    else:
        return "<h1> 当前用户无权限查看该页面</h1>"
コード例 #10
0
def delete_user(id):
    username = request.cookies.get('username')
    if username == 'admin':
        print 'delete user data : ', user.search_id(id)
        user.delete(id)
        return render_template('user_list.html')
    else:
        return "<h1> 当前用户无权限查看该页面</h1>"
コード例 #11
0
ファイル: app.py プロジェクト: yulu9206/seenit_lu
def account_profile():
    global this_u_id
    user_info = user.read_one(this_u_id)
    print("My Account Information:")
    print(user_info)
    print("-" * 40)
    print("                Account Menu")
    print("-" * 40)
    logging.info("Print account_profile menu - Request user response\n")
    if admin == True:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            3 = Show All Accounts
            4 = Main Menu
            5 = Exit
            ''')
    else:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            4 = Main Menu
            5 = Exit
            ''')
    if method == '1':
        logging.info("Response: 1 - Update Account Info\n")
        logging.info("Response 1 request user response\n")
        x = input("user name: ")
        z = getpass.getpass('Password:'******'2':
        logging.info("Response: 2 - Delete My Account\n")
        user.delete(this_u_id)
        this_u_id = 0
        main_menu()
    elif method == '3':
        logging.info("Response: 3 - Show All Accounts\n")
        user.read_all()
        # print(all_users)
        account_profile()
    elif method == '5':
        logging.info("Response: 5 - Exit\n")
        exit()
    else:
        logging.info("Response: 4 - Main Menu\n")
        main_menu()
コード例 #12
0
def delete():
    global _array, _deleted
    size = len(_array)

    num = randint(0, size - 1)
    key = list(_array)[num]

    del _array[key]
    _deleted.add(key)

    t = time.time()
    user.delete(key)
    dt = (time.time() - t) * TIME_MULTIPLIER

    return dt < TIME_TEST_LIMIT
コード例 #13
0
ファイル: views.py プロジェクト: sajjadpoores/Myig
    def get(self, request, cid, uid):
        client = get_client(cid)
        if not (client and (request.user == client or request.user.is_staff)):
            return HttpResponse(
                "دسترسی مجاز نیست")  # TODO: redirect to error page

        import user
        user = user.views.get_user(uid)
        if not (user and (user.cid == request.user or request.user.is_staff)):
            return HttpResponse(
                "دسترسی مجاز نیست")  # TODO: redirect to error page

        user.delete()

        return redirect('/client/dashboard/')
コード例 #14
0
def account_profile():
    global this_u_id
    user_info = user.read_one(this_u_id)
    print("Account Information:")
    print(user_info)
    print("-" * 40)
    print("                Account Menu")
    print("-" * 40)
    if admin == True:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            3 = Show All Accounts
            4 = Main Menu
            5 = Delete Accounts
            6 = Exit
            ''')
    else:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            4 = Main Menu
            6 = Exit
            ''')
    if method == '1':
        x = input("user name: ")
        z = input("password: "******"email: ")
        user.update(this_u_id, x, z, y)
        account_profile()
    elif method == '2':
        user.delete(this_u_id)
        this_u_id = 0
        main_menu()
    elif method == '3':
        all_users = user.read_all()
        print(all_users)
        account_profile()
    elif method == '5':
        x = input("Enter the ID of the account you want to delete")
        user.delete(x)
        account_profile()
    elif method == '6':
        exit()
    else:
        main_menu()
コード例 #15
0
def delete_contact():
    '''
    removes Contacts older than 1 minute
    :return:
    '''
    users = user_api.read_all()
    # normalise datetime
    now = datetime.now() - timedelta(minutes=1)
    now = now.replace(tzinfo=utc)
    for user in users:
        created_on = datetime.strptime(user.get('contact_details')[0].get('created_on'), '%Y-%m-%dT%H:%M:%S.%f%z')
        # normalise datetime
        created_on = created_on.replace(tzinfo=utc)
        if created_on < now:
            try:
                print(f'deleting user: {user.get("name")} {user.get("surname")}')
                user_api.delete(user.get('user_id'))
            except Exception as e:
                assert('Working outside of application context' in str(e))
コード例 #16
0
ファイル: command.py プロジェクト: dshinin/sttm
def execute_command(db, command, data):
    answer = ""

    if command == 'EMPLOYERS_LIST':
        answer = employee.list(db)
    elif command == 'EMPLOYEE_INFO':
        answer = employee.info(db, data['EMPLOYEE_ID'])
    elif command == 'EMPLOYEE_ADD':
        answer = employee.new(db, data['EMPLOYEE_FIO'])
    elif command == 'EMPLOYEE_FIRE':
        answer = employee.fire(db, data['EMPLOYEE_ID'])
    elif command == 'EMPLOYEE_EDIT':
        answer = employee.edit(db, data['EMPLOYEE_ID'], data['EMPLOYEE_DATA'])
    elif command == 'EMPLOYEE_ADD_TO_UNIT':
        answer = employee.edit(db, data['EMPLOYEE_ID'], data['UNIT_ID'])
    elif command == 'SCHEDULES_LIST':
        answer = schedule.list(db)
    elif command == 'SCHEDULE_ADD':
        answer = schedule.new(db, data['SCHEDULE_DATA'])
    elif command == 'SCHEDULE_INFO':
        answer = schedule.info(db, data['SCHEDULE_ID'])
    elif command == 'SCHEDULE_EDIT':
        answer = schedule.edit(db, data['SCHEDULE_ID'], data['SCHEDULE_DATA'])
    elif command == 'SCHEDULE_DELETE':
        answer = schedule.delete(db, data['SCHEDULE_ID'])
    elif command == 'SCHEDULE_ADD_TO_EMPLOYEE':
        answer = employee.add_schedule(db, data['EMPLOYEE_ID'], data['SCHEDULE_ID'])
    elif command == 'KEYS_LIST':
        answer = key.list(db)
    elif command == 'KEY_INFO':
        answer = key.info(db, data['KEY_ID'])
    elif command == 'KEY_EDIT':
        answer = key.edit(db, data['KEY_ID'], data['KEY_DATA'])
    elif command == 'KEY_DELETE':
        answer = key.delete(db, data['KEY_ID'])
    elif command == 'KEY_ADD_TO_EMPLOYEE':
        answer = key.add_employee(db, data['KEY_ID'], data['EMPLOYEE_ID'])
    elif command == 'KEY_REMOVE_FROM_EMPLOYEE':
        answer = key.remove_employee(db, data['KEY_ID'])
    elif command == 'KEY_ACTIVATE':
        answer = key.activate(db, data['KEY_NUMBER'], data['KEY_DATETIME'])
    elif command == 'USERS_LIST':
        answer = user.list(db)
    elif command == 'USER_ADD':
        answer = user.new(db, data['USER_NAME'], data['USER_PASSWORD'])
    elif command == 'USER_DELETE':
        answer = user.delete(db, data['USER_ID'])
    elif command == 'USER_READ_PRIVILEGES':
        answer = user.read_access(db, data['USER_ID'])
    elif command == 'USER_WRITE_PRIVILEGES':
        answer = user.write_access(db, data['USER_ID'])
    elif command == 'USER_PASSWORD_CHANGE':
        answer = user.change_password(db, data['USER_ID'], data['USER_PASSWORD'])

    return answer
コード例 #17
0
def users():
    if request.method == "GET":
        return user.get()
    elif request.method == "POST":
        return user.post()
    elif request.method == "PATCH":
        return user.patch()
    elif request.method == "DELETE":
        return user.delete()
    else:
        Response("Not Supported", mimetype="text/html", status=500)
コード例 #18
0
def deleteDatas():
    GoogleEvent.clean(mysql, email=current_user.email)
    user.delete(mysql, email=current_user.email)
    logout_user()
    return redirect(url_for("index"))
コード例 #19
0
ファイル: app.py プロジェクト: KeyStorke/floud
 def get(self, user_id):
     return user.delete(user_id)
コード例 #20
0
ファイル: user_web.py プロジェクト: kaibinyuan/python_reboot
def deluser():
    username = request.args.get('username')
    user.delete(username)
    return redirect('/showuser')
コード例 #21
0
ファイル: main.py プロジェクト: timofi1906/algo
def main(input_file):
    _lst = []
    error = 0
    test_num = 0

    user.init()
    _cur = -1

    with open(input_file) as f_in:
        for line in f_in:
            pair = line.strip().split()

            if len(pair) != 1 and len(pair) != 2:
                continue

            key = pair[0]
            item = 0
            if len(pair) == 2:
                item = int(pair[1])

            if key == "empty":
                test_num += 1
                out_empty = user.empty()
                lst_empty = len(_lst) == 0
                if out_empty != lst_empty:
                    error += 1

            elif key == "set_first":
                if len(_lst) == 0:
                    continue

                _cur = 0
                user.set_first()

            elif key == "set_last":
                if len(_lst) == 0:
                    continue

                _cur = len(_lst) - 1
                user.set_last()

            elif key == "next":
                test_num += 1

                if len(_lst) == 0:
                    try:
                        user.next()
                    except StopIteration:
                        pass
                    else:
                        error += 1
                    continue

                if _cur == len(_lst) - 1:
                    try:
                        user.next()
                        error += 1
                    except StopIteration:
                        pass
                    continue

                _cur += 1
                try:
                    user.next()
                except StopIteration:
                    error += 1

            elif key == "prev":
                test_num += 1

                if len(_lst) == 0:
                    try:
                        user.prev()
                    except StopIteration:
                        pass
                    else:
                        error += 1
                    continue

                if _cur == 0:
                    try:
                        user.prev()
                        error += 1
                    except StopIteration:
                        pass
                    continue

                _cur -= 1
                try:
                    user.prev()
                except StopIteration:
                    error += 1

            elif key == "current":
                if len(_lst) == 0:
                    continue

                test_num += 1
                out_current = user.current()
                lst_current = _lst[_cur]
                if out_current != lst_current:
                    error += 1

            elif key == "insert_after":
                _lst.insert(_cur + 1, item)
                user.insert_after(item)
                if len(_lst) == 1:
                    _cur = 0

            elif key == "insert_before":
                _lst.insert(_cur, item)
                user.insert_before(item)
                if len(_lst) == 1:
                    _cur = 0
                else:
                    _cur += 1

            elif key == "delete":
                if len(_lst) == 0:
                    continue

                user.delete()
                _lst.pop(_cur)
                if _cur == len(_lst):
                    _cur = len(_lst) - 1

            elif key == "len":
                test_num += 1
                out_len = user.len()
                lst_len = len(_lst)
                if out_len != lst_len:
                    error += 1

            elif key == "damp":
                test_num += 1
                out = user.damp()
                if len(_lst) != len(out):
                    error += 1
                else:
                    for i in range(len(_lst)):
                        if _lst[i] != out[i]:
                            error += 1
                            break

            elif key == "swap_prev":
                if len(_lst) == 0 or _cur == 0:
                    continue

                _lst[_cur - 1], _lst[_cur] = _lst[_cur], _lst[_cur - 1]
                _cur -= 1
                user.swap_prev()

            elif key == "swap_next":
                if len(_lst) == 0 or _cur == len(_lst) - 1:
                    continue

                _lst[_cur], _lst[_cur + 1] = _lst[_cur + 1], _lst[_cur]
                _cur += 1
                user.swap_next()

        score = 100 * (test_num - error) / test_num
        return score if score > 35 else 0