def upload_content(connection, repolist, path): ''' upload content to a custom repository ''' # Check whether "path" is a file or a directory. # If it is a directory, get a list of *.rpm files in it. path_type = Util.get_file_type(connection, path) if path_type == "regular file": content = [basename(path)] elif path_type == "directory": content = Util.get_rpms_in_dir(connection, path) else: # This should not happen. Getting here means that "path" is neither a file # nor a directory. # Anyway, going on with no content, # leaving it up to proceed_with_check() to handle this situation. content = [] # Continue in rhui-manager. RHUIManager.screen(connection, "repo") Expect.enter(connection, "u") RHUIManager.select(connection, repolist) Expect.expect(connection, "will be uploaded:") Expect.enter(connection, path) RHUIManager.proceed_with_check(connection, "The following RPMs will be uploaded:", content) RHUIManager.quit(connection, timeout=60)
def packages_upload(connection, repo_id, path): ''' upload a package or a directory with packages to the custom repo ''' cmd = "rhui-manager packages upload --repo_id %s --packages %s" % ( repo_id, path) _, stdout, _ = connection.exec_command(cmd) output = stdout.read().decode().splitlines() successfully_uploaded_packages = [line.split()[0] for line in output \ if line.endswith("successfully uploaded")] if not successfully_uploaded_packages: raise RuntimeError("\n".join(output) or "no output from '%s'" % cmd) successfully_uploaded_packages.sort() path_type = Util.get_file_type(connection, path) if path_type == "regular file": expected_packages = [path] elif path_type == "directory": expected_packages = [ join(path, rpm) for rpm in Util.get_rpms_in_dir(connection, path) ] else: expected_packages = [] nose.tools.eq_(successfully_uploaded_packages, expected_packages)