Exemplo n.º 1
0
def main(path):
    print "main started!!"
    global dissector_global_dir
    config = ConfigurationReader()   #Config parameters
    #Check if the path is a file or a dir
    if os.path.isdir(path):
        #Checking if path is OK
        if path[-1:] is not "/":
            path = path + "/"
        analyzeSample(path, config)
        #Could call to statistics.py to get some permissions statistics
        print "[*] Getting some statistics..."
        stats = Statistics(config.outputdir)
        stats.getStatistics()
        print "[*] Errors are reported in " + config.errorlogdir
        print "[*] More output for each APK available in " + config.outputdir

    else:
        #apkname = os.path.basename(path)
        start = time.time()
        #analyzeAPK(path, config)
        apk = ThreadAnalyzer(path,config)
        print "Analyzing APK " + path
        apk.start()
        #Wait until thread ends
        #if apk.isAlive():
        #    apk.join()
        end = time.time()
        print "Total time spent (seconds): %.2f" % (end - start)
 def _statloop(self):
   while not self.shutdown:
     with self.statwakeup:
       if self.settings.statinterval <= 0: self.statwakeup.wait()
       else:
         now = time.time()
         stats = Statistics(obj = self.core, ghashes = self.core.stats.ghashes, starttime = self.core.stats.starttime)
         stats.avgmhps =  1000. * stats.ghashes / (now - stats.starttime)
         stats.children = self.core.get_worker_statistics() \
                        + self.core.get_work_source_statistics() \
                        + self.core.get_blockchain_statistics()
         with self.lock:
           self._insert_stats(now, stats)
           self.db.commit()
         self.statwakeup.wait(self.settings.statinterval)
 def _statloop(self):
   while not self.shutdown:
     with self.statwakeup:
       if self.settings.statinterval <= 0: self.statwakeup.wait()
       else:
         now = time.time()
         stats = Statistics(obj = self.core, ghashes = self.core.stats.ghashes, starttime = self.core.stats.starttime)
         stats.avgmhps =  1000. * stats.ghashes / (now - stats.starttime)
         stats.children = self.core.get_worker_statistics() \
                        + self.core.get_work_source_statistics() \
                        + self.core.get_blockchain_statistics()
         with self.lock:
           self._insert_stats(now, stats)
           self.db.commit()
         self.statwakeup.wait(self.settings.statinterval)
def execute_one_experiment(port_class_number=None, ship_class_number=None, test_case=5, do_stats=True):
    if port_class_number==None:
        port_class_number=ONE_TEST[0]
    if ship_class_number==None:
        ship_class_number=ONE_TEST[1]
    port_class=import_port_class(port_class_number)
    ship_class=import_ship_class(ship_class_number)
    ware_class=Ware
    one_experiment=Experiment()
    stats_class=""
    if do_stats:
        stats_class=Statistics()
    one_experiment.make_experiment(ware_class, port_class, ship_class, test_case)
    if do_stats:
        stats_class.print_statistics(one_experiment)
    return one_experiment
Exemplo n.º 5
0
from core.statistics import Statistics

log = logging.getLogger("Main")

if __name__ == '__main__':

    parser = argparse.ArgumentParser(description='Ragpicker Statistics')
    subparsers = parser.add_subparsers(title='subcommands',
                                       description='valid subcommands',
                                       help='additional help')

    parser_long = subparsers.add_parser('long',
                                        help="Show statistics (long version)")
    parser_long.set_defaults(which='long')
    parser_short = subparsers.add_parser(
        'short', help="Show statistics (short version)")
    parser_short.set_defaults(which='short')
    parser_av = subparsers.add_parser('av',
                                      help="Show statistics (AV version)")
    parser_av.set_defaults(which='av')

    args = vars(parser.parse_args())

    logo()

    if args['which'] == 'long':
        Statistics().runStatisticsLong()
    elif args['which'] == 'short':
        Statistics().runStatisticsShort()
    elif args['which'] == 'av':
        Statistics().runStatisticsAV()
Exemplo n.º 6
0
def main(dir):
    if dir[-1:] is not "/":
        dir = dir + "/"
    if os.path.isdir(dir):
        statistics = Statistics(dir)
        statistics.getStatistics()
Exemplo n.º 7
0
from core.config import config
from core.environments import XORProblem
from core.statistics import Statistics
from core import neat, interface

env = XORProblem()
stats = Statistics()
algorithm = neat.NEAT(env.evaluate)
network_visualizer = interface.NetworkVisualizer()

for run in range(config.num_runs):
    for i in range(config.num_iter):
        best_individual = algorithm.epoch(stats)

        if config.visualize_best_networks:
            for spec in algorithm.population.species:
                for individual in spec.individuals:
                    network_visualizer.update_node_positions(
                        individual.connections, individual.nodes)

        if env.solved:
            stats.update_run(env.evaluations, best_individual)
            break

    if config.visualize_best_networks:
        network_visualizer.visualize_network(best_individual.connections)

    interface.plot_overall_fitness(stats.best_fitnesses, stats.avg_fitnesses,
                                   stats.stdev_fitnesses)
    interface.plot_structures(stats.avg_num_hidden_nodes,
                              stats.stdev_num_hidden_nodes,
Exemplo n.º 8
0
def statisticsFromDB(database):
    if os.path.isfile(database):
        statistics = Statistics(database)
        statistics.getStatisticsFromDB()
Exemplo n.º 9
0
config.num_iter = 201
config.pop_size = 300
config.c1 = 2.0
config.c2 = 2.0
config.compatibility_threshold = 1.0
config.ct_step = 0.15
config.ct_min_val = 0.4
config.ct_max_val = 4.6
config.new_node_probability = 0.06
config.new_connection_probability = 0.1
config.verbose = True
config.visualize_every = 200

env = LunarLander()
stats = Statistics()
algorithm = neat.NEAT(env.evaluate)
network_visualizer = interface.NetworkVisualizer()

agent_file_name = 'lunar-lander-agent.pickle'
video_file_name = 'lunar-lander-demo.mp4'
demonstrate = interface.demonstrate_if_exists(agent_file_name, env, video_file_name)

if demonstrate:
	exit()

for i in range(config.num_iter):
	interface.log('Generation: {:d}'.format(i))

	best_individual = algorithm.epoch(stats)
	env.seed += 1