Exemplo n.º 1
0
def unfollow(db, user):
    main.clear()
    while(True):
        try:
            print()
            print("+-----------------+".center(49))
            print("|    UNFOLLOW     |".center(49))
            print("+-----------------+".center(49))
            print()
            user = db.member.find_one({'_id': user['_id']})
            printfollowings(db,user)
            if user['following']!=[]:
                print('Enter id to unfollow')
                unfollowid = input("Search id (Press 'q' to quit): ")
                unfollow = db.member.find_one({'_id': unfollowid}, {"_id": 1, "name": 1})
                if unfollowid=='q':return
                elif unfollow == None:
                    main.clear()
                    print("There is no such user\n")
                elif unfollowid not in user["following"]:
                    main.clear()
                    print("You are not following @" + unfollowid+".\n")
                else:
                    db.member.update({'_id': user['_id']}, {'$pull': {'following': unfollowid}})
                    db.member.update({'_id': unfollowid}, {'$pull': {'follower': user['_id']}})
                    main.clear()
                    print("You have unfollowed @" + unfollowid+'\n')
            else:
                print("You can't unfollow anyone")
                return
        except Exception as e:
            main.clear()
            print("Can't unfollow! Try again.")
Exemplo n.º 2
0
def menu():
    print("1. Convert Classic DEX to JSON")
    print("2. Convert Classic DEX to VMD")

    user_choice = input()
    if user_choice == "1":
        root = tk.Tk().withdraw()

        file_path = filedialog.askopenfilename(filetypes=[("Classic DEX File",
                                                           "*.bin")])
        ext = os.path.splitext(file_path)
        with open(file_path, 'rb') as f:
            with open(f'{ext[0]}.json', 'w') as j:
                ReadClassicEXPToJson(f, j)
        main.clear()
        main.main()

    elif user_choice == "2":
        root = tk.Tk().withdraw()

        file_path = filedialog.askopenfilename(filetypes=[("DEX Json",
                                                           "exp_*.json")])
        ext = os.path.splitext(file_path)
        with open(file_path, 'rb') as f:
            ReadDexJsonToVMD(f, ext[0])
        main.clear()
        main.main()
Exemplo n.º 3
0
def showfollow(db,user):
    user = db.member.find_one({'_id': user['_id']})
    followings=user['following']
    main.clear()
    print('+-------------You are now following-------------+')
    if followings==[]:
        print('No one')
    for f in followings:
        tain=db.member.find_one({'_id':f},{'_id':1,'name':1})
        print(tain['name']+'(@'+tain['_id']+')')
    print('+'+'-'*47+'+')
    while(True):
        #print('-'*49)
        print('1) Follow more')
        print('2) Unfollow')
        print("3) Explore the other's page")
        print('q) Exit')
        print('-'*49)
        a=input('Enter:')
        if a=='1':
            import follow
            follow.follow(db,user)
        elif a=='2':
            import follow
            follow.unfollow(db,user)
        elif a=='3':
            other=input('Enter id to explore (enter q to quit) : ')
            if other=='q':
                return
            exploreothers(db,user,other)
        else:
            return
Exemplo n.º 4
0
def explore(db,user):
    msg=""
    while(True):
        main.clear()
        try:
            print(msg)
            print()
            print("+-----------------+".center(49))
            print("|     EXPLORE     |".center(49))
            print("+-----------------+".center(49))
            print()
            print(single)
            print("You can explore the other user's wall!")
            otherid=input("Enter the id (q:quit) : ")
            if otherid=='q':return
            import post
            me=db.member.find_one({'_id':user['_id']})
            other= db.member.find_one({'_id': otherid})
            post.other_wall(db,me,other)
            inp=input("Want to explore more? (Yes:y,Quit:q) : ")
            msg=""
            if inp=='y':pass
            else:return
        except:
            msg=("Can't find.. try again.")
