Esempio n. 1
0
 def __init__(self, fecha):
     Analizer.__init__(self)
     self.__date = fecha
     self.meses = [
         'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio',
         'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'
     ]
 def __init__(self, numero):
     Analizer.__init__(self)
     self.__days = numero
     self.bulletin = "BOPCO"
     self.meses = [
         'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio',
         'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'
     ]
def data_analizer(current_file, current_patterns):
    patterns = []
    number = 0
    list_of_selections = []
    for file_name in files:
        if file_name+".dat" != current_file:
            try:
                _file = open(file_name+".dat", "r").readlines()
                analizer = Analizer(_file)
                analizer.find_patterns()
                patterns.append([file_name, analizer])
            except:
                pass
    for next_file in patterns:
        matches = next_file[1].best_match(current_patterns)
        match_filter = []
        for match in matches:
            if float(match[0]) < float(match[1]):
                match_filter.append([match[1], match[0], len(match[2])])
        last = None
        dict_list = []
        match_dict = []
        for match in sorted(match_filter, key=itemgetter(0)):
            if last != match[0]:
                if last!= None:
                    match_dict.append({last:dict_list})
                last = match[0]
                dict_list = []
            dict_list.append([match[1], match[2]])
        selection = []
        for match in reversed(match_dict):
            print match
            selection.append(best_option(match))
        allow_time = real_duration
        allow_time = allow_time-(allow_time*.15)
        filter_selection = []
        for element in selection:
            if element[0] > allow_time:
                filter_selection.append(element)
        small_time = 0
        for sel in sorted(filter_selection, key=itemgetter(1)):
            if sel[2]!=0:
                if small_time == 0:
                    small_time = sel
                if small_time[1] > sel[1]:
                    small_time = sel
        list_of_selections.append([next_file[0],small_time])
    best_selection = None
    small_time = None
    for i in range(len(list_of_selections)):
        if small_time == None:
            small_time = list_of_selections[i][1][1]
        if small_time < list_of_selections[i][1][1]:
            small_time = list_of_selections[i][1][1]
            best_selection = list_of_selections[i][0]
    return best_selection
Esempio n. 4
0
 def __init__(self, numero):
     Analizer.__init__(self)
     self.meses = [
         'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio',
         'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'
     ]
     self.__days = numero
     self.bulletin = "BOE"
     self.urls = [
     ]  # Aquí vamos metiendo las urls que hay que analizar en las diferentes pasadas.
     self.urls_visited = []
def next_track(current_file):
    _file = open(current_file+".dat", "r").readlines()
    a = Analizer(_file)
    patterns = a.find_patterns()
    data = data_analizer(current_file+".dat", patterns)
    if data != None:
        print data
        print "from analizer\n"
    else:
        print files[random.randint(0, len(files)-1)]
        print "from random\n"
Esempio n. 6
0
def reading(name):
    """
    Reading all.json and return all the info
    """
    info = json.load(open('all.json', encoding='utf-8'))

    for chat in info['chats']['list']:
        try:

            if chat["name"] == name:
                break
        except:
            if chat["type"] == "saved_messages":
                pass
            else:
                print("Error003")

    with open("cur_dialog.json", "w") as fp:
        json.dump(chat, fp)

    chat = json.load(open('cur_dialog.json', encoding='utf-8'))
    # user1 = User(info['personal_information']["first_name"] +
    #              info['personal_information']["last_name"])

    user1 = User(self_name)
    user2 = User(name)
    cur_chat = Chat(user1, user2)
    for mes in chat['messages']:
        cur_chat.handle_message(mes)
    d_a = dialogue_analiz(cur_chat.dialogues)
    user2.total = cur_chat.total
    print(str(user1))
    print(str(user2))
    analiz = Analizer(user2, d_a)
    print(str(analiz))
Esempio n. 7
0
def main():
    logging.basicConfig(level=logging.INFO, filename="typo_pypi.log")
    should_roll_over = os.path.isfile("typo_pypi.log")
    handler = logging.handlers.RotatingFileHandler("typo_pypi.log",
                                                   mode='w',
                                                   backupCount=0)
    results = logging.handlers.RotatingFileHandler("results2.txt",
                                                   mode='w',
                                                   backupCount=0)
    try:
        samplesize = sys.argv
        config.samplesize = samplesize[1]
    except IndexError:
        print("specify a samplesize in range of 0-3999")
        return

    if should_roll_over:  # log already exists, roll over!
        handler.doRollover()
        results.doRollover()
        pass
    try:
        threads = []
        tmp_dir = tempfile.mkdtemp(prefix="typo_pypi")
        analizer = Analizer("analizerthread", c)
        client = Client("clientthread", tmp_dir, c)
        validater = Validater("validaterhtread", c)

        analizer.start()
        threads.append(analizer)
        threads.append(client)
        threads.append(validater)
        client.start()
        validater.start()

        logging.info('threads started')
        # class methods should execute
        for thread in threads:
            thread.join()
            time.sleep(1)
    finally:
        try:
            shutil.rmtree(tmp_dir)
        except OSError as exc:
            if exc.errno != errno.ENOENT:
                raise  # re-raise exception
Esempio n. 8
0
 def __init__(self, f):
     Analizer.__init__(self)
     self.__date = f
Esempio n. 9
0
import sys
import os

from analizer import Analizer

current_directory = ""
if (len(sys.argv) == 1):
    print "No arguments found!"
    # set current directory as work directory
    current_directory = os.path.realpath(os.curdir)
else:
    current_directory = os.path.realpath(sys.argv[1])

print ("Program will try to analyze \"" +
       current_directory + "\" directory")
analize_tool = Analizer(current_directory)
total = analize_tool.analize_dir("result.txt")
print "End of program"
quit()
Esempio n. 10
0
 def __init__(self,numero):
     Analizer.__init__(self)
     self.__days = numero
     self.bulletin = "BOPLU"
Esempio n. 11
0
from analizer import Analizer
from AnalizerModel import AnalizerModel

import sys

print ("Working...")

num_days = 1
if (len(sys.argv) > 1):
    num_days = int(sys.argv[1])
p = Analizer()
analizerm = AnalizerModel()
analizers = analizerm.getActive()
for a in analizers:
    module = __import__(a.module)
    class_ = getattr(module, a.classname)
    instance = class_(num_days)
    #instance.imprimir()
    p.addAnalizer(instance)
p.work()
print ("End.")