Ejemplo n.º 1
0
def main():

	init.config()
	stats_ctrl = StatsController( file_name )

	node_ctrl = NodeController()
	node_ctrl.create_nodes()
	node_ctrl.find_all_neighbours()

	print("> Inizio simulazione ")

	for i, gamma in enumerate(init.GAMMA):
		perc_done = int((i+1)/len(init.GAMMA)*100)
		print("\b> "+str(gamma)+" \t\t "+str(perc_done)+"%")
		for a in range(0, init.SIMULATION_REPETITION):

			transmission_ctrl = TransmissionController( gamma )

			simulation = Simulator( node_ctrl, transmission_ctrl, gamma )
			simulation.initialize()

			while( not simulation.finish() ):
				simulation.step()

			stats_ctrl.process( node_ctrl, gamma, a )
			node_ctrl.clear();

			sys.stdout.write("\b%s" % syms[ a % len(syms) ])
			sys.stdout.flush()

	print("\b" + colors.OKGREEN + " Simulazione conclusa" + colors.ENDC)
	print("Ho creato il file: " + colors.OKGREEN + file_name + ".svg" + colors.ENDC)
	print("Ho creato il file: " + colors.OKGREEN + file_name + "-nodes.svg" + colors.ENDC)
Ejemplo n.º 2
0
 def __init__(self):
     u"""
     配置文件使用$符区隔,同一行内的配置文件归并至一本电子书内
     """
     init = Init()
     SqlClass.set_conn(init.getConn())
     self.config = Setting()
     return
Ejemplo n.º 3
0
 def __init__(self):
     ini = Init()
     self.language,self.langpath = ini.read()
     self.run = run.run()
     self.runc = run.run_cn()
     
     gettext.install("lang",self.langpath,codeset="utf-8")
     gettext.translation("lang",self.langpath,languages=[self.language])
     self._ = gettext.gettext
Ejemplo n.º 4
0
 def __init__(self):
     u"""
     配置文件使用$符区隔,同一行内的配置文件归并至一本电子书内
     """
     self.checkUpdate()
     init = Init()
     SqlClass.set_conn(init.getConn())
     self.baseDir = os.path.realpath('.')
     self.config = Setting()
     return
Ejemplo n.º 5
0
 def __init__(self):
     u"""
     配置文件使用$符区隔,同一行内的配置文件归并至一本电子书内
     """
     self.checkUpdate()
     init = Init()
     SqlClass.set_conn(init.getConn())
     self.baseDir = os.path.realpath('.')
     self.config = Setting()
     return
Ejemplo n.º 6
0
 def __init__(self):
     self.closed = False
     self.command = str()
     self.args = defaultdict(list)
     self.command_history = list()
     self.valid_commands = {}
     self.valid_commands["init"] = Init()
     self.valid_commands["push"] = Push()
     self.valid_commands["pull"] = Pull()
     self.valid_commands["config"] = Config()
     self.valid_commands["dir"] = Dir()
     self.valid_commands["purgue"] = Purgue()
Ejemplo n.º 7
0
def init(version: str):
    """init dirs and fetch code.
    """
    InitHandler = Init()
    InitHandler.create_dirs()
    asyncio.run(InitHandler.fetch_jars('3.1.3'))
    asyncio.run(InitHandler.move_jars())
Ejemplo n.º 8
0
 def start(self, progress):
     if progress == 1:
         with Init() as i:
             i.checkUtils()
     if progress == 2:
         with JobScraper() as js:
             js.checkScrape()
     if progress == 3:
         with ScrapeEmails() as se:
             se.begin()
     if progress == 4:
         with Emailer() as e:
             e.begin()
Ejemplo n.º 9
0
def init(version: str):
    """init dirs and fetch code.
    """
    init_handler = Init(ROOT_PATH)
    progress_msg('Creating folders')
    init_handler.create_dirs()
    progress_msg('Downloading release builds')
    asyncio.run(init_handler.fetch_jars(version))
    asyncio.run(init_handler.move_jars())
Ejemplo n.º 10
0
def main(mycfg):
    logging.info("# start system")

    init = Init(mycfg=mycfg)
    init.check()
    init.close()
    logging.info("# finish initialize")
    """ Class """
    obj = EmptyObject()
    obj.neko = EtherInterface(mycfg=mycfg)
    obj.tip = TipnemControl(mycfg=mycfg)
    obj.income = IncomingPolling(mycfg=mycfg)
    obj.rest = RestApi(mycfg=mycfg)
    """ import object """
    obj.neko.obj = obj
    obj.tip.obj = obj
    obj.income.obj = obj
    obj.rest.obj = obj
    """ threading start """
    obj.income.start()
    obj.rest.start()
    obj.tip.start_control()  # blocking main thread
    """ check """
    count = 0
    while True:
        try:
            count += 1
            time.sleep(1)
            if mycfg.stop_signal:
                raise Exception("kill signal")
            if count % 1800 == 0:
                logging.info("# checking living %d" % count)

        except Exception as e:
            logging.info("# input stop signal")
            while True:
                mycfg.stop_signal = True
                time.sleep(1)
                for name in mycfg.stop_need_obj:
                    if name not in mycfg.stop_ok:
                        logging.info("# wait for %s" % name)
                        break
                else:
                    logging.info("# exit ok!")
                    exit(0)
Ejemplo n.º 11
0
def main():

    init = Init()

    if init.provider_token != None and init.provider_zone != None:
        cf = Cloudflare(token=init.provider_token, zonename=init.provider_zone)
        # try:
        #     cf = Cloudflare(token=init.provider_token, zonename=init.provider_zone)
        # except ValueError as e:
        #     print("Could not connect to DNS provider, check your token and zone")
        #     return
        if cf:
            for entry in init.parsed_dns_records:
                if (entry.get('valid') == True):
                    if (entry.get('type').upper() == 'CNAME'):
                        cf.createDNSrecord(entry.get('name'),
                                           entry.get('target'),
                                           entry.get('type'))
                    else:
                        print("Creating {} {} {}".format(
                            entry.get('name'), entry.get('type'),
                            entry.get('IP')))
                        cf.createDNSrecord(entry.get('name'), entry.get('IP'),
                                           entry.get('type'))
Ejemplo n.º 12
0
import sys
from PyQt5.QtWidgets import QApplication

from init import Init
from user import MainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    initWindow = Init()
    mainWindow = MainWindow()

    initWindow.loginButton.clicked.connect(mainWindow.handle_visible)
    initWindow.loginButton.clicked.connect(initWindow.hide)
    initWindow.close_signal.connect(initWindow.close)
    initWindow.show()
    sys.exit(app.exec_())
Ejemplo n.º 13
0
import sys
from init import Init
from functions.data_process import prepare_dataset
from functions.data_process import dataset_statistics
from functions.model_process import predict_ml
from functions.model_process import train_ml
from functions.model_process import single_predict_ml

#init returns: 	0 = MODE; 		1 = TYPE; 			2 = Filename for save model; 	3 = Fake CSV; 
# 				4 = True CSV	5 = Label for fake; 6 = Label for true; 			7 = verification label; 		
#				8 = percentage	9 = clean			10= Filename for processed data	11= Clean level
init_data = Init()

def switch(argument):
	if argument == "TEST_ML":
		predict_ml(dataset, init_data[2])
	elif argument == "TRAIN_ML":
		print ( "Preparing dataset..." )
		dataset = prepare_dataset(init_data[3],init_data[4],init_data[5],init_data[6],init_data[7],init_data[8],init_data[9],init_data[11]);
		train_ml(dataset, init_data[2])
	elif argument == "STATISTICS_ML":
		dataset_statistics(init_data[3],init_data[4],init_data[5],init_data[6],init_data[7],init_data[8],init_data[9],init_data[10],init_data[11]);
	elif argument == "STEST_ML":
		single_predict_ml(str(sys.argv[1]),init_data[2],init_data[9])
switch( (init_data[0]+"_"+init_data[1]))

Ejemplo n.º 14
0
# -*- coding: utf-8 -*-
import sys

reload(sys)
sys.setdefaultencoding('utf8')

# 添加库路径
currentPath = sys.path[0].replace('unit', '')
sys.path.append(currentPath)
sys.path.append(currentPath + r'codes')
sys.path.append(currentPath + r'codes\parser')

sys.setrecursionlimit(1000000)  # 为了适应知乎上的长答案,需要专门设下递归深度限制。。。

from baseClass import *
from login import Login
from init import Init

init = Init()
SqlClass.set_conn(init.getConn())
login = Login()
login.login()
Ejemplo n.º 15
0
db_session = scoped_session(
    sessionmaker(autocommit=False, autoflush=False, bind=engine))

migrate = Migrate(app, db)

ma = Marshmallow(app)

manager = Manager(app)
manager.add_command('runserver', Server())
manager.add_command(
    'shell', Shell(make_context=lambda: {
        'app': app,
        'db_session': db_session
    }))
manager.add_command('db', MigrateCommand)
manager.add_command('init', Init())

environment = Environment(app)
environment.append_path(str(cwd / 'static'))
environment.append_path(str(cwd / 'bower_components'))

version = subprocess.check_output(['git', 'describe', '--tags', '--always'],
                                  cwd=str(cwd)).decode(
                                      sys.stdout.encoding).strip()

app.config['SECRET_KEY'] = config['SECRET_KEY']
app.config['SESSION_PROTECTION'] = 'strong'
app.config['SOCIAL_AUTH_LOGIN_URL'] = '/login'
app.config['SOCIAL_AUTH_LOGIN_REDIRECT_URL'] = '/?logged_in=1'
app.config['SOCIAL_AUTH_USER_MODEL'] = 'models.User'
app.config['SOCIAL_AUTH_AUTHENTICATION_BACKENDS'] = (
Ejemplo n.º 16
0
from asynchronous import Catch
import asyncio
import os 
import requests
import shutil
import json
import sys
import time
from image_data import ImageData

# current database location, ran by C1C Zach Lorch (@LorchZachery)
dfcsURL = 'http://10.10.10.40/capstone/scripts/'
url = dfcsURL + 'query.php'

#initialize main dictionary, important variables, etc. -> init.py
initial = Init()

def query_db(statement, command, verbose=False):
    data = {'query' : statement, 'type' : command}
    #try:
    r = requests.post(url, data = data)
    #except:
    #    url = urlNetwork + 'scripts/query.php'
    #    r = requests.post(url, data = data)
    b = r.content.decode()
    if command == 'SELECT':
        load = json.loads(b)
        final = json.dumps(load, indent =4)
        if verbose:
            print(final)
        return load
from flask import Flask
import webbrowser

######### CONFIGURATION #########
# the gamma value to simulate
# (inter-arrival-time in seconds)
gamma = 0.005
###### END OF CONFIGURATION #####

syms = ['\\', '|', '/', '-']
bs = '\b'
file_name = 'stats'

number = 0

init.config()

node_ctrl = NodeController()
node_ctrl.create_nodes()
node_ctrl.find_all_neighbours()

print("> Inizio simulazione")

transmission_ctrl = TransmissionController(gamma)
simulation = Simulator(node_ctrl, transmission_ctrl, gamma)
simulation.initialize()

webbrowser.open('http://127.0.0.1:5000/', new=0)

app = Flask('testapp')
Ejemplo n.º 18
0
import pygame

game_display = pygame.display.set_mode((1024, 768))
pygame.display.set_caption('Nice Window')
pygame.display.flip()

from state import State
from menu import Menu
from init import Init
from game import Game
from mouselistener import MouseListener
from keylistener import KeyListener

current_state = Init()

clock = pygame.time.Clock()

running = True


def change_state(new_state):
    global current_state

    if new_state != State.program_states.STATE_NULL:
        if new_state == State.program_states.STATE_MENU.value:
            current_state = Menu()

        if new_state == State.program_states.STATE_GAME.value:
            current_state = Game()
            current_state.set_display(game_display)
            current_state.create_game_world()
Ejemplo n.º 19
0
    """Main function"""
    try:
        prog = Program()
    except:
        print('Run the main.py file with "-i" or "--init" at first.')
        exit(1)

    run = True
    while run:
        prog.consult_substitutes()
        prog.show_category()
        prog.show_product()
        prog.show_substitute()

        run = prog.continu()


ARG = None

try:
    INIT_DB = Init()
    ARG = INIT_DB.arg()
except AttributeError:
    pass

if __name__ == "__main__":
    if ARG is True:
        ARG
    else:
        main()