commit message from python script

This commit is contained in:
2023-04-26 20:00:01 +02:00
parent 446c080d2a
commit a0475b87a9
6 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
#! /usr/bin/env python3
import os
def read_sshkeys(target_folder = str, search_string = str):
key_liste = []
for root, dirs, files in os.walk(target_folder, topdown=False, ):
for name in files:
if name == search_string:
FullPATH = str(os.path.join(root, name))
#if FullPATH.endswith(".pub") is False :#and FullPATH.endswith("known_hosts") is False and FullPATH.endswith("authorized_keys") is False:
#if FullPATH.
key_liste.append({"FullPath": FullPATH,
"Name": name,
"Root": root,
"Folder": dirs})
return key_liste
if __name__ == "__main__":
search_jenkins_folder = "/home/jonnybravo/.jenkins/data/jobs"
for i in read_sshkeys(target_folder=search_jenkins_folder, search_string="config.xml"):
print(i["FullPath"])
with open(i["FullPath"], 'r') as file:
data = file.read()
data = data.replace('<daysToKeep>-1</daysToKeep>', '')
with open(i["FullPath"], 'w') as file:
file.write(data)