Python과 Gemini를 사용하여 데비안 패키지 업데이트 요약 자동화(gemini--flash)
Debian과 유사한 배포판을 사용하고 있고 새로운 사용자이거나 시스템 관리자로 경력을 시작했다면 아마도 패키지 업데이트의 중요성을 이미 알고 계실 것입니다. 적절한 업데이트를 사용합니다. Linux에 대해 자세히 알아보려면 각 패키지의 기능을 이해하고 싶을 수도 있습니다. 또한 시스템 관리자(시스템 관리자)는 긴급하거나 보안과 관련된 업데이트가 무엇인지 이해관계자에게 전달하거나 문서화해야 하는 경우가 많습니다.
이 게시물에서는 Python, apt list -u 명령 및 Gemini AI를 결합하여 사람이 읽을 수 있는 보류 중인 패키지 업데이트 요약을 생성하는 방법을 보여 드리겠습니다.
목표?
- apt list -u 명령을 사용하여 Debian에서 보류 중인 업데이트 목록을 검색합니다. 참고: 원하는 경우 다음과 같은 방법을 사용하여 출력을 수정할 수 있습니다.
apt list -u | awk '{ print }' | sed 's|/.*||'
- 이 목록을 Gemini AI로 보냅니다(Google 생성 라이브러리 사용).
- AI를 사용해 각 패키지 업데이트의 중요성을 분류하고 요약합니다.
- 쉽게 공유할 수 있도록 결과를 Markdown 파일에 저장하세요.
요구사항?
- 파이썬 3.8
- Google Gemini API 키
- 필수 라이브러리:pip install google-generativeai Environs
- Debian 기반 시스템: 이 스크립트는 apt 명령을 사용합니다.
코드
다음은 두 스크립트에 대한 솔루션 분석입니다.
apt_list.py
이 스크립트는 apt list -u를 실행하여 보류 중인 업데이트를 가져오고, 출력을 처리하고, 프롬프트 기능을 사용하여 Gemini AI에서 분류된 요약을 가져옵니다.
import subprocess from utils.gemini_cfg import prompt try: # Run 'apt list -u' to list upgradable packages result = subprocess.run(["apt", "list", "-u"], capture_output=True, text=True, check=True) output = result.stdout # Get command output # Use the Gemini AI model to summarize the updates summary = prompt(output) # Save the AI-generated summary to a Markdown file with open("./gemini_result.md", "w") as file: file.write(summary) print("Summary saved to gemini_result.md") except subprocess.CalledProcessError as e: print("Error while running apt list:", e)
gemini_cfg.py
이 스크립트는 Gemini API를 구성하고 AI 생성 콘텐츠에 대한 프롬프트 기능을 정의합니다.
import google.generativeai as genai from environs import Env # Load API key from .env file env = Env() env.read_env() key = env("TOKEN") # Replace with your environment variable key name # Configure Gemini API genai.configure(api_key=key) model = genai.GenerativeModel("gemini-1.5-flash") # Function to prompt Gemini AI for summaries def prompt(content): message = ( "You work as a sysadmin (Debian server infrastructure). " "You must create a list categorizing the importance in terms of security and priority, " "providing a brief summary for each package so that business managers can understand " "what each library is from this output of the `apt list -u` command: " f"{content}" ) response = model.generate_content([message]) return response.text
- apt_list.py 스크립트 실행: python apt_list.py
-
스크립트는 다음을 수행합니다.
- 보류 중인 Debian 패키지 업데이트를 검색합니다.
- 분류 및 설명을 위해 목록을 Gemini AI에 전달합니다.
- AI가 생성한 출력을 gemini_result.md에 저장합니다.
gemini_result.md를 열어 쉽게 의사소통할 수 있도록 명확하고 분류된 업데이트 요약을 확인하세요.
예제 출력
생성된 요약의 예는 다음과 같습니다.
## Debian Package Update List: Priority and Security The list below categorizes the packages available for update, considering their importance in terms of security and business operation priority. The classification is subjective and may vary depending on your company's specific context. **Category 1: High Priority - Critical Security (update immediately)** - **linux-generic, linux-headers-generic:** Critical kernel updates to fix security vulnerabilities. - **libcurl4:** Resolves potential security issues for data transfer operations. ... **Category 2: High Priority - Maintenance and Stability (update soon)** * **`e2fsprogs`, `logsave`:** Packages related to ext2/ext3/ext4 file systems. Update to ensure data integrity and file system stability. **Medium-High priority.** ... **Category 3: Medium Priority - Applications (update as needed)** * **`code`:** Visual Studio Code editor. Update for new features and bug fixes, but not critical for system security. * **`firefox`, `firefox-locale-en`, `firefox-locale-pt`:** Firefox browser. Updates for security fixes and new functionalities. Priority depends on Firefox usage in your infrastructure. ...
결론
Python과 Gemini AI를 약간 사용하면 Debian 패키지 업데이트 전달 방법을 자동화하고 개선할 수 있습니다. 이 스크립트는 AI를 시스템 관리 작업 흐름에 통합하기 위한 훌륭한 기반입니다. 이 게시물은 교육용이므로 Gemini API 리소스와 시스템 보안 처리에 주의하세요.
읽어주셔서 감사합니다! ?
위 내용은 Python과 Gemini를 사용하여 데비안 패키지 업데이트 요약 자동화(gemini--flash)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Linux 터미널에서 Python 버전을 보려고 할 때 Linux 터미널에서 Python 버전을 볼 때 권한 문제에 대한 솔루션 ... Python을 입력하십시오 ...

Fiddlerevery Where를 사용할 때 Man-in-the-Middle Reading에 Fiddlereverywhere를 사용할 때 감지되는 방법 ...

Python의 Pandas 라이브러리를 사용할 때는 구조가 다른 두 데이터 프레임 사이에서 전체 열을 복사하는 방법이 일반적인 문제입니다. 두 개의 dats가 있다고 가정 해

Uvicorn은 HTTP 요청을 어떻게 지속적으로 듣습니까? Uvicorn은 ASGI를 기반으로 한 가벼운 웹 서버입니다. 핵심 기능 중 하나는 HTTP 요청을 듣고 진행하는 것입니다 ...

Linux 터미널에서 Python 사용 ...

10 시간 이내에 컴퓨터 초보자 프로그래밍 기본 사항을 가르치는 방법은 무엇입니까? 컴퓨터 초보자에게 프로그래밍 지식을 가르치는 데 10 시간 밖에 걸리지 않는다면 무엇을 가르치기로 선택 하시겠습니까?

Investing.com의 크롤링 전략 이해 많은 사람들이 종종 Investing.com (https://cn.investing.com/news/latest-news)에서 뉴스 데이터를 크롤링하려고합니다.
