Skip to content

Commit

Permalink
Added checking for the config file at the beginning of each step of t…
Browse files Browse the repository at this point in the history
…he process. This is begging for refactoring (#68)
  • Loading branch information
alexcpsec committed Sep 16, 2014
1 parent 0b77dd3 commit 501a99f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion baler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def tiq_output(reg_file, enr_file):
config = ConfigParser.SafeConfigParser()
cfg_success = config.read('combine.cfg')
if not cfg_success:
sys.stderr.write('Could not read combine.cfg.\n')
sys.stderr.write('tiq_output: Could not read combine.cfg.\n')
sys.stderr.write('HINT: edit combine-example.cfg and save as combine.cfg.\n')
return

Expand Down Expand Up @@ -93,6 +93,13 @@ def bale_enr_csvgz(harvest, output_file):


def bale(input_file, output_file, output_format):
config = ConfigParser.SafeConfigParser()
cfg_success = config.read('combine.cfg')
if not cfg_success:
sys.stderr.write('Baler: Could not read combine.cfg.\n')
sys.stderr.write('HINT: edit combine-example.cfg and save as combine.cfg.\n')
return

sys.stderr.write('Reading processed data from %s\n' % input_file)
with open(input_file, 'rb') as f:
harvest = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion reaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def reap(file_name):
config = ConfigParser.SafeConfigParser(allow_no_value=False)
cfg_success = config.read('combine.cfg')
if not cfg_success:
sys.stderr.write('Could not read combine.cfg.\n')
sys.stderr.write('Reaper: Could not read combine.cfg.\n')
sys.stderr.write('HINT: edit combine-example.cfg and save as combine.cfg.\n')
return

Expand Down
9 changes: 9 additions & 0 deletions thresher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ConfigParser
import bs4
import datetime
import feedparser
Expand Down Expand Up @@ -134,6 +135,14 @@ def process_malwaregroup(response, source, direction):


def thresh(input_file, output_file):

config = ConfigParser.SafeConfigParser(allow_no_value=False)
cfg_success = config.read('combine.cfg')
if not cfg_success:
sys.stderr.write('Thresher: Could not read combine.cfg.\n')
sys.stderr.write('HINT: edit combine-example.cfg and save as combine.cfg.\n')
return

sys.stderr.write('Loading raw feed data from %s\n' % input_file)
with open(input_file, 'rb') as f:
crop = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion winnower.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def winnow(in_file, out_file, enr_file):
config = ConfigParser.SafeConfigParser(allow_no_value=True)
cfg_success = config.read('combine.cfg')
if not cfg_success:
sys.stderr.write('Could not read combine.cfg.\n')
sys.stderr.write('Winnower: Could not read combine.cfg.\n')
sys.stderr.write('HINT: edit combine-example.cfg and save as combine.cfg.\n')
return

Expand Down

0 comments on commit 501a99f

Please sign in to comment.