Skip to content

Commit

Permalink
Merge pull request #10 from thepanacealab/finaledits
Browse files Browse the repository at this point in the history
update streaming.py
  • Loading branch information
jmbanda authored May 15, 2020
2 parents 807c236 + 4081c16 commit cb70f38
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions data_acquisition/streaming.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# The streaming.py code is compiled using the code from Global Connectivity and Multilinguals in the Twitter Network
# Paper citation - Hale, S. A. (2014) Global Connectivity and Multilinguals in the Twitter Network.In Proceedings of the 2014 ACM Annual Conference on Human Factors in Computing Systems, ACM (Montreal, Canada).
# Please cite this paper if using streaming.py code

from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
Expand All @@ -9,12 +13,6 @@
import zipfile
import zlib

try:
import smtplib
from email.mime.text import MIMEText
except:
sys.stderr.write("Error loading smtplib. Will not be able to send emails...\n")

# Output directory to hold json files (one per day) with tweets
# Within the output directory, the script loads a file named FILTER with the terms to be tracked (one per line)

Expand Down Expand Up @@ -76,7 +74,7 @@ def rotateFiles(self):
try:
self.fh.close()
except:
#Log/Email it
#Log it
pass
self.filename=filenow
self.fh = open(self.basePath + "/" + self.filename,"a")
Expand Down Expand Up @@ -150,13 +148,6 @@ class TimeoutException(Exception):
try:
info = str(e)
sys.stderr.write("%s - Unexpected exception. %s\n"%(datetime.now(),info))
msg = MIMEText("Unexpected error in Twitter collector. Check server. %s"%info)
msg['Subject'] = "Unexpected error in Twitter collector"
msg['From'] = "[email protected]"
msg['To'] = email
s = smtplib.SMTP("smtp.example.com") #Update this to your SMTP server
s.sendmail("[email protected]", email, msg.as_string())
s.quit()
except:
pass
time.sleep(1800)#Sleep thirty minutes and resume
Expand Down

0 comments on commit cb70f38

Please sign in to comment.