def install_uca_ufo(path: str, verbose: bool = True) -> dict: """ Installs the uca-ufo repository into the given *path*. Returns a dict which contains some information about the installation process. The returned dict contains the following items: - success: boolean value of whether or not the installation succeeded - path: the string path of the file - git: the string URL of the git repository from which it was installed :param path: The string path of the folder into which to install this dependency :param verbose: Whether or not to produce verbose output. DEPRECATED: Uses config field to determine verbosity :return: A dict, which contains information about the installation process. """ git_url = CONFIG['install']['ucaufo_git'] folder_path = install_generic_cmake( path, git_url, CONFIG.verbose(), { 'CMAKE_INSTALL_PREFIX': '/usr', 'CMOSIS_SENSOR_WIDTH': CONFIG.get_sensor_width(), 'CMOSIS_SENSOR_HEIGHT': CONFIG.get_sensor_height() }) # Declare as successful if the folder exists and is not empty success = os.path.exists(folder_path) and bool(os.listdir(folder_path)) return {'success': success, 'path': folder_path, 'git': git_url}
def install_pcitools(path: str, verbose: bool = True) -> dict: """ Installs the "pcitool" repository into the given *path*. Returns a dict which contains information about the installation process. The returned dict contains the following items: - success: boolean value of whether or not the installation succeeded - path: the string path of the file - git: the string URL of the git repository from which it was installed :param path: The string path of the folder into which to install this dependency :param verbose: Whether or not to produce verbose output. DEPRECATED: Uses config field to determine verbosity :return: A dict, which contains information about the installation process. """ git_url = CONFIG['install']['pcitools_git'] folder_path = install_generic_cmake(path, git_url, CONFIG.verbose(), {'CMAKE_INSTALL_PREFIX': '/usr'}) # Also installing the driver! driver_path = os.path.join(folder_path, 'driver') output = None if verbose else subprocess.DEVNULL build_command = 'mkdir build; cd build; cmake -DCMAKE_INSTALL_PREFIX=/usr ..' exit_code = execute_command(build_command, CONFIG.verbose(), cwd=driver_path) if not exit_code: click.secho('Built "pcilib driver" sources', fg='green') install_command = 'cd build; sudo make install' exit_code = execute_command(install_command, CONFIG.verbose(), cwd=driver_path) if not exit_code: click.secho('Installed "pcilib driver" successfully!', bold=True, fg='green') # Activating the driver after it has been installed... activate_driver_command = 'sudo depmod -a' exit_code = execute_command(activate_driver_command, CONFIG.verbose()) if not exit_code: click.secho('Activated driver!', bold=True, fg='green') return {'success': (not exit_code), 'path': folder_path, 'git': git_url}
def decode_frame(data_path: str) -> str: """Decodes the frame data given at *data_path* and returns the path to the .raw image file This function can only be called, after the actual frame data has been received from the camera. The file with the raw data has to already exist. This function is based on one of Michele's scripts called "frame.sh" :param data_path: The string path of the file which contains the raw frame data. :raises FrameDecodingError: When the decode command fails. The error message contains some part of the commands output. :returns: The string path to the decoded .raw image file """ frame_path = f'{data_path}.raw' if CONFIG.verbose(): cprint('Decoding the image, with the following settings:') cparams({ 'camera sensor width': CONFIG.get_sensor_width(), 'camera sensor height': CONFIG.get_sensor_height(), 'input data path': data_path, 'output frame path': frame_path }) decode_command = 'ipedec -r {height} --num-columns {width} {path} {verbose}'.format( height=CONFIG.get_sensor_height(), width=CONFIG.get_sensor_width(), path=data_path, verbose='-v' if CONFIG.verbose() else '' ) exit_code, stdout = run_command(decode_command) if exit_code: raise FrameDecodingError(stdout[:stdout.find('\n')]) return frame_path
def file_url(self): """ Previously this property was just a instance variable, but this would cause problems if the configuration in regards to the url changes during the lifetime of this object that would cause a wrong url to be returned. """ return CONFIG.url(self.url_base_clean, self.file_name)