added settings for better customization
This commit is contained in:
@@ -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
|
||||||
+28
-13
@@ -6,17 +6,31 @@ from datetime import date, datetime
|
|||||||
import os, getpass
|
import os, getpass
|
||||||
|
|
||||||
WHOAMI = getpass.getuser()
|
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'
|
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= "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_USERNAME = os.getenv('REDMINE_USERNAME')
|
||||||
REDMINE_PASSWORD = os.getenv('REDMINE_PASSWORD')
|
REDMINE_PASSWORD = os.getenv('REDMINE_PASSWORD')
|
||||||
REDMINE_USER_ID = os.getenv('REDMINE_USER_ID')
|
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):
|
def custom_input(datatype, text, color):
|
||||||
if color == "magenta":
|
if color == "magenta":
|
||||||
@@ -30,16 +44,16 @@ def clear_console():
|
|||||||
|
|
||||||
|
|
||||||
def write_to_env(auth_to_change):
|
def write_to_env(auth_to_change):
|
||||||
if not os.path.exists(ENV_PATH):
|
if not os.path.exists(AUTH_ENV_PATH):
|
||||||
try:
|
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():
|
for key, value in auth_to_change.items():
|
||||||
env_file.write(f"{key}={value}\n")
|
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:
|
except Exception as e:
|
||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
else:
|
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):
|
def get_redmine_user(temp_username, temp_password):
|
||||||
@@ -61,7 +75,7 @@ def get_redmine_user(temp_username, temp_password):
|
|||||||
def get_credentials():
|
def get_credentials():
|
||||||
global redmine, user
|
global redmine, user
|
||||||
|
|
||||||
if os.path.exists(ENV_PATH):
|
if os.path.exists(AUTH_ENV_PATH):
|
||||||
try:
|
try:
|
||||||
redmine = Redmine(REDMINE_URL, username=REDMINE_USERNAME, password=REDMINE_PASSWORD, requests={'verify': False})
|
redmine = Redmine(REDMINE_URL, username=REDMINE_USERNAME, password=REDMINE_PASSWORD, requests={'verify': False})
|
||||||
# user = redmine.user.get("current")
|
# 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
|
estimated_hours_input = 0.5
|
||||||
try:
|
try:
|
||||||
redmine.issue.create(
|
redmine.issue.create(
|
||||||
project_id = 223, #EDV 223/IT Support 425
|
project_id = REDMINE_PROJECT_ID, #EDV 223/IT Support 425
|
||||||
tracker_id = 1,
|
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,
|
assigned_to_id = REDMINE_USER_ID,
|
||||||
estimated_hours = estimated_hours_input,
|
estimated_hours = REDMINE_ESTIMATED_HOURS,
|
||||||
subject = title,
|
subject = title,
|
||||||
done_ratio = 100,
|
done_ratio = REDMINE_DONE_RATIO,
|
||||||
description = description,
|
description = description,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
@@ -115,6 +129,7 @@ def create_new_ticket_assigned_to_myself_and_set_to_done():
|
|||||||
input(" Please press enter to continue...")
|
input(" Please press enter to continue...")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(REDMINE_PROJECT_ID)
|
||||||
print(f" An error occurred: {e}")
|
print(f" An error occurred: {e}")
|
||||||
input(" Please press enter to continue...")
|
input(" Please press enter to continue...")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user