Esempio n. 1
0
def userpage(db, user):
     while True:
        print("")
        time.sleep(0.5)
        print("(1) 내 상태창")
        print('(2) 뉴스피드 ')
        print('(3) 담벼락 ')
        print('(4) 포스팅 하기 ')
        print('(5) 팔로우 하기 ')
        print('(6) 팔로우 끊기 ')
        print('(7) 포스트 검색 ')
        print('(8) 로그아웃')
        print("")
        num = input("원하는 기능을 선택하세요: ")
        if int(num) == 1:
            mystatus(db, user)
        elif int(num) == 2:
            getPosts(db, user)
        elif int(num) == 3:
            postInterface(db, user)
        elif int(num) == 4:
            insertPost(db, user)
        elif int(num) == 5:
            follow(db, user)
        elif int(num) == 6:
            unfollow(db, user)
        elif int(num) == 7:
            search(db, user)
        elif int(num) == 8:
            return exit()
        else: return
        '''
Esempio n. 2
0
def srs_draw(S, n, t, rules, step=2, angle=60):
	"""This function uses the nth (argument) rewriting
	of the string S (argument) according to the rules given
	in the dictionary 'rules' to draw with a turtle t, which
	interprets the string symbols according as:
	F: move forward by fixed distance defined by 'step' argument
	E: same effect as F
	L: turn left by a fixed angle, given by 'angle' argument
	R: turn right by fixed angle ('angle')
	Any other symbols are ignored by the turtle.
	"""
	follow(t, srs_print(S, n , rules), [], step, angle)
Esempio n. 3
0
def srs_draw(S, n, t, rules, step=2, angle=60):
    """This function uses the nth (argument) rewriting
	of the string S (argument) according to the rules given
	in the dictionary 'rules' to draw with a turtle t, which
	interprets the string symbols according as:
	F: move forward by fixed distance defined by 'step' argument
	E: same effect as F
	L: turn left by a fixed angle, given by 'angle' argument
	R: turn right by fixed angle ('angle')
	Any other symbols are ignored by the turtle.
	"""
    follow(t, srs_print(S, n, rules), [], step, angle)
Esempio n. 4
0
def userpage(db, user):
    while True:
        try:
            print("-----[Welcome FIRA!!]-----\n"
                  "1. My status\n"
                  "2. News feed\n"
                  "3. Wall\n"
                  "4. Post\n"
                  "5. Follow\n"
                  "6. Unfollow\n"
                  "7. #Searching\n"
                  "8. blacklist\n"
                  "9. Logout\n")
            b = int(input("\nChoose one:"))
            if b == 1:
                mystatus(db, user)
            elif b == 2:
                newsfeed(db,user)
            elif b == 3:
                getPosts(db,user)
            elif b == 4:
                postInterface(db, user)
            elif b == 5:
                following_list = db.users.find_one({"_id": user})["followings"]
                if following_list:
                    print("Your followings : ", following_list)
                else:
                    print("You have no followings")
                following = input("Input userid to follow:")
                if following == user:
                    print("You can't follow yourself!")
                else:
                    follow(db, user, following)
            elif b == 6:
                following_list = db.users.find_one({"_id": user})["followings"]
                if following_list:
                    print("Your followings : ", following_list)
                else:
                    print("You have no followings")
                following = input("Input userid to unfollow:")
                unfollow(db, user, following)
            elif b == 7:
                findTag(db, user)

            elif b == 8:
                blockInterface(db, user)
            elif b == 9:
                return
            else:
                print("Wrong input!\n")

        except ValueError:
            print('[userpage]Error! Invalid input! try again\n')
Esempio n. 5
0
def userpage(db, user):
    '''
    user page
    '''

    while True:
        print("=" * 49)
        print("=============<{:^21s}>=============".format("USER PAGE"))
        print(
            "1. MY STATUS\n2. NEWSFEED\n3. WALL\n4. POST\n5. FOLLOW\n6. UNFOLLOW\n7. HASHTAG SEARCH\n8. MANAGE COMMENT\n9. Blacklist\n10.LOGOUT\n"
        )
        click = input("Enter Menu Number: ")
        print("=" * 49)
        if click == '1':
            mystatus(db, user)
            continue
        elif click == '2':
            getOtherPosts(db, user)
            continue
        elif click == '3':
            try:
                getPosts(db, user)
            except Exception as e:
                print(e)
                continue
        elif click == '4':
            try:
                postInterface(db, user)
            except Exception as e:
                print(e)
                continue
        elif click == '5':
            follow(db, user)
        elif click == '6':
            unfollow(db, user)
        elif click == '7':
            findpost(db, user)
            continue
        elif click == '8':
            manageComment(db, user)
            continue
        elif click == '9':
            manageBlack(db, user)
            continue
        elif click == '10':
            break

        else:
            print("Check Again Please")
Esempio n. 6
0
def srs_draw(S, n, t, rules, stack=[], step=4, angle=25):
	"""This function uses the nth (argument) rewriting
	of the string S (argument) according to the rules given
	in the dictionary 'rules' to draw with a turtle t, which
	interprets the string symbols according as:
	F: move forward by fixed distance defined by 'step' argument
	E: same effect as F
	L: turn left by a fixed angle, given by 'angle' argument
	R: turn right by fixed angle ('angle')
	[: add the location and heading to the 'stack' argument
	]: retrieve location and heading from stack
	Any other symbols are ignored by the turtle.
	"""

	t.left(90)
	# initial angle of turtle changed so desired image is printed upwards
	penup(t)
	t.sety(-350)
	pendown(t)
	# initial y-position of turtle changed so drawn fern can be seen in the window
	
	follow(t, srs_print(S, n , rules), stack, step, angle)
Esempio n. 7
0
def srs_draw(S, n, t, rules, stack=[], step=4, angle=25):
    """This function uses the nth (argument) rewriting
	of the string S (argument) according to the rules given
	in the dictionary 'rules' to draw with a turtle t, which
	interprets the string symbols according as:
	F: move forward by fixed distance defined by 'step' argument
	E: same effect as F
	L: turn left by a fixed angle, given by 'angle' argument
	R: turn right by fixed angle ('angle')
	[: add the location and heading to the 'stack' argument
	]: retrieve location and heading from stack
	Any other symbols are ignored by the turtle.
	"""

    t.left(90)
    # initial angle of turtle changed so desired image is printed upwards
    penup(t)
    t.sety(-350)
    pendown(t)
    # initial y-position of turtle changed so drawn fern can be seen in the window

    follow(t, srs_print(S, n, rules), stack, step, angle)
Esempio n. 8
0
# genshutdown.py
#
# Example of shutting down a generator
#
# Requires you to run run/foo/logsim.py to get a real-time source

from follow import *

lines = follow(open("run/foo/access-log"))
for i, line in enumerate(lines):
    print line,
    if i == 10:
        lines.close()
Esempio n. 9
0
# realtime404.py
#
# Print all 404 requests as they happen in the log

from apachelog import *
from follow import *

logfile = open("run/foo/access-log")
loglines = follow(logfile)
log = apache_log(loglines)

r404 = (r for r in log if r['status'] == 404)

for r in r404:
    print r['host'], r['datetime'], r['request']
Esempio n. 10
0
#
# Broadcast a generator source to a collection of consumers


def broadcast(source, consumers):
    for item in source:
        for c in consumers:
            c.send(item)


# Example
if __name__ == '__main__':

    class Consumer(object):
        def __init__(self, name):
            self.name = name

        def send(self, item):
            print self, "got", item

        def __repr__(self):
            return self.name

    c1 = Consumer('consumer1')
    c2 = Consumer('consumer2')
    c3 = Consumer('consumer3')

    from follow import *
    lines = follow(open("access-log"))
    broadcast(lines, [c1, c2, c3])
Esempio n. 11
0
        item_q.put(StopIteration)

    threading.Thread(target=run_all).start()
    while True:
        item = item_q.get()
        if item is StopIteration:
            return
        yield item


# Example use
#
# This example requires you to perform these setup steps:
#
# 1.  Go to run/foo and run logsim.py
# 2.  Go to run/bar and run logsim.py
#
# These two steps will start writing two different Apache log files.
# Now, we're going to read from both at the same time.

if __name__ == '__main__':
    from follow import *

    log1 = follow(open("run/foo/access-log"))
    log2 = follow(open("run/bar/access-log"))

    log = gen_multiplex([log1, log2])

    for line in log:
        print(line, )
Esempio n. 12
0
# sendto.py
#
# Send items to a remote machine

import socket
from genpickle import *


def sendto(source, addr):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(addr)
    for pitem in gen_pickle(source):
        s.sendall(pitem)
    s.close()

# Example use.   This requires you to run receivefrom.py
# in a different process/window

if __name__ == '__main__':
    from apachelog import *
    from follow import *

    lines = follow(open("www/foo/access-log"))
    log = apache_log(lines)
    sendto(log, ("127.0.0.1", 3333))
Esempio n. 13
0
        for t in thrlist: t.join()
        item_q.put(StopIteration)

    threading.Thread(target=run_all).start()
    while True:
        item = item_q.get()
        if item is StopIteration: return
        yield item


# Example use
#
# This example requires you to perform these setup steps:
#
# 1.  Go to run/foo and run logsim.py
# 2.  Go to run/bar and run logsim.py
#
# These two steps will start writing two different Apache log files.
# Now, we're going to read from both at the same time.

if __name__ == '__main__':
    from follow import *
    
    log1 = follow(open("run/foo/access-log"))
    log2 = follow(open("run/bar/access-log"))
    
    log = gen_multiplex([log1,log2])
    
    for line in log:
        print line,
Esempio n. 14
0
            time.sleep(0.1)
            continue
        yield line

# Example use
# Note : This example requires the use of an apache log simulator.
# 
# Go to the directory run/foo and run the program 'logsim.py' from
# that directory.   Run this program as a background process and
# leave it running in a separate window.  We'll write program
# that read the output file being generated
# 

if __name__ == '__main__':
    logfile = open("run/foo/access-log","r")
    loglines = follow(logfile)
    for line in loglines:
        print line,

# realtime404.py
#
# Print all 404 requests as they happen in the log

from apachelog import *
from follow import *

logfile  = open("run/foo/access-log")
loglines = follow(logfile)
log      = apache_log(loglines)

r404 = (r for r in log if r['status'] == 404)
Esempio n. 15
0
# storelast.py
# 获取生成器中最后一个值
# An iterator that stores the last value returned.


class storelast(object):
    def __init__(self, source):
        self.source = source

    def next(self):
        item = self.source.next()
        self.last = item
        return item

    def __iter__(self):
        return self


# Example
if __name__ == '__main__':
    from follow import *
    from apachelog import *

    lines = storelast(follow(open("access-log")))
    log = apache_log(lines)

    for r in log:
        print(r)
        print(lines.last)
Esempio n. 16
0
# storelast.py
#
# An iterator that stores the last value returned.  

class storelast(object):
    def __init__(self,source):
        self.source = source
    def next(self):
        item = self.source.next()
        self.last = item
        return item
    def __iter__(self):
        return self

# Example
if __name__ == '__main__':
    from follow import *
    from apachelog import *

    lines = storelast(follow(open("run/foo/access-log")))
    log   = apache_log(lines)

    for r in log:
        print r
        print lines.last
Esempio n. 17
0
# storelast.py
#
# An iterator that stores the last value returned.


class storelast(object):  # Store the last item generated
    def __init__(self, source):
        self.source = source

    def next(self):
        item = self.source.next()
        self.last = item
        return item

    def __iter__(self):
        return self


# Example
if __name__ == '__main__':
    from follow import *
    from apachelog import *

    lines = storelast(follow(open("run/foo/access-log")))
    log = apache_log(lines)

    for r in log:
        print(r)
        print(lines.last)
Esempio n. 18
0
    # 多线程将多个生成器的值放入queue中
    threading.Thread(target=run_all).start()

    while True:
        item = item_q.get()
        if item is StopIteration: return
        yield item


# Example use
#
# This example requires you to perform these setup steps:
#
# 1.  Go to run/foo and run logsim.py
# 2.  Go to run/bar and run logsim.py
#
# These two steps will start writing two different Apache log files.
# Now, we're going to read from both at the same time.

if __name__ == '__main__':
    from follow import *

    log1 = follow(open("access-log"))
    log2 = follow(open("access-log"))

    log = gen_multiplex([log1, log2])

    for line in log:
        print(line, )