Skip to content

Commit

Permalink
Merge pull request cvandeplas#22 from CIRCL/master
Browse files Browse the repository at this point in the history
boundary check fixed (cosmetic)
  • Loading branch information
cvandeplas committed Jul 28, 2014
2 parents 777651b + 7146ad5 commit 2be37c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pystemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import gzip
import hashlib
import traceback
import redis
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
Expand Down Expand Up @@ -221,12 +222,18 @@ def savePastie(self, directory):
if not self.pastie_content:
raise SystemExit('BUG: Content not set, sannot save')
full_path = verifyDirectoryExists(directory) + os.sep + self.site.pastieIdToFilename(self.id)
if yamlconfig['redis']['queue']:
r = redis.StrictRedis(host=yamlconfig['redis']['server'],port=yamlconfig['redis']['port'],db=yamlconfig['redis']['database'])
if self.site.archive_compress:
with gzip.open(full_path, 'w') as f:
f.write(self.pastie_content.encode('utf8'))
if yamlconfig['redis']['queue']:
r.lpush('pastes', full_path)
else:
with open(full_path, 'w') as f:
f.write(self.pastie_content.encode('utf8'))
if yamlconfig['redis']['queue']:
r.lpush('pastes', full_path)

def fetchAndProcessPastie(self):
# double check if the pastie was already downloaded, and remember that we've seen it
Expand Down Expand Up @@ -578,10 +585,10 @@ def http_error_302(self, req, fp, code, msg, headers):

def downloadUrl(url, data=None, cookie=None, loop_client=0, loop_server=0):
# Client errors (40x): if more than 5 recursions, give up on URL (used for the 404 case)
if loop_client > retries_client:
if loop_client >= retries_client:
return None, None
# Server errors (50x): if more than 100 recursions, give up on URL
if loop_server > retries_server:
if loop_server >= retries_server:
return None, None
try:
opener = None
Expand Down
6 changes: 6 additions & 0 deletions pystemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ db:
enable: no # Activate this DB engine # NOT FULLY IMPLEMENTED
file: 'db.sqlite3' # The filename of the database

redis:
queue: yes
server: "localhost"
port: 6379
database: 10

email:
alert: no # Enable/disable email alerts
from: [email protected]
Expand Down

0 comments on commit 2be37c9

Please sign in to comment.