Exemplo n.º 5
0
def other_wall(db, me, other):
    try:
        while (True):
            me = db.member.find_one({'_id': me['_id']})
            other = db.member.find_one({'_id': other['_id']})
            main.clear()
            print()
            print(('The Wall of ' + other['name']).center(49))
            db.posts.create_index('uid')
            cursor = db.posts.find({
                'uid': other['_id']
            }).sort('rawtime', pymongo.DESCENDING)  ################
            cursor = list(cursor)
            printpost(db, cursor)
            print('\n' + single)
            cursor = list(cursor)
            print("1 좋아요 2 좋아요 취소 3 댓글 보기")
            inp = input("Enter (q to quit) : ")
            if inp == 'q': return
            elif inp == '1':
                likey(db, me, cursor)
            elif inp == '2':
                dislikey(db, me, cursor)
            elif inp == '3':
                comment(db, me, cursor)
            else:
                input('Wrong number...Enter to proceed')
    except:
        print("다른 담벼락 메뉴에서 문제가 생겼습니다. 다시 해주세요 ㅠ")
Exemplo n.º 6
0
def myblock(db,user):
    while(True):
        user = db.member.find_one({'_id': user['_id']})
        main.clear()
        print('+----------------My block list------------------+')
        try:
            blocks = user['block']
            if blocks == []:
                print('No one')
            for f in blocks:
                tain = db.member.find_one({'_id': f}, {'_id': 1, 'name': 1})
                print(tain['name'] + '(@' + tain['_id'] + ')')
        except:
            print('No one')
        print('+' + '-' * 47 + '+')
        print('1) Delete ')
        print('2) Add ')
        print('q) Exit')
        print('-'*49)
        a=input('Enter:')
        if a=='1':
            try:
                b=user['block']
                if b==[]:raise Exception
                id=input("Enter id to delete from the block list : ")
                db.member.update({'_id': user['_id']}, {'$pull': {'block': id}})
                print('Successfully unblocked\n')
            except:
                print("You can't unblock.\n")
        elif a=='2':
            showfollower(db,user)
        else:
            return
Exemplo n.º 7
0
def mystatus(db, user):
    while(True):
        main.clear()
        user = db.member.find_one({'_id': user['_id']})
        printstatus(db,user)
        modify=input('Want more options? (Yes:y/No:q) :')
        if modify=='y':statusmenu(db,user)
        else:break
Exemplo n.º 8
0
def moname(db,user):
    user = db.member.find_one({'_id': user['_id']})
    newname=input('Enter your new name : ')
    if input('Are U Sure? (Yes:y/No:n) : ')=='y':
        db.member.update({'_id':user['_id']},{'$set':{'name':newname}})

        main.clear()
        print('Successfully modified.')
        us.printstatus(db, user)
def menu():
    print("1. Convert X/XHD LIT file to JSON")

    user_choice = input()
    if user_choice == "1":

        file_path = filedialog.askopenfilename(filetypes=[("X/XHD LIT Container", "*.lit")])
        ext = os.path.splitext(file_path)
        with open(file_path, 'rb') as f:
            with open(f'{ext[0]}.json', 'w') as j:
                litReaderX(f, j)
        main.clear()
Exemplo n.º 10
0
def main_menu():
    print("1. DIVA Database Tools")
    print("2. MIRAI Database Tools")

    user_choice = input()

    if user_choice == "1":
        print('Unimplemented')
        main.clear()
        main.main()
    elif user_choice == "2":
        main.clear()
        mirai_menu()
