Skip to content

Commit

Permalink
implented #145 and FIX #134
Browse files Browse the repository at this point in the history
  • Loading branch information
zitelog committed Dec 12, 2024
1 parent 9095609 commit 6194eb7
Show file tree
Hide file tree
Showing 22 changed files with 1,011 additions and 493 deletions.
59 changes: 59 additions & 0 deletions assets/script/lin/install_new_portable_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash


if [ "$#" -lt 1 ]; then
echo "Usage: $0 <path_to_gz_file> [destination_folder]" >&2
exit 1
fi

GZ_PATH="$1"
DEST_DIR="${2:-/opt}"
TEMP_DIR="/tmp/InstallApp"

if [ ! -f "$GZ_PATH" ]; then
echo "Error: File $GZ_PATH not found." >&2
exit 1
fi

if [ ! -d "$DEST_DIR" ]; then
echo "Error: Destination directory $DEST_DIR does not exist." >&2
exit 1
fi


mkdir -p "$TEMP_DIR"

echo "Extracting $GZ_PATH..."
gzip -d "$GZ_PATH" || {
echo "Error: Failed to extract the .gz file." >&2
exit 1
}


EXTRACTED_FILE="${GZ_PATH%.gz}"


if [ ! -f "$EXTRACTED_FILE" ]; then
echo "Error: Extraction failed, no file found at $EXTRACTED_FILE" >&2
exit 1
fi


echo "Copying $EXTRACTED_FILE to $DEST_DIR..."
cp "$EXTRACTED_FILE" "$DEST_DIR" || {
echo "Error: Failed to copy the extracted file." >&2
exit 1
}


echo "Cleaning up temporary files..."
rm -f "$EXTRACTED_FILE"

echo "Launching $EXTRACTED_FILE..."
"$DEST_DIR/$(basename "$EXTRACTED_FILE")" || {
echo "Error: Failed to launch the application." >&2
exit 1
}

echo "Installation and launch completed successfully in $DEST_DIR!"
exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ python_path=${1:-}
app_path=${2}

if [[ -z "$python_path" ]]; then
echo "Esecuzione dell'app senza Python..."
echo "Running the app without Python..."
pkexec "$app_path"
else
echo "Esecuzione con Python..."
echo "Running with Python..."
pkexec "$python_path" "$app_path"
fi
77 changes: 77 additions & 0 deletions assets/script/mac/install_new_portable_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash


if [ "$#" -lt 1 ]; then
echo "Usage: $0 <path_to_dmg_file> [destination_folder]" >&2
exit 1
fi


DMG_PATH="$1"
DEST_DIR="${2:-/Applications}"
MOUNT_DIR="/Volumes/InstallDMG"


if [ ! -f "$DMG_PATH" ]; then
echo "Error: File $DMG_PATH not found." >&2
exit 1
fi


if [ ! -d "$DEST_DIR" ]; then
echo "Error: Destination directory $DEST_DIR does not exist." >&2
exit 1
fi

echo "Mounting $DMG_PATH..."
hdiutil attach "$DMG_PATH" -nobrowse -mountpoint "$MOUNT_DIR" || {
echo "Error: Failed to mount the DMG file." >&2
exit 1
}


APP_PATH=$(find "$MOUNT_DIR" -type d -name "*.app" | head -n 1)

if [ -z "$APP_PATH" ]; then
echo "Error: No application found inside the DMG." >&2
hdiutil detach "$MOUNT_DIR"
exit 1
fi


APP_NAME=$(basename "$APP_PATH")
TARGET_PATH="$DEST_DIR/$APP_NAME"

if [ -d "$TARGET_PATH" ]; then
echo "Removing existing version of $APP_NAME in $DEST_DIR..."
rm -rf "$TARGET_PATH" || {
echo "Error: Failed to remove the old version." >&2
hdiutil detach "$MOUNT_DIR"
exit 1
}
fi


echo "Copying $APP_PATH to $DEST_DIR..."
cp -R "$APP_PATH" "$DEST_DIR" || {
echo "Error: Failed to copy the application." >&2
hdiutil detach "$MOUNT_DIR"
exit 1
}


echo "Unmounting the DMG..."
hdiutil detach "$MOUNT_DIR" || {
echo "Error: Failed to unmount the DMG." >&2
exit 1
}


