示例#1
0
    def computeNone(self):
        if self.generate_new_graph:
            self.generate_new_graph = False

            today = datetime.date.today()
            year = today.year
            month = today.month

            self.redis_logger.debug('Building protocol graph')
            lib_words.create_curve_with_word_file(self.r_serv_trend,
                                                  self.csv_path_proto,
                                                  self.protocolsfile_path,
                                                  year, month)

            self.redis_logger.debug('Building tld graph')
            lib_words.create_curve_with_word_file(self.r_serv_trend,
                                                  self.csv_path_tld,
                                                  self.tldsfile_path, year,
                                                  month)

            self.redis_logger.debug('Building domain graph')
            lib_words.create_curve_from_redis_set(self.r_serv_trend,
                                                  self.csv_path_domain,
                                                  "domain", year, month)
            self.redis_logger.debug('end building')
示例#2
0
    while True:
        if message is not None:
            generate_new_graph = True

            filename, word, score = message.split()
            temp = filename.split('/')
            date = temp[-4] + temp[-3] + temp[-2]

            low_word = word.lower()
            prev_score = r_serv1.hget(low_word, date)
            if prev_score is not None:
                r_serv1.hset(low_word, date, int(prev_score) + int(score))
            else:
                r_serv1.hset(low_word, date, score)

        else:
            if generate_new_graph:
                generate_new_graph = False
                print 'Building graph'
                today = datetime.date.today()
                year = today.year
                month = today.month
                lib_words.create_curve_with_word_file(r_serv1, csv_path,
                                                      wordfile_path, year,
                                                      month)

            publisher.debug("Script Curve is Idling")
            print "sleeping"
            time.sleep(10)
        message = p.get_from_set()