Exemplo n.º 11
0
def showfollower(db,user):
    user = db.member.find_one({'_id': user['_id']})
    followings=user['follower']
    main.clear()
    print('+-------------You are followed by---------------+')
    if followings==[]:
        print('No one')
    for f in followings:
        tain=db.member.find_one({'_id':f},{'_id':1,'name':1})
        print(tain['name']+'(@'+tain['_id']+')')
    print('+'+'-'*47+'+')
    while(True):
        #print('-'*49)
        print('1) Block')
        print('2) Unblock')
        print("3) Explore the other's page")
        print('q) Exit')
        print('-'*49)
        a=input('Enter:')
        if a=='1':
            blockid = input('Enter an id to block  : ')
            try:
                f=db.member.find_one({'_id':blockid})
                if user['_id'] == blockid:
                    raise Exception
                try:
                    if user['follower'] != []:
                        db.member.update({'_id': user['_id']}, {'$pull': {'follower': blockid}})
                        db.member.update({'_id': blockid}, {'$pull': {'following': user['_id']}})
                except:
                    pass
                finally:
                    db.member.update({'_id': user['_id']}, {'$push': {'block': blockid}})
                    print("You have blocked @" + blockid + '\n')
            except:print("You can't block.\n")
        elif a=='2':
            try:
                b=user['block']
                if b==[]:raise Exception
                id=input("Enter id to delete from the block list : ")
                db.member.update({'_id': user['_id']}, {'$pull': {'block': id}})
                print('Successfully unblocked\n')
            except:
                print("You can't unblock.\n")
        elif a=='3':
            other=input('Enter id to explore : ')
            return
        else:
            return
