def Main(): """The main program function. Returns: bool: True if successful or False if not. """ l2tdevtools_path = os.path.abspath(__file__) l2tdevtools_path = os.path.dirname(l2tdevtools_path) l2tdevtools_path = os.path.dirname(l2tdevtools_path) project_path = os.getcwd() projects_helper = project.ProjectHelper(project_path) project_file = '{0:s}.ini'.format(projects_helper.project_name) project_reader = project_config.ProjectDefinitionReader() with open(project_file, 'rb') as file_object: project_definition = project_reader.Read(file_object) helper = dependencies.DependencyHelper() for writer_class in ( appveyor_yml.AppveyorYmlWriter, pylint_rc.PylintRcWriter, travis.TravisRunWithTimeoutScriptWriter, requirements_txt.RequirementsWriter, setup.SetupCfgWriter, setup.SetupPyWriter, tox_ini.ToxIniWriter, travis.TravisInstallScriptWriter, travis.TravisRunTestsScriptWriter, travis.TravisRunWithTimeoutScriptWriter, travis_yml.TravisYMLWriter): writer = writer_class(l2tdevtools_path, project_definition, helper) writer.Write() for writer_class in ( dependencies_py.DependenciesPyWriter, dpkg.DPKGControlWriter, gift_copr.GIFTCOPRInstallScriptWriter, gift_ppa.GIFTPPAInstallScriptWriter, macos.MacOSInstallScriptWriter, macos.MacOSMakeDistScriptWriter, macos.MacOSUninstallScriptWriter): if not os.path.exists(writer_class.PATH): continue writer = writer_class(l2tdevtools_path, project_definition, helper) writer.Write() path = os.path.join(l2tdevtools_path, 'l2tdevtools', 'dependencies.py') file_data = [] with open(path, 'rb') as file_object: for line in file_object.readlines(): if 'GetDPKGDepends' in line: break file_data.append(line) file_data.pop() file_data = ''.join(file_data) path = os.path.join('utils', 'dependencies.py') with open(path, 'wb') as file_object: file_object.write(file_data) return True
def InitializeHelpers(self): """Initializes the helpers. Returns: bool: True if the helper initialization was successful. """ project_path = os.path.abspath(self._project_path) self._project_helper = project.ProjectHelper(project_path) self._project_name = self._project_helper.project_name if not self._project_name: print('{0:s} aborted - unable to determine project name.'.format( self._command.title())) # yapf: disable return False if self._project_name in ('artifacts', 'artifacts-kb'): github_organization = 'ForensicArtifacts' elif self._project_name in ( 'dtfabric', 'dtformats', 'esedb-kb', 'winevt-kb', 'winreg-kb'): github_organization = 'libyal' else: github_organization = 'log2timeline' self._git_repo_url = b'https://github.com/{0:s}/{1:s}.git'.format( github_organization, self._project_name) self._git_helper = git.GitHelper(self._git_repo_url) self._github_helper = github.GitHubHelper( github_organization, self._project_name) return True
def testInitialize(self): """Tests the __init__ function.""" l2tdevtools_path = '/fake/l2tdevtools/' project_definition = project.ProjectHelper(l2tdevtools_path) configuration_file = self._GetTestFilePath(['dependencies.ini']) dependency_helper = dependencies.DependencyHelper( configuration_file=configuration_file) writer = jenkins_scripts.RunPython3EndToEndTestsScriptWriter( l2tdevtools_path, project_definition, dependency_helper, None) self.assertIsNotNone(writer)
def testInitialize(self): """Tests that the writer can be initialized.""" l2tdevtools_path = '/fake/l2tdevtools/' project_definition = project.ProjectHelper(l2tdevtools_path) configuration_file = self._GetTestFilePath(['dependencies.ini']) dependency_helper = dependencies.DependencyHelper( configuration_file=configuration_file) writer = dpkg.DPKGControlWriter(l2tdevtools_path, project_definition, dependency_helper, None) self.assertIsNotNone(writer)
def testInitialize(self): """Tests that the writer can be initialized.""" l2tdevtools_path = '/fake/l2tdevtools/' project_definition = project.ProjectHelper(l2tdevtools_path) configuration_file = self._GetTestFilePath(['dependencies.ini']) dependency_helper = dependencies.DependencyHelper( configuration_file=configuration_file) writer = gift_ppa.GIFTPPAInstallScriptWriter( l2tdevtools_path, project_definition, dependency_helper) self.assertIsNotNone(writer)
def InitializeHelpers(self): """Initializes the helpers. Returns: bool: True if the helper initialization was successful. """ project_path = os.path.abspath(self._project_path) self._project_helper = project.ProjectHelper(project_path) self._project_name = self._project_helper.project_name if not self._project_name: print('{0:s} aborted - unable to determine project name.'.format( self._command.title())) # yapf: disable return False project_definition = self._project_helper.ReadDefinitionFile() self._github_organization = None if project_definition.homepage_url.startswith('https://github.com/'): self._github_organization = project_definition.homepage_url[ len('https://github.com/'):] self._github_organization, _, _ = self._github_organization.partition( '/') if not self._github_organization: print('{0:s} aborted - unable to determine GitHub organization.'. format(self._command.title())) return False self._git_repo_url = 'https://github.com/{0:s}/{1:s}.git'.format( self._github_organization, self._project_name) self._git_helper = git.GitHelper(self._git_repo_url) self._github_helper = github.GitHubHelper(self._github_organization, self._project_name) return True
def testInitialize(self): """Tests that the helper can be initialized.""" helper = project.ProjectHelper('/home/plaso/l2tdevtools/review.py') self.assertIsNotNone(helper)
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ l2tdevtools_path = os.path.abspath(__file__) l2tdevtools_path = os.path.dirname(l2tdevtools_path) l2tdevtools_path = os.path.dirname(l2tdevtools_path) project_path = os.getcwd() projects_helper = project.ProjectHelper(project_path) project_definition = projects_helper.ReadDefinitionFile() dependencies_helper = dependencies.DependencyHelper() test_dependencies_helper = None if os.path.exists('test_dependencies.ini'): test_dependencies_helper = dependencies.DependencyHelper( 'test_dependencies.ini') for writer_class in (pylint_rc.PylintRcWriter, travis.TravisRunWithTimeoutScriptWriter, requirements.RequirementsWriter, requirements.TestRequirementsWriter, setup.SetupCfgWriter, setup.SetupPyWriter, travis.TravisInstallScriptWriter, travis.TravisRunPylintScriptWriter, travis.TravisRunPython3ScriptWriter, travis.TravisRunTestsScriptWriter, travis.TravisRunWithTimeoutScriptWriter, travis_yml.TravisYMLWriter): writer = writer_class(l2tdevtools_path, project_definition, dependencies_helper, test_dependencies_helper) writer.Write() for writer_class in (appveyor_yml.AppveyorYmlWriter, check_dependencies.CheckDependenciesWriter, dependencies_py.DependenciesPyWriter, dpkg.DPKGCompatWriter, dpkg.DPKGControlWriter, dpkg.DPKGRulesWriter, gift_copr.GIFTCOPRInstallScriptWriter, gift_ppa.GIFTPPAInstallScriptPY3Writer, jenkins_scripts.LinuxRunEndToEndTestsScriptWriter, jenkins_scripts.RunPython3EndToEndTestsScriptWriter, linux_scripts.UbuntuInstallationScriptWriter, macos.MacOSInstallScriptWriter, macos.MacOSMakeDistScriptWriter, macos.MacOSUninstallScriptWriter, tox_ini.ToxIniWriter): if not os.path.exists(writer_class.PATH): continue writer = writer_class(l2tdevtools_path, project_definition, dependencies_helper, test_dependencies_helper) writer.Write() output_path = os.path.join('utils', 'dependencies.py') if os.path.exists(output_path): input_path = os.path.join(l2tdevtools_path, 'l2tdevtools', 'dependencies.py') file_data = [] with io.open(input_path, 'r', encoding='utf-8') as file_object: for line in file_object.readlines(): if 'GetDPKGDepends' in line: break file_data.append(line) file_data.pop() file_data = ''.join(file_data) with io.open(output_path, 'w', encoding='utf-8') as file_object: file_object.write(file_data) # Remove old scripts. script_path = os.path.join('config', 'linux', 'gift_ppa_install.sh') if os.path.isfile(script_path): os.remove(script_path) script_path = os.path.join('config', 'travis', 'run_coverage.sh') if os.path.isfile(script_path): os.remove(script_path) return True