示例#1
0
def main(input_args: List[str]) -> int:
    parser = ArgumentParser(
        description=
        "Regenerate the python wrapper library around the nuget xml schema.")
    parser.add_argument(
        "--output-path",
        help=("Full path to the output file. "
              "Intermediate directories are created as needed."),
        required=True,
    )
    parser.add_argument(
        "--generateds-binary",
        help=
        "Path to generateDS. If not specified, defaults to looking in $env:PATH",
        default=None,
    )
    args = parser.parse_args(input_args)

    if args.generateds_binary is None:
        args.generateds_binary = find_binary("generateDS")

    if args.generateds_binary is None:
        print(
            "ERROR: Unable to locate generateDS! Try passing --generateds-binary."
        )
        return 1

    # Create any directories as needed.
    output_dir = os.path.abspath(os.path.dirname(args.output_path))
    print(f"Generated output is being written to: {output_dir}")
    os.makedirs(output_dir, exist_ok=True)

    return run_generateds(args.generateds_binary, args.output_path,
                          get_schema_source(SCHEMA_SOURCE_URL))
示例#2
0
    def setUp(self):
        self.maxDiff = 100000
        self.test_dir: tempfile.TemporaryDirectory = tempfile.TemporaryDirectory()
        self.common_nuspec_vars: VarDict = {
            "id": "a-package",
            "version": "1.4.4",
            "title": "A package",
            "authors": "package people",
            "description": "Yeah",
        }
        self.common_processor_vars: VarDict = {
            "RECIPE_CACHE_DIR": self.test_dir.name,  # Don't write to real recipe cache.
            "KEEP_BUILD_DIRECTORY": True,  # `self.test_dir` destruction cleans all.
            "chocoexe_path": find_binary("choco"),
        }
        self.installation_file: str = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "..", "autopkg")
        )
        self.good_chocolatey_file_vars: VarDict = {
            "installer_path": self.installation_file,
            "installer_checksum": "781FBCCE29C1BA769055E3D012A69562",
            "installer_checksum_type": "md5",
            "installer_type": "exe",  # a lie, but it's not going to matter
            "output_directory": self.test_dir.name,
        }

        self.good_file_vars: VarDict = {
            **self.common_processor_vars,
            **self.common_nuspec_vars,
            **self.good_chocolatey_file_vars,
        }
示例#3
0
    def test_find_binary_posixy(self, mock_ospath, mock_getpath, mock_isexe,
                                mock_sys):
        # Forcibly use posixpath regardless of platform to test "linux/mac" anywhere.
        import posixpath

        mock_ospath.join = posixpath.join
        mock_sys.platform = "Darwin"
        mock_getpath.return_value = ["/usr/bin", "/usr/local/bin"]
        mock_isexe.side_effect = [True, False]
        result = autopkglib.find_binary("curl")
        self.assertEqual(result, "/usr/bin/curl")
示例#4
0
    def test_find_binary_windows(self, mock_ospath, mock_getpath, mock_isexe,
                                 mock_sys):
        # Forcibly use ntpath regardless of platform to test "windows" anywhere.
        import ntpath

        mock_ospath.join = ntpath.join
        mock_sys.platform = "Win32"
        mock_getpath.return_value = [r"C:\Windows\system32", r"C:\CurlInstall"]
        mock_isexe.side_effect = [False, True]
        result = autopkglib.find_binary("curl")
        self.assertEqual(result, r"C:\CurlInstall\curl.exe")
示例#5
0
    def curl_binary(self):
        """Return a path to a curl binary, priority in the order below.
        Return None if none found.
        1. env['CURL_PATH']
        2. app pref 'CURL_PATH'
        3. a 'curl' binary that can be found in the PATH environment variable
        4. '/usr/bin/curl' (POSIX-y platforms only)
        """

        curlbin = find_binary("curl", self.env)
        if curlbin is not None:
            return curlbin

        raise ProcessorError("Unable to locate or execute any curl binary")