Exemplo n.º 12
0
def signup(db):
    print("\n"+double)
    a = """      
                  +-----------+
                  | 1 SIGN UP | 
                  +-----------+
                    """



    print("\n"+a)
    print("\n1. ID must be at least 2 characters")
    print("2. Password must be at least 4 characters")
    print("3. If you want to quit the sign-up menu, ")
    print("   enter 'q' as ID or password")
    print("\n"+double)
    while (True):
        userid=input("ID : ")
        if userid=='q':
            return
        elif len(userid)<2:
            print("Invaid ID... try again\n")
            continue
        username=input("name : ")
        pw=input("password : "******"password once more: ")
        while pw!=ensure or len(pw)<4 :
            print("\nInvalid password... try again")
            pw=input("password : "******"password once more: ")
        break
    try:
        while (True):
            rusure=input('Are U Sure? (Yes:y/No:n/Quit:q) :')
            if rusure=='y':break #while문을 나가서 signin메뉴로 이어지게
            elif rusure=='n':signup(db) #signup메뉴를 다시 불러들임
            elif rusure=='q':return #signup 함수를 종료하고 메인메뉴로 돌아감
        db.member.insert({'_id':userid,'name':username,'password':pw,'pnumber':0,\
                         'follower':[],'following':[],'block':[],'mylikes':[]})
    except:
        main.clear()
        print('ID already taken. Please input new ID')
        signup(db)
    main.clear()
    print('Successfully signed up!')
    signin(db) #로그인 성공시 signin 메뉴로 바로 이어진다
    '''
Exemplo n.º 13
0
def update(db,user):
    user = db.member.find_one({'_id': user['_id']})
    print('Your profile : ',end='')
    try:
        pro=user['profile']
        print(pro)
    except:
        print('None')
    up=input('Enter your new profile : ')
    rusure = input('Are U Sure? (Yes:y/No:n) :')
    if rusure=='n':return
    else:
        db.member.update({'_id':user['_id']},{'$set':{'profile':up}})
        main.clear()
        print('Successfully modifed!')
        us.printstatus(db, user)
Exemplo n.º 14
0
def hashtag(db, user):
    a = ""
    while (True):
        main.clear()
        print()
        print("+-----------------+".center(49))
        print("| Search hash tag |".center(49))
        print("+-----------------+".center(49))
        print()
        print("OR  : word1 word2".center(49))
        print("AND : word1&word2".center(49))
        print("\n+-----------------------------------------------+\n")
        from bson.son import SON
        if a == "":
            tag = input("Search hash tag (enter 'q' to quit) : ")
        else:
            print(a)
        if tag == 'q':
            return
        if tag[0] != '#':
            tag = '#' + tag
        for i in range(len(tag)):
            if tag[i] == " ":
                if tag[i + 1] != '#':
                    tag = tag[:i + 1] + "#" + tag[i + 1:]
        if "&" in tag:
            tag = tag.split("&")
            tag = list(map(lambda x: "\"" + x + "\"", tag))
            tag = " ".join(tag)
        db.posts.drop_indexes()
        db.posts.create_index([('content', pymongo.TEXT)])
        c = db.posts.aggregate([{
            '$match': {
                '$text': {
                    '$search': tag
                }
            }
        }, {
            '$sort': SON([('rawtime', -1)])
        }])
        post.printpost(db, c)
        print("\n+-----------------------------------------------+\n")
        a = "Search hash tag (enter 'q' to quit) : "
        tag = input(a)
        a = a + tag
        if tag == 'q': return
Exemplo n.º 15
0
    def character_menu(self):  # need to be improved
        #self.player.details(self.round)

        for obj in self.player.macro_attributes():
            print("{0}: {1}: {2}".format(obj.ID(), obj.name(), obj.value()))
        print("\nYou have {0} Points left".format(self.player.get_attribute_points()))

        while True:
            if self.player.attribute_points >= 5:
              selection = user_input("Character attribute:")
              for obj in self.player.macro_attributes():
                if obj.is_ID(selection):
                    self.player.improve_attribute(obj)
                    break
            else:
                pause()
                clear()
                break
Exemplo n.º 16
0
def showlikes(db, me):
    try:
        while (True):
            me = db.member.find_one({'_id': me['_id']})
            main.clear()
            print()
            print("내가 좋아요 누른 글들".center(49))
            print()

            db.posts.create_index('rawtime')

            mylikelist = me['mylikes']

            #print(mylikelist)

            cursor = db.posts.find({
                '_id': {
                    '$in': mylikelist
                }
            }).sort('rawtime', pymongo.DESCENDING)
            cursor = list(cursor)

            #print(cursor)

            printpost(db, cursor)
            print('\n' + single)

            if cursor == []:
                input("엔터를 누르면 돌아갑니다.")
                return

            print("1 좋아요 2 좋아요 취소 3 댓글 보기")
            inp = input("Enter (q to quit) : ")
            if inp == 'q': return
            elif inp == '1':
                likey(db, me, cursor)
            elif inp == '2':
                dislikey(db, me, cursor)
            elif inp == '3':
                comment(db, me, cursor)
            else:
                input('Wrong number...Enter to proceed')
    except:
        input("좋아요 열람 메뉴에서 문제가 생겼습니다. 엔터를 누르면 돌아갑니다")
Exemplo n.º 17
0
def wall(db, user):
    main.clear()
    print()
    print(('The Wall of ' + user['name']).center(49))
    user = db.member.find_one({'_id': user['_id']})
    db.posts.create_index('uid')
    cursor = db.posts.find({
        'uid': user['_id']
    }).sort('rawtime', pymongo.DESCENDING)
    printpost(db, cursor)
    print('\n' + single)

    #########

    #########

    return db.posts.find({
        'uid': user['_id']
    }).sort('rawtime', pymongo.DESCENDING)
Exemplo n.º 18
0
def mirai_menu():
    print("1. Sprite DB Converter")
    print("2. AET DB Converter")
    print("3. NintendoWare DB Converter (Not Implemented)")

    user_choice = input()

    if user_choice == "1":
        root = tk.Tk()
        root.withdraw()

        file_path = filedialog.askopenfilename(filetypes=(('SPRDB BIN File', '*.bin'), ('SPRDB JSON File', '*.json')))
        ext = os.path.splitext(file_path)
        if ext[1] == '.bin':
            with open(file_path, 'rb') as f:
                with open(f'{ext[0]}.json', 'w') as o:
                    mirai_tools.mirai_db_tools.Read_SPRDB_To_Json(f, o)
        elif ext[1] == '.json':
            with open(file_path, 'rb') as f:
                with open(f'{ext[0]}.bin', 'wb') as o:
                    mirai_tools.mirai_db_tools.Write_SPRDB_To_Bin(f, o)

        main.clear()
        main.main()

    elif user_choice == "2":

        file_path = filedialog.askopenfilename(filetypes=(('AETDB BIN File', '*.bin'), ('AETDB JSON File', '*.json')))
        ext = os.path.splitext(file_path)
        if ext[1] == '.bin':
            with open(file_path, 'rb') as f:
                with open(f'{ext[0]}.json', 'w') as o:
                    mirai_tools.mirai_db_tools.Read_AETDB_To_Json(f, o)
        elif ext[1] == '.json':
            with open(file_path, 'rb') as f:
                with open(f'{ext[0]}.bin', 'wb') as o:
                    mirai_tools.mirai_db_tools.Write_AETDB_To_Bin(f, o)

        main.clear()
        main.main()

    elif user_choice == "3":
        print('REALLY unimplemented')
def menu():
    print("1. Classic DEX Converter (F/AFT/FT/MM)")
    print("2. VMD to DEX Json (PD_Tool)")

    user_choice = input()
    if user_choice == "1":
        main.clear()
        diva_tools.dex.menu()
    if user_choice == "2":

        file_path = filedialog.askopenfilename(filetypes=[("MAIN VMD FILE",
                                                           "*.vmd")])
        ext = os.path.splitext(file_path)
        with open(file_path, 'rb') as dex_main_f:
            with open(f'{ext[0][:-4]}eyes.vmd', 'rb') as dex_eyes_f:
                with open(f'{ext[0]}.json', 'w') as j:
                    vmd_tools.vmd_defs.Read_Main_Morphs_to_EXP(
                        dex_main_f, dex_eyes_f, j)
        main.clear()
Exemplo n.º 20
0
def newsfeed(db, user):
    while (True):
        me = db.member.find_one({'_id': user['_id']})
        main.clear()
        print('The Newsfeed'.center(49))
        followings = user['following'] + [user['_id']]
        db.posts.create_index('uid')
        cursor = db.posts.find({
            'uid': {
                '$in': followings
            }
        }).sort('rawtime', pymongo.DESCENDING)
        printpost(db, cursor)
        print('\n' + single)
        print("1 좋아요 2 좋아요 취소")
        print("3 댓글 보기 4 댓글 달기")
        inp = input("Enter (Quit:q) : ")
        if inp == 'q': return
        elif inp == '1':
            cursor = db.posts.find({
                'uid': {
                    '$in': followings
                }
            }).sort('rawtime', pymongo.DESCENDING)
            likey(db, me, cursor)
        elif inp == '2':
            cursor = db.posts.find({
                'uid': {
                    '$in': followings
                }
            }).sort('rawtime', pymongo.DESCENDING)
            dislikey(db, me, cursor)
        elif inp == '3':
            cursor = db.posts.find({
                'uid': {
                    '$in': followings
                }
            }).sort('rawtime', pymongo.DESCENDING)
            comment(db, me, cursor)
        else:
            input("잘못누르셨습니다. 엔터를 눌러주세요")
Exemplo n.º 21
0
def userpage(db, user,addstring=""):
    menu_num = -1
    while(menu_num != '0'):
        main.clear()
        user = db.member.find_one({'_id': user['_id']})
        if addstring=="":pass
        else:print(addstring)
        print("\n" + double)
        welcomeyou="Welcome %s"%user['name']
        print("\n"+welcomeyou.center(49))
        print("Select User Menu".center(49))
        print()
        print("+------------+------------------+-------------+")
        print("| 1 Status   | 2   Newsfeed     | 3  My wall  |")
        print("+------------+------------------+-------------+")
        print("| 4 Explore  | 5    Follow      | 6 Unfollow  |")
        print("+------------+------------------+-------------+")
        print("| 7  Hash#   | 8 Delete account | 9  My likes |")
        print("+------------+------------------+-------------+")
        print("| q LOG OUT  |")
        print("+------------+")
        print()
        print("\n" + double)
        menu_num = input("Enter : ")
        switcher = {
            'q' : log_out,
            '1' : mystatus,
            '2' : post.newsfeed,
            '3' : post.postInterface,
            '5' : follow.follow,
            '6' : follow.unfollow,
            '8' : delacc,
            '7' : hashtag.hashtag,
            '9' : post.showlikes,
            '4' : explore
        }
        selected_func = switcher.get(menu_num, print_wrong)
        a=selected_func(db,user)
        if  a:return
Exemplo n.º 22
0
def signin(db):
    while(True):
        a = """      
                  +-----------+
                  | 1 SIGN IN | 
                  +-----------+
                """
        print(a)
        print(double)
        print("(Press q to quit)")
        userid=input("                  ID : ")
        if userid=='q':return
        pw=input("                  password : "******"Log-in failed! Try again")
    print("Successfully logged in!")
    main.clear()
    userpage(db,user)
    '''