echo "Launching $APP_NAME..."
open "$TARGET_PATH" || {
echo "Error: Failed to launch the application." >&2
exit 1
}

echo "Installation and launch completed successfully in $DEST_DIR!"
exit 0
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash

# Controlla gli argomenti
PYTHON_PATH=${1:-}
APP_PATH=${2:-}

if [[ -z "$PYTHON_PATH" ]]; then
echo "Percorso di Python mancante. Avvio senza argomento Python."
echo "Missing Python path. Starting without the Python argument."
osascript -e "do shell script \"launchctl asuser $(id -u) '${APP_PATH}'\" with administrator privileges"
else
echo "Avvio con Python: $PYTHON_PATH"
echo "Starting with Python: $PYTHON_PATH"
osascript -e "do shell script \"launchctl asuser $(id -u) '${PYTHON_PATH}' '${APP_PATH}'\" with administrator privileges"
fi
52 changes: 52 additions & 0 deletions assets/script/win/install_new_portable_version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
if ($args.Count -lt 1) {
Write-Host "Usage: .\$($MyInvocation.MyCommand.Name) <path_to_zip_file> [destination_folder]" -ForegroundColor Red
exit 1
}

$ZIP_PATH = $args[0]
$DEST_DIR = if ($args.Count -ge 2) { $args[1] } else { "C:\Program Files" }


if (-not (Test-Path -Path $ZIP_PATH)) {
Write-Host "Error: File $ZIP_PATH not found." -ForegroundColor Red
exit 1
}


if (-not (Test-Path -Path $DEST_DIR)) {
Write-Host "Error: Destination directory $DEST_DIR does not exist." -ForegroundColor Red
exit 1
}


Write-Host "Extracting $ZIP_PATH..."
try {
Expand-Archive -Path $ZIP_PATH -DestinationPath $DEST_DIR -Force
} catch {
Write-Host "Error: Failed to extract the ZIP file." -ForegroundColor Red
exit 1
}

$APP_NAME = (Get-ChildItem -Path $DEST_DIR | Where-Object { $_.PSIsContainer }).Name
$TARGET_PATH = Join-Path -Path $DEST_DIR -ChildPath $APP_NAME

if (Test-Path -Path $TARGET_PATH) {
Write-Host "Removing existing version of $APP_NAME in $DEST_DIR..."
Remove-Item -Path $TARGET_PATH -Recurse -Force
}

Write-Host "Moving extracted files to $DEST_DIR..."
Move-Item -Path (Join-Path -Path $DEST_DIR -ChildPath $APP_NAME) -Destination $DEST_DIR


Write-Host "Launching $APP_NAME..."
$exePath = Join-Path -Path $DEST_DIR -ChildPath "$APP_NAME\your_application.exe"
if (Test-Path -Path $exePath) {
Start-Process -FilePath $exePath
} else {
Write-Host "Error: Executable not found in $TARGET_PATH." -ForegroundColor Red
exit 1
}

Write-Host "Installation and launch completed successfully in $DEST_DIR!" -ForegroundColor Green
exit 0
10 changes: 10 additions & 0 deletions assets/script/win/launch_fit_with_admin_privileges.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$python_path = $args[0]
$app_path = $args[1]

if (-not $python_path) {
Write-Host "Running the app without Python..."
Start-Process -FilePath $app_path -Verb RunAs
} else {
Write-Host "Running with Python..."
Start-Process -FilePath $python_path -ArgumentList $app_path -Verb RunAs
}
11 changes: 0 additions & 11 deletions assets/script/win/launch_fit_with_privileges.bat

This file was deleted.

15 changes: 11 additions & 4 deletions common/constants/view/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@
WAR_NPCAP_NOT_INSTALLED = "Seems <strong>Npcap</strong> it's not installed in your PC.<br><br><strong style=\"color:red\">Without Npcap fit's functionality is very limited.</strong><br><br>Do you want install it?"

FIT_NEW_VERSION_TITLE = "New version of FIT"
FIT_NEW_VERSION_MSG = "There is a new version of FIT.<br><br>Do you want download and excute it?"
FIT_NEW_VERSION_MSG = (
"There is a new version of FIT.<br><br>Do you want download and excute it?"
)
FIT_NEW_VERSION_DOWNLOAD_TITLE = "FIT download"
FIT_NEW_VERSION_DOWNLOAD_MSG = "Download new version of FIT"

