Skip to content

Logo

TUIX

  • Terminal User Interface eXperience
  • SkillCollector Admin Panel
  • Version 1.0
  • Author: Reima Parviainen
  • Team: Gang de Farine
  • Documentation v. 1.0 (3.4.2023)
  • Gitlab Repository

Overview

TUIX (Terminal User Interface eXperience) is tightly connected to the main project SkillCollector but it is a standalone application written in Python. TUIX -application is a command-line interface tool for managing and querying a PostgreSQL database. The tool has various functions, such as creating folders, reading CSV files, updating database records, deleting records, and querying records based on various criteria. It also has functions for reading and displaying system logs and command histories. It is also used to update SFIA skills and descriptions whenever new versions are released.

UI

Python Modules used in TUIX

os

  • The os module provides a way of interacting with the operating system.
  • It provides functions for creating, deleting, and modifying files and directories, getting information about the current working directory, and more.
  • In this project, the os module is used to create new directories, check if a file exists, and run terminal commands.

psycopg2

  • psycopg2 is a PostgreSQL database adapter for the Python programming language.
  • It provides an interface to communicate with a PostgreSQL database from a Python script.
  • In this project, psycopg2 is used to establish a connection to a PostgreSQL database, execute SQL queries, and commit transactions.

time

  • The time module provides various functions to work with time and dates.
  • It provides functions for measuring the time elapsed between events, pausing execution for a specified amount of time, and more.
  • In this project, the time module is used to pause execution for a short period after some actions, such as creating a new directory.

csv

  • The csv module provides functionality for working with CSV files.
  • It allows us to read from and write to CSV files using a variety of options and settings.
  • In this project, the csv module is used to write the results of SQL queries to CSV files.

subprocess

  • The subprocess module provides a way to spawn new processes and communicate with them.
  • It allows us to run system commands and interact with them programmatically from a Python script.
  • In this project, the subprocess module is used to execute terminal commands, such as reading system logs.

openpyxl

  • openpyxl is a Python library for reading and writing Excel files.
  • It provides an interface to interact with Excel files programmatically from a Python script.
  • In this project, the openpyxl module is used to read data from an Excel file and populate a PostgreSQL database with that data.

Functions

main()

  • The main function that initializes the program and establishes a connection to the database. It calls the menu() function to display the main menu.

connect_db()

  • Connects to the PostgreSQL database with the given credentials and returns the connection object.
  • Displays the main menu options and prompts the user to select an option. It calls check_menu(conn) to validate the user's input.

check_menu(conn)

  • Validates the user's input from the main menu and executes the appropriate function based on the selected option.

security_menu()

  • Displays the security menu options and prompts the user to select an option. It returns the selected option.

query(con, sql)

  • Executes a SQL query on the database and returns the results.

folder_create(newFolder)

  • Creates a new folder with the given name if it does not already exist.

to_csv(cur, my_query)

  • Exports the results of a SQL query to a CSV file.

read_csv(con)

  • Reads a CSV file and inserts its contents into the database.

update_hash(con)

  • Updates a hash value in the database.

insert_hash(con, new_hash)

  • Inserts a new hash value into the database.

delete_hash(con)

  • Deletes a hash value from the database.

class Skill

  • A class that represents a skill and its associated data.

excel_read(con)

  • Reads an Excel file and inserts its contents into the database.

skill_to_object(con, sheet)

  • Converts a worksheet of skill data to a list of Skill objects.

update_db(con, skill_list)

  • Updates the database with a list of Skill objects.

bash_history()

  • Displays the contents of the .bash_history file for a given user.

syslog_read()

  • Displays the contents of the syslog file.

quick_check(con, param)

  • Performs a quick check of the answers in the database based on the given parameter.

fetch_and_prompt(con, sql_query, all_query)

  • Executes a SQL query on the database and prompts the user to export the results to a CSV file.

list_hashes(con, toggle)

  • Displays a list of unused or all hashes in the database.