def menu():
    print("1. DEX Tools")
    print("2. Future Tone DSC Tools")
    print("3. LIT Tools")

    user_choice = input()
    if user_choice == "1":
        main.clear()
        diva_tools.dex_menu.menu()
    if user_choice == "2":
        main.clear()
        dsc_tools.future.ft_menu_main.main()
    if user_choice == "3":
        main.clear()
        diva_tools.litlib.menu()
Exemplo n.º 24
0
def roll_loop():
    done = False
    while not done:
        roll()
        done = not interactor.show_confirm_done()
        main.clear()
Exemplo n.º 25
0
def comment(db, me, cursor):
    try:

        cursor = list(cursor)
        #print(cursor)
        me = db.member.find_one({'_id': me['_id']})

        pnum = int(input("Enter post number : "))

        main.clear()
        if pnum == 'q': return
        apost = cursor[pnum]
        unique_id = apost['_id']

        while (True):
            apost = db.posts.find_one({'_id': unique_id})
            username = db.member.find_one({'_id': apost['uid']})['name']
            print("\n" + single)
            print('\nUser : '******'(@' + apost['uid'] + ')')
            print(apost['content'])
            lc = ("LIKE : " + str(apost['like']) + "  " + "Comments : " +
                  str(len(apost['comments'])))
            print(lc.rjust(49))
            print(apost['time'].rjust(49))
            print("\n")
            print("+댓글+".center(49))
            foundcomments = apost['comments']
            count = 0
            for c in foundcomments:
                print('@' + str(c['uid']) + "(" + str(count) + ") : " +
                      str(c['text']))
                count += 1
            print()
            print(single)
            your_comment = input("댓글(-번호 입력시 삭제됩니다) : ")

            if your_comment[0] == '-':
                try:
                    delnum = int(your_comment[1:])
                    count = 0
                    for c in foundcomments:
                        if count == delnum:
                            delcom = c
                        count += 1
                    commentlist = foundcomments
                    #print(commentlist)
                    #print(delcom)
                    commentlist.remove(delcom)
                    #print(commentlist)
                    db.posts.update({'_id': unique_id},
                                    {'$set': {
                                        'comments': commentlist
                                    }})

                    main.clear()
                    continue
                except:
                    main.clear()
                    continue

            if your_comment == 'q' or your_comment == "":
                print()
                return
            else:
                db.posts.update({'_id': unique_id}, {
                    '$push': {
                        'comments': {
                            'uid': me['_id'],
                            'text': your_comment
                        }
                    }
                })
            main.clear()
    except:
        input('Wrong ...press enter to try again')
