def add_header_section( report: reporting.Report, settings: dict, activity_phases: limb.Property ): """ :param report: :param settings: :param activity_phases: :return: """ activity_phases = activity_phases.values() support_phases = settings['support_phases'] activity_phases = ['{}%'.format(round(100 * x)) for x in activity_phases] support_phases = ['{}%'.format(round(100 * x)) for x in support_phases] report.add_template( paths.resource('trial', 'header.html'), title=settings.get('name'), summary=settings.get('summary'), duty_cycle=round(100.0 * settings['duty_cycle']), activity_phases=activity_phases, support_phases=support_phases, date=datetime.utcnow().strftime("%m-%d-%Y %H:%M") )
def execute_command(): source = paths.resource('tracksim.global.sh') with open(source, 'r+') as f: contents = f.read() path = paths.project('bin', 'tracksim') contents = contents.replace('###TRACKSIM_PATH###', path) path = '/usr/local/bin/tracksim' with open(path, 'w+') as f: f.write(contents) os.chmod( path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH ) register_global_var() system.log(""" [SUCCESS]: The tracksim command has been registered for global use. You can now call tracksim globally from a terminal. If you have trouble calling tracksim, make sure you have exported /usr/local/bin in your .bash_profile PATH. """)
def test_resource_path(self): """ Tests making project paths """ # Without arguments resources_root_path = os.path.abspath(os.path.join( MY_DIRECTORY, '..', '..', 'resources' )) self.assertEqual(resources_root_path, paths.resource())
def __init__(self, report_type:str, identifier: str = None, **kwargs): self.env = Environment( loader=FileSystemLoader(paths.resource('reports')) ) self.id = identifier self.type = report_type self.body = [] self.data = kwargs.get('data', {}) self.files = dict()
def add_info(report: reporting.Report, settings: dict, coupling_data: dict): """ Adds the info section to the report, which is an existing html template that is pre-populated with data by rendering it with Jinja2 :param report: The report being created :param settings: Configuration settings for the trial simulation :param coupling_data: Coupling analysis data :return: """ bounds = coupling_data['bounds'] bounds = [mstats.value.round_significant(b, 4) for b in bounds] report.add_template( paths.resource('trial', 'info.html'), coupling_length=coupling_data['value'].html_label, coupling_bounds=bounds )
def deploy_directory(**kwargs): template_path = paths.resource("template") target_path = os.path.join(kwargs["root_path"], kwargs["trackway_name"], kwargs["scenario_name"]) if os.path.exists(target_path): raise FileExistsError("Scenario already exists") trackway_path = os.path.dirname(target_path) # create the scenario folder if not os.path.exists(trackway_path): os.makedirs(trackway_path) # copy the template version for each of the default trials shutil.copytree(template_path, target_path) # get group.json file and set it up. print("path = {}".format(target_path)) group_path = os.path.join(target_path, "group.json") print("group_path is [{}]".format(group_path)) if not os.path.exists(group_path): raise FileNotFoundError("group.json file not found") with open(group_path, mode="r+") as f: d = json.load(f) # set up the group's name key d["name"] = "{}_{}".format(kwargs["trackway_name"], kwargs["scenario_name"]) # save the group.json file with 2-space indents with open(group_path, mode="w+") as f: json.dump(d, f, indent=2, sort_keys=True) return target_path
def add_header_section( report: reporting.Report, settings: dict, trials: typing.List[dict] ): trial_data = [] for t in trials: color = plotting.get_color(t['index'] - 1, as_string=True) trial_data.append(dict( index=t['index'], id=t['id'], name=t['settings']['name'], summary=t['settings'].get('summary', ''), back_color=color )) report.add_template( path=paths.resource('group', 'header.html'), title=settings['name'], date=datetime.utcnow().strftime("%m-%d-%Y %H:%M"), summary=settings.get('summary'), trials=trial_data )