import subprocess
from datetime import datetime
import time
import os
import string
import random
def run_command(command):
output1 = subprocess.run(command, capture_output=True, text=True)
# Execute multiple commands in sequence and capture their output
print(output1.stdout)
def random_modify_file(path='.'):
# 获取目录下所有不包含自身的文件
files = []
for f in os.listdir(path):
if os.path.isfile(f) and f != os.path.basename(os.path.realpath(__file__)):
files.append(f)
# 随机选择一个文件
random_file = random.choice(files)
# 打开文件并读取内容
with open(random_file, 'w') as file:
# Generate random content and write it to the file
content = str(random.randint(1, 100)) + '\n'
file.write(content)
print("{} is changed!".format(random_file))
def random_new_file():
letters_digits = string.ascii_lowercase + string.digits
filename = ''.join(random.choice(letters_digits) for i in range(6))
# Returning the filename with a .txt extension
filename = filename + '.txt'
with open(filename, 'w') as file:
pass
print("{} was generated!".format(filename))
def main():
while 1:
if datetime.now().hour == 17:
# 拉取代码
# 修改文件内容
# 1. 随机新建文件
# 2. 随机修改已有文件
random.choice([random_new_file, random_modify_file])()
# 提交代码
# Add all changes to the staging area
run_command(['git', 'add', '.'])
# Commit changes with a commit message
run_command(['git', 'commit', '-m', 'fixed'])
# Push changes to the remote repository
run_command(['git', 'push'])
print("auto push code completed!")
rt = random.randint(1, 60)
time.sleep(25*rt)
main()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!