示例#3
0
    generate_new_graph = False
    # Endless loop getting messages from the input queue
    while True:
        # Get one message from the input queue
        message = p.get_from_set()

        if message is None:
            if generate_new_graph:
                generate_new_graph = False
                today = datetime.date.today()
                year = today.year
                month = today.month

                print 'Building protocol graph'
                lib_words.create_curve_with_word_file(r_serv_trend,
                                                      csv_path_proto,
                                                      protocolsfile_path, year,
                                                      month)

                print 'Building tld graph'
                lib_words.create_curve_with_word_file(r_serv_trend,
                                                      csv_path_tld,
                                                      tldsfile_path, year,
                                                      month)

                print 'Building domain graph'
                lib_words.create_curve_from_redis_set(r_serv_trend,
                                                      csv_path_domain,
                                                      "domain", year, month)
                print 'end building'

            publisher.debug(
示例#4
0
def main():
    """Main Function"""

    # CONFIG #
    cfg = ConfigParser.ConfigParser()
    cfg.read(configfile)

    # SCRIPT PARSER #
    parser = argparse.ArgumentParser(
    description = '''This script is a part of the Analysis Information
    Leak framework.''',
    epilog = '''''')

    parser.add_argument('-l',
    type = str,
    default = "../files/list_categ_files",
    help = 'Path to the list_categ_files (../files/list_categ_files)',
    action = 'store')

    args = parser.parse_args()

    # REDIS #
    r_serv = redis.StrictRedis(
        host = cfg.get("Redis_Queues", "host"),
        port = cfg.getint("Redis_Queues", "port"),
        db = cfg.getint("Redis_Queues", "db"))

    r_serv1 = redis.StrictRedis(
        host = cfg.get("Redis_Level_DB", "host"),
        port = cfg.get("Redis_Level_DB", "port"),
        db = 0)

    # LOGGING #
    publisher.channel = "Script"

    # ZMQ #
    channel = cfg.get("PubSub_Words", "channel_0")
    subscriber_name = "curve"
    subscriber_config_section = "PubSub_Words"

    Sub = ZMQ_PubSub.ZMQSub(configfile, subscriber_config_section, channel, subscriber_name)

    # FUNCTIONS #
    publisher.info("Script Curve subscribed to channel {0}".format(cfg.get("PubSub_Words", "channel_0")))

    # FILE CURVE SECTION #
    csv_path = cfg.get("Directories", "wordtrending_csv")
    wordfile_path = cfg.get("Directories", "wordsfile")

    paste_words = []
    message = Sub.get_msg_from_queue(r_serv)
    prec_filename = None
    while True:
        if message != None:
            channel, filename, word, score = message.split()
            if prec_filename == None or filename != prec_filename:
                PST = P.Paste(filename)
                lib_words.create_curve_with_word_file(r_serv1, csv_path, wordfile_path, int(PST.p_date.year), int(PST.p_date.month))

            prec_filename = filename
            prev_score = r_serv1.hget(word.lower(), PST.p_date)
            print prev_score
            if prev_score != None:
                r_serv1.hset(word.lower(), PST.p_date, int(prev_score) + int(score))
            else:
                r_serv1.hset(word.lower(), PST.p_date, score)
             #r_serv.expire(word,86400) #1day

        else:
            if r_serv.sismember("SHUTDOWN_FLAGS", "Curve"):
                r_serv.srem("SHUTDOWN_FLAGS", "Curve")
                print "Shutdown Flag Up: Terminating"
                publisher.warning("Shutdown Flag Up: Terminating.")
                break
            publisher.debug("Script Curve is Idling")
            print "sleepin"
            time.sleep(1)

        message = Sub.get_msg_from_queue(r_serv)
示例#5
0
    # FILE CURVE SECTION #
    csv_path = os.path.join(os.environ['AIL_HOME'],
                            h.config.get("Directories", "wordtrending_csv"))
    wordfile_path = os.path.join(os.environ['AIL_HOME'],
                                 h.config.get("Directories", "wordsfile"))

    message = h.redis_rpop()
    prec_filename = None
    while True:
        if message is not None:
            channel, filename, word, score = message.split()
            if prec_filename is None or filename != prec_filename:
                PST = Paste.Paste(filename)
                lib_words.create_curve_with_word_file(
                    r_serv1, csv_path, wordfile_path, int(PST.p_date.year),
                    int(PST.p_date.month))

            prec_filename = filename
            prev_score = r_serv1.hget(word.lower(), PST.p_date)
            print prev_score
            if prev_score is not None:
                r_serv1.hset(word.lower(), PST.p_date,
                             int(prev_score) + int(score))
            else:
                r_serv1.hset(word.lower(), PST.p_date, score)

        else:
            if h.redis_queue_shutdown():
                print "Shutdown Flag Up: Terminating"
                publisher.warning("Shutdown Flag Up: Terminating.")
示例#6
0
    generate_new_graph = False
    # Endless loop getting messages from the input queue
    while True:
        # Get one message from the input queue
        message = p.get_from_set()

        if message is None:
            if generate_new_graph:
                generate_new_graph = False
                today = datetime.date.today()
                year = today.year
                month = today.month

                print('Building protocol graph')
                lib_words.create_curve_with_word_file(r_serv_trend, csv_path_proto,
                                                      protocolsfile_path, year,
                                                      month)

                print('Building tld graph')
                lib_words.create_curve_with_word_file(r_serv_trend, csv_path_tld,
                                                      tldsfile_path, year,
                                                      month)

                print('Building domain graph')
                lib_words.create_curve_from_redis_set(r_serv_trend, csv_path_domain,
                                                      "domain", year,
                                                      month)
                print('end building')


            publisher.debug("{} queue is empty, waiting".format(config_section))
示例#7
0
    while True:
        if message is not None:
            generate_new_graph = True

            filename, word, score = message.split()
            temp = filename.split('/')
            date = temp[-4] + temp[-3] + temp[-2]

            low_word = word.lower()
            prev_score = r_serv1.hget(low_word, date)
            if prev_score is not None:
                r_serv1.hset(low_word, date, int(prev_score) + int(score))
            else:
                r_serv1.hset(low_word, date, score)

        else:
            if generate_new_graph:
                generate_new_graph = False
                print 'Building graph'
                today = datetime.date.today()
                year = today.year
                month = today.month
                lib_words.create_curve_with_word_file(r_serv1, csv_path,
                                                      wordfile_path, year,
                                                      month)

            publisher.debug("Script Curve is Idling")
            print "sleeping"
            time.sleep(10)
        message = p.get_from_set()