def get_variable(identifier, platform, name, varname): filepath = os.path.join(workspace_path, identifier, platform, name) conf = FileConfigLoader(filepath).dictionary res = [x for x in conf["Variables"] if x["name"] == varname][0] return Response(response=json.dumps(res), status=200, mimetype="application/json")
def save_variable(identifier, platform, name, varname): filepath = os.path.join(workspace_path, identifier, platform, name) config_loader = FileConfigLoader(filepath) conf = config_loader.dictionary res = [x for x in conf["Variables"] if x["name"] == varname][0] res["value"] = request.data config_loader.save_config(conf) return True
def __testLocal__(): workingDir = os.path.dirname(os.path.abspath(__file__)) config_loader = FileConfigLoader("../test_data/build_configuration.json") config = config_loader.load_config() executor = CommandExecutor(config["Resources"], basePath=workingDir, verbose=True) builder = AppConfigurator(config_loader, executor) builder.apply()
def on_show_config_clicked(self): if self.working_dir: self.config = FileConfigLoader( self.get_config_path()).load_config() self.cfg = ConfigWindow(self) self.cfg.set_configuration(self.get_config_path(), self.working_dir) self.cfg.cw.set_save_path(self.get_config_path()) self.cfg.show()
def set_configuration(self, config_path, working_dir=None): self.config_path = config_path if working_dir: self.working_dir = working_dir else: self.working_dir = app_config.get_working_dir() self.loader = FileConfigLoader(self.config_path) self.configuration = self.loader.load_config() self.bindUi()
def on_platform_changed(self): ind = self.cmb_platforms.currentIndex() if ind > 0: self.working_dir = solution_dir.replace( '{PlatformType}', solution_for_platform[self.cmb_platforms.currentText()]) self.config = FileConfigLoader( self.get_config_path()).load_config() else: self.working_dir = None
def get_config(identifier, platform, name): filepath = os.path.join(workspace_path, identifier, platform, name) conf = FileConfigLoader(filepath).dictionary admin = request.args.get('admin') result = conf['Variables'] if bool(admin): result = conf return Response(response=json.dumps(result), status=200, mimetype="application/json")
def on_configure_clicked(self): config_loader = FileConfigLoader(self.get_config_path()) builder = AppConfigurator(config_loader, ZmqChainedLoger(port), verbose=self.cb_verbose.isChecked(), debug_mode=self.cb_verbose.isChecked()) builder.set_execution_dir(self.working_dir) self.worker = ConfigRunnerThread(builder) self.set_message_receiver() self.worker.start() self.worker.finished.connect(self.on_worker_finished)
def save_config(identifier, platform, name): print "saved" filepath = os.path.join(workspace_path, identifier, platform, name) config_loader = FileConfigLoader(filepath) try: newconf = json.loads(request.data) config_loader.save_config(newconf) print 'all fine' return Response(response="True", status=200) except Exception, ex: # @UnusedVariable print ex.message return Response(response="False", status=200)
def get_resource(identifier, platform, name, resid): filepath = os.path.join(workspace_path, identifier, platform, name) conf = FileConfigLoader(filepath).dictionary res = [x for x in conf["Resources"] if x["rid"] == resid][0] file_path = os.path.join(workspace_path, identifier, platform, res['url']) print file_path if os.path.exists(file_path): print 'resource exists:' + file_path return send_file(file_path, mimetype='image/png') else: print 'non existent' print 'resource not available at:' + file_path return Response(status=404)
def run(self): is_valid, errors = self.validate_args() res = None if is_valid: res = self.value_substitutor.substitute(self.ConfigPath) else: raise InvalidCommandArgumentsError(str(errors)) if not os.path.isabs(res): config_loader = self.executor.parent.config_loader dr = os.path.dirname(config_loader.config_file) res = os.path.join(dr, res) loader = FileConfigLoader(res) config = loader.load_config() builder = self.executor.parent bundles_filter = ConfigBuildFilter() builder.apply_parametrized(config, bundles_filter=bundles_filter)
def job_start(identifier, platform, name): Workspace.set(workspace_path) filepath = os.path.join(workspace_path, identifier, platform, name) loader = FileConfigLoader(filepath) config = loader.dictionary c_loger = ConsoleLoger() s_loger = StringLoger() composite_log = CompositeLoger(*[c_loger, s_loger]) builder = AppConfigurator(loader, composite_log) job_output = "No Response" try: job_output = execute_job.delay(builder, workspace_path, workspace_path).get(100) except OSError, e: job_output = e.strerror job_output += '\nTraceback' + job_output.traceback
def get_config_loader(args): if args[1] == '-from': ldr = None if args[2] == 'fs': ldr = FileConfigLoader(args[3]) elif args[2] == 'svc': ldr = SvcConfigLoader(svcUrl, args[3]) return ldr else: print ''' 1. automator -from svc [configuration_id] -o [destinationDir] 2. automator -from fs [configuration_path] -o [destinationDir] ''' raise Exception( """Console mode requires a ConfigLoader to be specified:+) 1. automator -from svc [configuration_id] -o [destinationDir] 2. automator -from fs [configuration_path] -o [destinationDir] """)
def run_config(identifier, platform, name): Workspace.set(workspace_path) filepath = os.path.join(workspace_path, identifier, platform, name) loader = FileConfigLoader(filepath) config = loader.dictionary c_loger = ConsoleLoger() s_loger = StringLoger() composite_log = CompositeLoger(*[c_loger, s_loger]) builder = AppConfigurator(loader, composite_log) working_dir = request.args.get('wd') if working_dir: builder.set_execution_dir(working_dir) else: builder.set_execution_dir(workspace_path) res_msg = '' try: builder.apply() except Exception, ex: res_msg += ex.message + '\n'
def save_resource(identifier, platform, name, resid): filepath = os.path.join(workspace_path, identifier, platform, name) conf = FileConfigLoader(filepath) res = [x for x in conf["Resources"] if x["rid"] == resid][0] # data_file = request.files.get('data_file') files = request.files.getlist('files[]') file_path = os.path.join(workspace_path, identifier, platform, res['url']) files[0].save(file_path) print "File Path: %s" % file_path # shutil.copy(data_file, file) # save_file(data_file, file_name) # file_size = get_file_size(file_name) # file_url = url_for('download', file_name=file_name) # providing the thumbnail url is optional # thumbnail_url = url_for('thumbnail', file_name=file_name) return jsonify(name='test', size=100000, url='/config/%s/%s/%s' % (identifier, platform, res['url']), thumbnail='/config/%s/%s/%s' % (identifier, platform, res['url']))
def on_run_click(self): root_url = os.path.dirname(self.config_path) if os.name != 'posix': root_url = '/' + root_url if self.build_output: self.build_output.close() self.build_output = ConsoleOutput() self.build_output.show() config_loader = FileConfigLoader(self.config_path) builder = AppConfigurator(config_loader, ZmqChainedLoger(1234), verbose=self.verbose) builder.set_execution_dir(self.working_dir) builder.include_bundles(self.get_included_bundles()) self.set_message_receiver() if self.debug: builder.apply() else: self.worker = ConfigRunnerThread(builder) self.worker.start() self.worker.finished.connect(self.on_worker_finished)
def open_clicked(self): fname, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open file', '~') config = FileConfigLoader(fname).load_config() self.cf = ConfigWindow(config) self.cf.show()