Exemplo n.º 26
0
        # set up input
        input_packet_file = open(TEMP, 'w')
        input_packet_file.write(packet)
        input_packet_file.close()
        input_packet_file = open(TEMP, 'r')
        # set up output
        output_packet_filename = PACKET_FILE + str(starting_offset + i) + ".txt"
        output_packet_file = open(output_packet_filename, 'w')
        print "\nWriting packet " + str(i) + " of " + str(len(packets)) + " to " + output_packet_filename + "..."
        # set up stdin and stdout
        sys.stdout = output_packet_file
        sys.stdin = input_packet_file
        # Run the program
        program.Program(reader).run(main.process_extra_attribs, main.process_remainder)
        reader.clear()
        main.clear()
        # reset stdin and stdout
        sys.stdout = sys.__stdout__
        sys.stdin = sys.__stdin__
        # close the files
        output_packet_file.close()
        input_packet_file.close()
        # remove the temp file
        os.remove(TEMP)
    print "\nWrote " + str(len(packets)) + " files, starting with \'" + PACKET_FILE + str(starting_offset) + ".txt\'.\n"
except:
    traceback.print_exc(sys.exc_info()[2])
    print "\nUsage: python batch.py packets_file [" + main.CUSTOM + " custom_xml_file]"
    print "  \'packets_file\' - (first parameter, not optional) is a file containing hex packets separated by whitespace"
    print "  \'" + main.CUSTOM + " custom_xml_file\' - uses the path/file of the custom XML file"
