added settings for better customization
This commit is contained in:
parent
07f83947cc
commit
ba9c483424
7
.settings.env
Normal file
7
.settings.env
Normal file
@ -0,0 +1,7 @@
|
||||
REDMINE_URL=http://pc23/redmine
|
||||
REDMINE_PROJECT_ID=223
|
||||
REDMINE_STATUS_ID=5 #Erledigt 3/Abgeschlossen 5
|
||||
REDMINE_ESTIMATED_HOURS=1
|
||||
REDMINE_DONE_RATIO=100
|
||||
|
||||
SCRIPT_DEBUG=0
|
||||
@ -6,17 +6,31 @@ from datetime import date, datetime
|
||||
import os, getpass
|
||||
|
||||
WHOAMI = getpass.getuser()
|
||||
ENV_PATH = f'/home/{WHOAMI}/.config/redmine-cli/.env'
|
||||
AUTH_ENV_PATH = f'/home/{WHOAMI}/.config/redmine-cli/.auth.env'
|
||||
SETTINGS_ENV_PATH = f'/home/{WHOAMI}/.config/redmine-cli/.settings.env'
|
||||
LOG_PATH = f'/home/{WHOAMI}/.config/redmine-cli/log'
|
||||
|
||||
load_dotenv(dotenv_path=ENV_PATH)
|
||||
|
||||
load_dotenv(dotenv_path=AUTH_ENV_PATH)
|
||||
load_dotenv(dotenv_path=SETTINGS_ENV_PATH)
|
||||
# REDMINE_URL= "https://192.168.10.231/redmine/"
|
||||
REDMINE_URL = "http://pc23/redmine"
|
||||
# Auth
|
||||
REDMINE_URL = os.getenv("REDMINE_URL")
|
||||
REDMINE_USERNAME = os.getenv('REDMINE_USERNAME')
|
||||
REDMINE_PASSWORD = os.getenv('REDMINE_PASSWORD')
|
||||
REDMINE_USER_ID = os.getenv('REDMINE_USER_ID')
|
||||
|
||||
# Settings
|
||||
REDMINE_PROJECT_ID = os.getenv('REDMINE_PROJECT_ID')
|
||||
REDMINE_STATUS_ID = os.getenv('REDMINE_STATUS_ID')
|
||||
REDMINE_ESTIMATED_HOURS = os.getenv('REDMINE_ESTIMATED_HOURS')
|
||||
REDMINE_DONE_RATIO = os.getenv('REDMINE_DONE_RATIO')
|
||||
SCRIPT_DEBUG = os.getenv('SCRIPT_DEBUG')
|
||||
|
||||
def debugging():
|
||||
if SCRIPT_DEBUG == 0:
|
||||
pass
|
||||
else:
|
||||
print('debug activated')
|
||||
|
||||
def custom_input(datatype, text, color):
|
||||
if color == "magenta":
|
||||
@ -26,20 +40,20 @@ def custom_input(datatype, text, color):
|
||||
|
||||
|
||||
def clear_console():
|
||||
os.system('clear')
|
||||
os.system('clear')
|
||||
|
||||
|
||||
def write_to_env(auth_to_change):
|
||||
if not os.path.exists(ENV_PATH):
|
||||
if not os.path.exists(AUTH_ENV_PATH):
|
||||
try:
|
||||
with open(ENV_PATH, 'w') as env_file:
|
||||
with open(AUTH_ENV_PATH, 'w') as env_file:
|
||||
for key, value in auth_to_change.items():
|
||||
env_file.write(f"{key}={value}\n")
|
||||
print(f"Credentials written to {ENV_PATH}")
|
||||
print(f"Credentials written to {AUTH_ENV_PATH}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
else:
|
||||
print(f"The file {ENV_PATH} already exists.")
|
||||
print(f"The file {AUTH_ENV_PATH} already exists.")
|
||||
|
||||
|
||||
def get_redmine_user(temp_username, temp_password):
|
||||
@ -61,7 +75,7 @@ def get_redmine_user(temp_username, temp_password):
|
||||
def get_credentials():
|
||||
global redmine, user
|
||||
|
||||
if os.path.exists(ENV_PATH):
|
||||
if os.path.exists(AUTH_ENV_PATH):
|
||||
try:
|
||||
redmine = Redmine(REDMINE_URL, username=REDMINE_USERNAME, password=REDMINE_PASSWORD, requests={'verify': False})
|
||||
# user = redmine.user.get("current")
|
||||
@ -98,13 +112,13 @@ def create_new_ticket_assigned_to_myself_and_set_to_done():
|
||||
estimated_hours_input = 0.5
|
||||
try:
|
||||
redmine.issue.create(
|
||||
project_id = 223, #EDV 223/IT Support 425
|
||||
project_id = REDMINE_PROJECT_ID, #EDV 223/IT Support 425
|
||||
tracker_id = 1,
|
||||
status_id = 5, #Erledigt 3/Abgeschlossen 5
|
||||
status_id = REDMINE_STATUS_ID, #Erledigt 3/Abgeschlossen 5
|
||||
assigned_to_id = REDMINE_USER_ID,
|
||||
estimated_hours = estimated_hours_input,
|
||||
estimated_hours = REDMINE_ESTIMATED_HOURS,
|
||||
subject = title,
|
||||
done_ratio = 100,
|
||||
done_ratio = REDMINE_DONE_RATIO,
|
||||
description = description,
|
||||
)
|
||||
try:
|
||||
@ -115,6 +129,7 @@ def create_new_ticket_assigned_to_myself_and_set_to_done():
|
||||
input(" Please press enter to continue...")
|
||||
|
||||
except Exception as e:
|
||||
print(REDMINE_PROJECT_ID)
|
||||
print(f" An error occurred: {e}")
|
||||
input(" Please press enter to continue...")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user