Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
allow for filters to be specified from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Lab41PaulM committed Feb 21, 2014
1 parent 752c603 commit 5040192
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/redwood
Expand Up @@ -10,24 +10,30 @@ import sys
import ConfigParser
import MySQLdb
import redwood.filters
import redwood.helpers.core as core
import redwood.connection.connect as rconn

from redwood.shell.controller import SessionController


def main(argv):

if(len(argv) != 1):
if(len(argv) != 1 and len(argv) != 2):
print "Please provide database configuration file"
sys.exit(1)

print '\033[1;31m\n\n#################################\nWelcome to Redwood\n#################################\n\033[1;m'

print "Establishing connection to database...\n",
print "...running with {} cores".format(multiprocessing.cpu_count())
print "...loading filters from ./Filters directory if exists"

cnx = rconn.connect_with_config(argv[0])


#import the filters
if(len(argv) == 2):
core.import_filters(argv[1], cnx)

sc = SessionController(cnx)
sc.preloop()
sc.cmdloop()
Expand Down
5 changes: 5 additions & 0 deletions redwood/helpers/core.py
Expand Up @@ -61,6 +61,9 @@ def import_filters(path, cnx):

new_filters = list()


print "Importing specified filters from {}".format(path)

#make sure path exists
if os.path.isdir(path) is False:
print "Error: path {} does not exist".format(path)
Expand Down Expand Up @@ -92,6 +95,8 @@ def import_filters(path, cnx):
filter_list.append(instance)
new_filters.append(instance)

print new_filters

return new_filters

def get_source_info(cnx, source_name):
Expand Down

0 comments on commit 5040192

Please sign in to comment.