Exemplo n.º 1
0
    def askpg(self):
        session = pCur()
        pqutweet = session.query(PSQLTweet).\
         filter(PSQLTweet.postid == self.postid).one_or_none()

        session.close()

        if pqutweet is None:
            self.lastupdate = None
        else:
            self.lastupdate = pqutweet.revuptime()
Exemplo n.º 2
0
    def askpg(self):
        session = pCur()
        pquser = session.query(PSQLUser).\
         filter(PSQLUser.userid == self.uinte).one_or_none()

        if pquser is None:
            self.lastupdate = None
        else:
            self.lastupdate = pquser.revuptime()

        session.close()
Exemplo n.º 3
0
        def _update_pg(uuid, userid):
            session = pCur()

            if uuid:
                point = session.query(PSQLUser).filter(
                    PSQLUser.userid == userid).one()
                point.update()

            else:
                session.add(PSQLUser(userid))

            session.commit()
            session.close()
Exemplo n.º 4
0
        def _update_pg(uuid, postid):
            session = pCur()

            if uuid:
                point = session.query(PSQLTweet).filter(
                    PSQLTweet.postid == postid).one()
                point.update()

            else:
                session.add(PSQLTweet(self.postid))

            session.commit()
            session.close()
Exemplo n.º 5
0
        def _pass_page(userid, plist, npage):
            session = pCur()
            pquser = session.query(PSQLUser).\
             filter(PSQLUser.userid == userid).one()

            pqpage = session.query(friendlist).\
             filter(and_(friendlist.userid == userid, friendlist.page == npage)).one_or_none()

            if pqpage is None:
                pagfr = friendlist(userid, ncursor)
                pagfr.setlist(plist)
                session.add(pagfr)
            else:
                pqpage.setlist(plist)

            session.commit()
            session.close()
Exemplo n.º 6
0
        def _get_access(userid):
            session = pCur()
            gauser = session.query(PSQLUser).\
             filter(PSQLUser.userid == userid).one_or_none()
            number = session.query(followerlist).\
             filter(followerlist.userid == userid).count()

            if gauser is None:
                return 0, None
            else:
                if not number:
                    session.close()
                    return 0, -1
                else:
                    n = gauser.fwpages[-1].revpage()  # or -1
                    session.close()
                    return number, n
Exemplo n.º 7
0
        def _pass_page(userid, plist, npage):
            session = pCur()
            pquser = session.query(PSQLUser).\
             filter(PSQLUser.userid == userid).one()

            pqpage = session.query(followerlist).\
             filter(and_(followerlist.userid == userid, followerlist.page == npage)).one_or_none()

            if pqpage is None:
                pagfw = followerlist(userid, ncursor)
                pagfw.setlist(plist)
                pquser.fwpages.append(pagfw)
            else:
                pqpage.setlist(plist)

            session.commit()
            session.close()
Exemplo n.º 8
0
    def connected(self, query):
        session = DBC()

        if query.startswith("users"):
            points = session.query(dbUser).all()

            csv_file = open('./' + self.conjson["dbname"] + '-users.csv',
                            mode='w')

            csv_file.write(
                "index , userid, screenname , followers , friends\n")

            for po in points:

                csv_file.write("{}, {}, {}, {}, {}\n".format(
                    po.index, po.userid, po.screenname, po.followers_count,
                    po.friends_count))

        elif query.startswith("tweets"):
            points = session.query(dbTweet).all()

            csv_file = open('./' + self.conjson["dbname"] + '-tweets.csv',
                            mode='w')
        elif query.startswith("edges"):

            # points = session.query(dbUser).all()

            csv_file = open('./' + self.conjson["dbname"] + '-edges.csv',
                            mode='w')

            # csv_file.write("user, fr\n")

            session_edge = pCur()

            # for point in points:
            pquser = session_edge.query(PSQLUser).\
            filter(PSQLUser.userid == '240664869').one()

            if (not pquser is None):  #or (point.userid == '240664869'):
                if not len(pquser.fwpages) == 0:  #point.userid == '240664869':
                    for page in pquser.fwpages:
                        for i in page.flist:
                            # if i in [pi.userid for pi in points]:
                            # us = clsuser(i)
                            csv_file.write("{}, {}\n".format(i, '240664869'))

                if not len(pquser.frpages) == 0:
                    for page in pquser.frpages:
                        for i in page.flist:
                            # if i in [pi.userid for pi in points]:
                            # us = clsuser(i)
                            csv_file.write("{}, {}\n".format('240664869', i))
                # else:
                # 	continue

            session_edge.close()

        #         # get info to update
        # else:
        #     js = json.loads(user.usjson)

        #         csv_file.write("%s , %s , %s , %s , %s , %s , %s , %s , %s , %s , %s \n" % (str(user.index) ,str(user.screenname) ,str(user.lastupdate) ,str(js["created_at"]) ,str(js["statuses_count"]) ,str(js["favourites_count"]) ,str(js["followers_count"]) ,str(js["friends_count"]) ,str(js["default_profile"]) ,str(js["verified"]) ,str(js["protected"])))

        # if not user.botometer == None:
        #     uvb += 1
        session.close()
        csv_file.close()
        # print("total users: {} \t need GetUserInfo users: {} include botometer scores: {} \n \t\t total edges store: \n".format(len(users), uvu, uvb))
        # input("press enter to continue ... ")

        # print("total tweets: {} \t total urls: {} & hashtags: {} & mention links: {} \n".format( len(tweets), len(urls), len(hashs), len(mentions)))
        # for tweet in reversed(tweets):
        #     jj = json.loads(tweet.twjson)
        #     print("{}: {} : {} \n\t retweeted : {} favorited : {} \n\t hash : {}\n\t {} \n".format(tweet.index, jj['id'], jj['created_at'], jj['retweet_count'], jj['favorite_count'], len(jj['entities']['hashtags']),jj['full_text']))
        #     break
        input("press enter to continue ... ")