FIT_NEW_VERSION_INSTALLATION_TITLE = "FIT install"
FIT_NEW_VERSION_INSTALLATION_SUCCESS = "The new version of FIT has been successfully updated. Please wait a few seconds for the new version to start."
FIT_NEW_VERSION_INSTALLATION_ERROR = (
"Something went wrong during the update, please try again in debug mode."
)


DOWNLOAD_URL_ERROR = "I couldn't find the download URL."

FIT_NEW_VERSION_DOWNLOAD_ERROR = (
Expand All @@ -46,6 +55,4 @@
NVIDIA_GPU_PRESENT_MSG = 'This PC has an <strong>NVIDIA graphics card</strong>.<br><br>Check the NVIDIA control panel to see which processor is selected for 3D acceleration. <strong>If it is NVIDIA, disable it.</strong><strong style="color:red"><br><br>Otherwise, the screen will not be recorded.</strong>'

NVIDIA_GPU_GUIDE_URL = "https://github.com/fit-project/fit/wiki/Screen-recorder-Issue"
NVIDIA_GPU_GUIDE = (
"<strong><i><u>For more info read the guide</u></i></strong>"
)
NVIDIA_GPU_GUIDE = "<strong><i><u>For more info read the guide</u></i></strong>"
1 change: 1 addition & 0 deletions common/constants/view/tasks/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
PENDING = "Pending"
FAIL = "Fail"
SUCCESS = "Success"
UNKNOW = "Unknow"
23 changes: 13 additions & 10 deletions common/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,24 @@ def is_cmd(name):
return distutils.spawn.find_executable(name) is not None


def is_nvidia_gpu_present():
def is_nvidia_gpu_installed():
is_present = bool(is_cmd("nvidia-smi"))

if is_present is False:
if get_platform() == "win":
try:
result = subprocess.run(["wmic", "path", "win32_VideoController", "get", "name"],
capture_output=True, text=True, check=True)
result = subprocess.run(
["wmic", "path", "win32_VideoController", "get", "name"],
capture_output=True,
text=True,
check=True,
)
is_present = "NVIDIA" in result.stdout
except FileNotFoundError:
is_present = False

if is_present is False:
with tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
dxdiag_output_path = os.path.join(temp_dir, "dxdiag_output.txt")
try:
subprocess.run(["dxdiag", "/t", dxdiag_output_path], check=True)
Expand All @@ -360,20 +364,21 @@ def is_nvidia_gpu_present():

gpu_names = re.findall(r"Card name: (.*NVIDIA.*)", output)
is_present = bool(gpu_names)

except subprocess.CalledProcessError as e:
is_present = False
except FileNotFoundError:
is_present = False

if get_platform() == "lin":
try:
result = subprocess.run(["lspci"], capture_output=True, text=True, check=True)
result = subprocess.run(
["lspci"], capture_output=True, text=True, check=True
)
is_present = "NVIDIA" in result.stdout
except FileNotFoundError:
is_present = False


return is_present


Expand All @@ -396,8 +401,6 @@ def get_language():
return controller.options["language"]




# search for the first free port to bind the proxy
def find_free_port():
sock = socket.socket()
Expand Down
10 changes: 6 additions & 4 deletions fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from PyQt6 import QtWidgets, QtGui
from common.utility import resolve_path

from view.init import Init as InitView

from view.checks.initial_checks import InitialChecks
from view.wizard import Wizard as WizardView
from view.scrapers.web.web import Web as WebView
from view.scrapers.mail.mail import Mail as MailView
Expand All @@ -26,6 +27,7 @@
app.setWindowIcon(QtGui.QIcon(resolve_path("icon.ico")))

acquisition_window = None

def start_task(task, case_info):
global acquisition_window
options = {}
Expand All @@ -43,13 +45,13 @@ def start_task(task, case_info):
acquisition_window.init(case_info, wizard, options)
acquisition_window.show()

init = InitView()
initial_checks = InitialChecks()
wizard = WizardView()

init.finished.connect(wizard.show)
initial_checks.finished.connect(wizard.show)
# Wizard sends a signal when start button is clicked and case is stored on the DB
wizard.finished.connect(lambda task, case_info: start_task(task, case_info))

init.init_check()
initial_checks.run_checks()

sys.exit(app.exec())
Empty file added view/checks/__init__.py
Empty file.
Loading

0 comments on commit 6194eb7

Please sign in to comment.