Exemplo n.º 27
0
## Comments ##
# nmap scanner instead of using python socket server, it's up to you if you want to remove basic port scan option
# I understand with basic port scan it will remain all python, but I find it pointless to use.
# I set this up so I can utilize quick nmap scans to see what services are open.
# You can ultimatly set this up any way you want. this is just a template - jmarkwart

import os
import subprocess
from os import system
from main import EntContinue, clear
from time import sleep


while 1:
	try:
		clear()
		target = 0
		while target == 0:
			target = raw_input("Please enter the target IP / CIDR range: ") # IP/CIDR range to scan
	
		# options for nmap
		stealth = "-sS"
		OS = "-O"
		subprocess.Popen("sudo nmap -PN -sC -T5 %s %s %s" % (target, stealth, OS), shell=True).wait()
		
		sleep(1)
		EntContinue()
	
		# back to main
		break
	except KeyboardInterrupt:
Exemplo n.º 28
0
 def test_clear(self, Mockinput):
     """testing clear function calls os.system"""
     with patch('main.os') as Mocked_os:
         main.clear()
         Mocked_os.system.assert_called_once()
Exemplo n.º 29
0
def follow(db, user):
    main.clear()
    while(True):
        try:
            user = db.member.find_one({'_id': user['_id']})
            print()
            print("+-----------------+".center(49))
            print("|     FOLLOW      |".center(49))
            print("+-----------------+".center(49))
            print()
            printfollowings(db,user)
            print('Enter id to follow')
            followid=input("Search id (Press 'q' to quit) : ")
            follow = db.member.find_one({'_id': followid})
            if followid=='q':
                return

            else: blocklist = follow['block']
            if follow == None:
                main.clear()
                print('There is no such user\n')

            elif user['_id'] in blocklist:
                main.clear()
                print(followid+" - You are blocked by this user.\n")
            elif followid == user['_id']:
                main.clear()
                print("You can't follow yourself :P\n")
            elif followid in user["following"]:
                main.clear()
                print("You are already following.\n")
            else:

                db.member.update({'_id':user['_id']},{'$push':{'following':followid}})
                db.member.update({'_id':followid},{'$push':{'follower':user['_id']}})
                main.clear()
                print("You are now following @"+followid+"\n")
        except Exception as e:
            main.clear()
            print("Can't follow... Try again.")
            sys.stderr.write("could not operate following %s\n" %e)
Exemplo n.º 30
0
                     fg='maroon',
                     bg='gray75',
                     font=('comicsans', 12))
button_hint.config(width=6, height=2, command=lambda: hint())
button_hint.grid(column=3, row=0, padx=1, pady=1)

#2. riadok

button_clear = Button(frame2,
                      text='C',
                      fg='maroon',
                      bg='gray75',
                      font=('comicsans', 12))
button_clear.config(width=6,
                    height=2,
                    command=lambda: main.clear(text_input, text_output))
button_clear.grid(column=0, row=1, padx=1, pady=1)

button_div = Button(frame2,
                    text='/',
                    fg='maroon',
                    bg='gray75',
                    font=('comicsans', 12))
button_div.config(width=6, height=2, command=lambda: main.div(text_output))
button_div.grid(column=1, row=1, padx=1, pady=1)

button_mul = Button(frame2,
                    text='X',
                    fg='maroon',
                    bg='gray75',
                    font=('comicsans', 12))