Commit 53f4d009 authored by Francesco Poldi's avatar Francesco Poldi Committed by GitHub

Merge branch 'dev' into master

parents 1e51ef60 8f8731de
...@@ -195,6 +195,9 @@ def main(): ...@@ -195,6 +195,9 @@ def main():
if not args.index_users: if not args.index_users:
args.index_users = "twintUser" args.index_users = "twintUser"
if not args.essid:
args.essid = ""
c = initialize(args) c = initialize(args)
if args.favorites: if args.favorites:
......
VERSION = (1, 1, 3, 4) #mysql support VERSION = (1, 1, 3, 5) #mysql support
__version__ = '.'.join(map(str, VERSION)) __version__ = '.'.join(map(str, VERSION))
...@@ -29,7 +29,7 @@ class Config: ...@@ -29,7 +29,7 @@ class Config:
All = None All = None
Debug = False Debug = False
Format = None Format = None
Essid = None Essid = ""
Profile = False Profile = False
Followers = False Followers = False
Following = False Following = False
...@@ -42,6 +42,6 @@ class Config: ...@@ -42,6 +42,6 @@ class Config:
Pandas_type = None Pandas_type = None
Pandas = False Pandas = False
Search_name = "-" #for identify a records in mysql with the search it provides from. it cannot be null for DB requirements. a tweet must be in several search so the PK are tweet ID and search_name Search_name = "-" #for identify a records in mysql with the search it provides from. it cannot be null for DB requirements. a tweet must be in several search so the PK are tweet ID and search_name
Index_tweets = None Index_tweets = "twint"
Index_follow = None Index_follow = "twintGraph"
Index_users = None Index_users = "twintUser"
\ No newline at end of file
...@@ -91,7 +91,7 @@ def init(db): ...@@ -91,7 +91,7 @@ def init(db):
); );
""" """
cursor.execute(table_followers) cursor.execute(table_followers)
table_following = """ table_following = """
CREATE TABLE IF NOT EXISTS CREATE TABLE IF NOT EXISTS
following ( following (
...@@ -127,7 +127,7 @@ def fTable(Followers): ...@@ -127,7 +127,7 @@ def fTable(Followers):
table = "followers_names" table = "followers_names"
else: else:
table = "following_names" table = "following_names"
return table return table
def uTable(Followers): def uTable(Followers):
...@@ -135,7 +135,7 @@ def uTable(Followers): ...@@ -135,7 +135,7 @@ def uTable(Followers):
table = "followers" table = "followers"
else: else:
table = "following" table = "following"
return table return table
def follow(conn, Username, Followers, User): def follow(conn, Username, Followers, User):
...@@ -168,7 +168,7 @@ def user(conn, Username, Followers, User): ...@@ -168,7 +168,7 @@ def user(conn, Username, Followers, User):
User.media_count, User.media_count,
User.is_private, User.is_private,
User.is_verified, User.is_verified,
User.avatar, User.avatar,
date_time, date_time,
Username,) Username,)
query = 'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'.format(uTable(Followers)) query = 'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'.format(uTable(Followers))
......
...@@ -33,7 +33,6 @@ def fTable(Followers): ...@@ -33,7 +33,6 @@ def fTable(Followers):
table = "followers_names" table = "followers_names"
else: else:
table = "following_names" table = "following_names"
return table return table
def uTable(Followers): def uTable(Followers):
...@@ -41,7 +40,6 @@ def uTable(Followers): ...@@ -41,7 +40,6 @@ def uTable(Followers):
table = "followers" table = "followers"
else: else:
table = "following" table = "following"
return table return table
def follow(conn, Username, Followers, User): def follow(conn, Username, Followers, User):
...@@ -80,10 +78,9 @@ def user(conn, Username, Followers, User): ...@@ -80,10 +78,9 @@ def user(conn, Username, Followers, User):
query = 'INSERT INTO {} VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'.format(uTable(Followers)) query = 'INSERT INTO {} VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'.format(uTable(Followers))
cursor.execute(query, entry) cursor.execute(query, entry)
conn.commit() conn.commit()
except MySQLdb.IntegrityError: except MySQLdb.IntegrityError:
pass pass
def tweets(conn, Tweet, config): def tweets(conn, Tweet, config):
try: try:
......
...@@ -31,7 +31,16 @@ def hour(datetime): ...@@ -31,7 +31,16 @@ def hour(datetime):
return strftime("%H", localtime(datetime)) return strftime("%H", localtime(datetime))
def Tweet(Tweet, config): def Tweet(Tweet, config):
day = weekday(strftime("%A", localtime(Tweet.datetime))) weekdays = {
"Monday": 1,
"Tuesday": 2,
"Wednesday": 3,
"Thursday": 4,
"Friday": 5,
"Saturday": 6,
"Sunday": 7,
}
day = weekdays[strftime("%A", localtime(Tweet.datetime))]
actions = [] actions = []
nLikes = 0 nLikes = 0
...@@ -43,7 +52,7 @@ def Tweet(Tweet, config): ...@@ -43,7 +52,7 @@ def Tweet(Tweet, config):
j_data = { j_data = {
"_index": config.Index_tweets, "_index": config.Index_tweets,
"_type": "items", "_type": "items",
"_id": Tweet.id + "_raw_" + str(config.Essid), "_id": Tweet.id + "_raw_" + config.Essid,
"_source": { "_source": {
"id": Tweet.id, "id": Tweet.id,
"date": dt, "date": dt,
...@@ -58,7 +67,7 @@ def Tweet(Tweet, config): ...@@ -58,7 +67,7 @@ def Tweet(Tweet, config):
"link": Tweet.link, "link": Tweet.link,
"retweet": Tweet.retweet, "retweet": Tweet.retweet,
"user_rt": Tweet.user_rt, "user_rt": Tweet.user_rt,
"essid": str(config.Essid) "essid": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
...@@ -67,7 +76,7 @@ def Tweet(Tweet, config): ...@@ -67,7 +76,7 @@ def Tweet(Tweet, config):
j_data = { j_data = {
"_index": config.Index_tweets, "_index": config.Index_tweets,
"_type": "items", "_type": "items",
"_id": Tweet.id + "_likes_" + str(nLikes) + "_" + str(config.Essid), "_id": Tweet.id + "_likes_" + str(nLikes) + "_" + config.Essid,
"_source": { "_source": {
"id": Tweet.id, "id": Tweet.id,
"date": dt, "date": dt,
...@@ -83,7 +92,7 @@ def Tweet(Tweet, config): ...@@ -83,7 +92,7 @@ def Tweet(Tweet, config):
"link": Tweet.link, "link": Tweet.link,
"retweet": Tweet.retweet, "retweet": Tweet.retweet,
"user_rt": Tweet.user_rt, "user_rt": Tweet.user_rt,
"essid": str(config.Essid) "essid": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
...@@ -93,7 +102,7 @@ def Tweet(Tweet, config): ...@@ -93,7 +102,7 @@ def Tweet(Tweet, config):
j_data = { j_data = {
"_index": config.Index_tweets, "_index": config.Index_tweets,
"_type": "items", "_type": "items",
"_id": Tweet.id + "_replies_" + str(nReplies) + "_" + str(config.Essid), "_id": Tweet.id + "_replies_" + str(nReplies) + "_" + config.Essid,
"_source": { "_source": {
"id": Tweet.id, "id": Tweet.id,
"date": dt, "date": dt,
...@@ -109,7 +118,7 @@ def Tweet(Tweet, config): ...@@ -109,7 +118,7 @@ def Tweet(Tweet, config):
"link": Tweet.link, "link": Tweet.link,
"retweet": Tweet.retweet, "retweet": Tweet.retweet,
"user_rt": Tweet.user_rt, "user_rt": Tweet.user_rt,
"essid": str(config.Essid) "essid": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
...@@ -119,7 +128,7 @@ def Tweet(Tweet, config): ...@@ -119,7 +128,7 @@ def Tweet(Tweet, config):
j_data = { j_data = {
"_index": config.Index_tweets, "_index": config.Index_tweets,
"_type": "items", "_type": "items",
"_id": Tweet.id + "_retweets_" + str(nRetweets) + "_" + str(config.Essid), "_id": Tweet.id + "_retweets_" + str(nRetweets) + "_" + config.Essid,
"_source": { "_source": {
"id": Tweet.id, "id": Tweet.id,
"date": dt, "date": dt,
...@@ -135,7 +144,7 @@ def Tweet(Tweet, config): ...@@ -135,7 +144,7 @@ def Tweet(Tweet, config):
"link": Tweet.link, "link": Tweet.link,
"retweet": Tweet.retweet, "retweet": Tweet.retweet,
"user_rt": Tweet.user_rt, "user_rt": Tweet.user_rt,
"essid": str(config.Essid) "essid": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
...@@ -152,11 +161,11 @@ def Follow(user, config): ...@@ -152,11 +161,11 @@ def Follow(user, config):
j_data = { j_data = {
"_index": config.Index_follow, "_index": config.Index_follow,
"_type": "items", "_type": "items",
"_id": user + "_" + config.Username + "_" + str(config.Essid), "_id": user + "_" + config.Username + "_" + config.Essid,
"_source": { "_source": {
"user": user, "user": user,
"follow": config.Username, "follow": config.Username,
"essid": str(config.Essid) "essid": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
...@@ -172,7 +181,7 @@ def UserProfile(user, config): ...@@ -172,7 +181,7 @@ def UserProfile(user, config):
j_data = { j_data = {
"_index": config.Index_users, "_index": config.Index_users,
"_type": "items", "_type": "items",
"_id": user.id + "_" + user.join_date + "_" + user.join_time + "_" + str(config.Essid), "_id": user.id + "_" + user.join_date + "_" + user.join_time + "_" + config.Essid,
"_source": { "_source": {
"id": user.id, "id": user.id,
"name": user.name, "name": user.name,
...@@ -191,7 +200,7 @@ def UserProfile(user, config): ...@@ -191,7 +200,7 @@ def UserProfile(user, config):
"private": user.is_private, "private": user.is_private,
"verified": user.is_verified, "verified": user.is_verified,
"avatar": user.avatar, "avatar": user.avatar,
"session": str(config.Essid) "session": config.Essid
} }
} }
actions.append(j_data) actions.append(j_data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment