def setup(self): super(TestBuilder, self).setup() import builder from builder.builder import Builder entitynames = Builder._get_entity_names() terrain_names = [str(t) for t in Builder._get_terrain_names()] self.entity_class1 = new_entity_class(entitynames[0], terrain_names) self.entity_class2 = new_entity_class(entitynames[1], terrain_names)
def compute(self): q = Quantizator() m = Maskerator() c = Cropper() b = Builder() # load the image and resize it to a smaller factor so that # the shapes can be approximated better image = cv2.imread('./temp/image.jpg') # resize image resized = cv2.resize(image, (960, 1280), interpolation=cv2.INTER_AREA) cv2.imwrite('./temp/original.jpg', resized) q.quantize(32) m.mask() assemblyInstructions = c.crop() b.build(assemblyInstructions) with open('./json/data.json', 'r') as f: return f.read()
def build(*args, **kwargs): """ Command that performs thet gets a GIT repository, compiles some files and pushes them to another repository If build is not OK it send an email with the changelog and the error :param args: :param kwargs: build command arguments :return: """ result = 0 with open(kwargs['config']) as f: config = json.load(f) print('This is your current config:\n{}'.format( pprint.pformat(config, indent=2, width=120))) if bool_input('Do you want to continue?'): last_execution = datetime.datetime.strptime(config["last_execution"], "%Y-%m-%d %H:%M:%S.%f") \ if config["last_execution"] else datetime.datetime(1900, 1, 1) email = Email( config["email"]["smtp_server"], config["email"]["smtp_port"], config["email"]["username"], config["email"]["password"], ) origin_repo = GitRepository(config["git_origin"]["repo_path"], config["git_origin"]["git_repo"]) target_repo = GitRepository( config["git_target"]["target_path"], config["git_target"]["git_target"].format( config["git_origin"]["git_user"], config["git_origin"]["git_pass"])) builder = Builder(origin=origin_repo, target=target_repo, email=email) build_ok = builder.build(config["git_origin"]["build_file"]) if build_ok: builder.push_binary(config["git_target"]["files"]) config["last_execution"] = str(datetime.datetime.now()) with open(kwargs['config'], "w") as f: json.dump(config, f) print("Success") else: builder.send_email_error(last_execution, config["email"]["email_from"], config["email"]["email_to"], config["email"]["subject"]) result = 0 if build_ok else -1 return result
def test_get_entity_names(self): """ TestBuilder Récupérer les noms des entités""" b = Builder() for entityName in b._get_entity_names(): path = os.path.join(Globals.user_abs_entity_path(entityName), "attributes.json") assert os.path.exists(path) assert Builder._get_entity_names()[0] == "Moustique", \ "Builder._get_entity_names()[0] = {}".format(Builder._get_entity_names()[0]) assert Builder._get_entity_names()[1] == "Humain", \ "Builder._get_entity_names()[1] = {}".format(Builder._get_entity_names()[1])
def build(rules_file): # read file with rules #rules = open(os.path.join(script_dir, rules_file), "r").readlines() global rules tokens = rules.parseFile(os.path.join(script_dir, rules_file)) print "#" * 25 print "# aply rules from file '%s'" % rules_file print "#" * 25 for tok in tokens: apply_rule(tok) # building scg files with base sources #print "Adding gwf files to test segment" #print defines.PATH_REPO_SRC #scg_build.generate_scg(os.path.join(defines.PATH_REPO_SRC, test_seg_uri + ".scg"), # os.path.join(defines.PATH_REPO_SRC, test_gwf_dir)) # building repository from builder.builder import Builder builder = Builder() builder.run()
def __init__(self, actions, status, xmsgs): super (ProjectView, self).__init__() self.actions = actions self.status = status self.xmsgs = xmsgs self.tab_view = QTabWidget() self.tab_view.setTabPosition(QTabWidget.South) self.tab_view.setTabShape(QTabWidget.Triangular) self.tab_view.setTabsClosable(False) layout = QVBoxLayout() layout.addWidget(self.tab_view) self.setLayout(layout) self.designer = Designer(actions, status) self.builder = Builder(actions, status, xmsgs) self.configuration = Configuration(actions, status) self.constraints = Constraints(actions, status) self.add_tab("designer", self.designer) self.add_tab("configuration", self.configuration) self.add_tab("constraints", self.constraints) self.add_tab("builder", self.builder) self.controller = None self.builder.set_project_status("Loaded default project")
# s'il n'y pas de simulations existantes if not os.path.exists(Globals.user_abs_path()): shutil.copytree(Globals.default_user_dir, Globals.user_root) # Initialisation de l'environnement graphique. application = QApplication(sys.argv) # Démarrage de la console console = Console("Launch console") console.show() console.push(Messages.main_001) exceptionOccurred = False try: # Préparation du user_data (fichier __init__.py) Builder.config_start() build_workspace() # Chargement des configurations params = Builder.get_params() console.push(Messages.main_002) console.push(Messages.main_003) except Exception as e: console.push_error("Error building simulation {}".format(Globals._simulation_name)) # Affichage de la trace en console, de l'erreur dans le LOG. exc_type, exc_value, exc_traceback = sys.exc_info() print exc_type.__name__.center(90, '-') print traceback.format_exc().splitlines()[-1] print "".ljust(90, '.') traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)
def deploy(): b = Builder() b.build() u = SFTPUploader() u.upload()
def build(): b = Builder() b.build()
class ProjectView(QWidget): def __init__(self, actions, status, xmsgs): super (ProjectView, self).__init__() self.actions = actions self.status = status self.xmsgs = xmsgs self.tab_view = QTabWidget() self.tab_view.setTabPosition(QTabWidget.South) self.tab_view.setTabShape(QTabWidget.Triangular) self.tab_view.setTabsClosable(False) layout = QVBoxLayout() layout.addWidget(self.tab_view) self.setLayout(layout) self.designer = Designer(actions, status) self.builder = Builder(actions, status, xmsgs) self.configuration = Configuration(actions, status) self.constraints = Constraints(actions, status) self.add_tab("designer", self.designer) self.add_tab("configuration", self.configuration) self.add_tab("constraints", self.constraints) self.add_tab("builder", self.builder) self.controller = None self.builder.set_project_status("Loaded default project") def set_controller(self, controller): self.designer.set_controller(controller) self.constraints.set_controller(controller) self.builder.set_controller(controller) self.controller = controller self.actions.update_view.emit() #controller.initialize_constraint_editor(self.constraints) def get_controller(self): return self.controller def update_view(self): self.actions.update_view.emit() def get_desigenr_scene(self): return self.designer.get_scene() def get_constraint_editor(self): return self.constraints def get_view_names(self): return VIEWS def add_tab(self, name, view): color = CONFIG_DICT[str(name)] pm = QPixmap(QSize(16, 16)) pm.fill(color) icon = QIcon(pm) self.tab_view.addTab(view, icon, name) def get_designer_scene(self): return self.designer.get_scene() def get_color(self, name): return CONFIG_DICT[str(name)] def get_configuration_editor(self): return self.configuration
def test_net_builder(self): builder=Builder() builder.net_builde() builder.instance_build() for instance in builder.instances: print instance.name
def test_get_terrain_names(self): """ Récupérer les noms des entités""" b = Builder() terrains = [str(s) for s in b._get_terrain_names()] assert "Montagne" in terrains assert "Zone_Risque" in terrains