仓库同步脚本

python 复制代码
#!/home/labstation/.local/anaconda3/bin/python3
from paramiko import SSHClient as ssh
from paramiko import AutoAddPolicy
from rich.console import Console
import os
import time

cli = ssh()
cli.load_system_host_keys()
cli.set_missing_host_key_policy(AutoAddPolicy())
cli.connect("128.0.0.1", username="git")
stdin, stdout, stderr = cli.exec_command("")
repos = list(
    filter(
        lambda x: x.startswith("sw"),
        map(
            lambda x: x[x.find("sw") :],
            filter(
                lambda x: x.startswith("R") or x.startswith("W"),
                map(lambda x: x.strip(" "), stdout.read().decode("utf-8").split("\n")),
            ),
        ),
    )
)

richConsole = Console()
richConsole.print()
with richConsole.status("[red] company repos backup working[/]") as status:
    for repo in repos:
        if os.access("/home/labstation/workqueue/%s" % (repo), os.F_OK):
            print(f"{repo} fetch from remote start")
            os.system(
                "cd /home/labstation/workqueue/%s && git fetch 2>/dev/null 1>/dev/null"
                % (repo)
            )
            print(f"{repo} fetch from remote complete")
        else:
            print(f"{repo} clone from remote start")
            os.system(
                "git clone git@128.0.0.1:%s /home/labstation/workqueue/%s \
                2>/dev/null 1>/dev/null"
                % (repo, repo),
            )
            print(f"{repo} clone from remote complete")
相关推荐
甘露寺4 分钟前
【LangGraph 2026 核心原理解析】大模型 Tool Calling 机制与使用最佳实践全解
大数据·人工智能·python
万象资讯18 分钟前
2026 年外贸私域CRM系统最新实测榜单:数据主权与全链路增长选型指南
大数据·人工智能
数智化管理手记1 小时前
异常反复出现?精益生产生产异常闭环的三大常见问题场景
大数据·数据库·低代码·制造·精益工程
塔能物联运维1 小时前
高密度算力时代,热管理的竞争已从“散热”转向“控温”
大数据
Omics Pro1 小时前
华大等NC|微生物多样性与抗菌物质发现
大数据·人工智能·深度学习·语言模型·excel
Are_You_Okkk_2 小时前
非结构化文档破局:BeeParser+PandaWiki赋能车企技术资料规范化管理
大数据·人工智能·开源
Yuer20252 小时前
幻觉量化(Hallucination Quantization):从随机语言模型到确定性交付系统的工程范式
大数据·人工智能·语言模型
科技AI训练师2 小时前
2026 屋顶风机行业观察测评:英飞风机助力建筑通风排烟升级
大数据·人工智能
Elasticsearch3 小时前
使用 Elastic Observability 和 MCP 的 Agentic 驱动 Kubernetes 调查
elasticsearch
weixin_531651813 小时前
Git 操作指南
大数据·git·elasticsearch