Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging for ddf #78

Merged
merged 18 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,250 changes: 9,250 additions & 0 deletions INFO.log

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

QView3D, developed at SUNY's Hydra Lab, is an open-source software project designed to streamline the management and communication of 3D printing files to printer arrays. It offers users an expandable framework to enhance their workflow and take control of their process. Embracing an open community ethos, QView3d continuously evolves, actively seeking collaboration and feedback from users to improve and innovate.

## Development Teams
#### - Created and advised by [**Professor Michael Curry**](https://github.com/currymike123)
The project is maintained by computer science students at SUNY New Paltz, under the guidance of professor Michael Curry. Team members are responsible for the development, testing, and documentation of the software. The project is part of the Computer Science Department's capstone course, where students work on real-world projects to gain experience in software development.

### Fall 2024
## Lab Development Team

- [**Michael Curry**](https://github.com/currymike123)
- [**Lars Palombi** ](https://github.com/Lars-Codes)
- [**Jack Gusler**](https://github.com/jackgusler)
- [**Olamide Kumapayi**](https://github.com/olakuma)
- [**Nathan Gopee**](https://github.com/ndg8743)
- [**Ari Yeger**](https://github.com/L10nhunter)
- [**CJ Jenks**](https://github.com/iron768)
- [**Nathan Gopee**](https://github.com/ndg8743)

### Spring 2024
- [**Lars Palombi**](https://github.com/Lars-Codes)
- [**Jack Gusler**](https://github.com/jackgusler)
- [**Olamide Kumapayi**](https://github.com/olakuma)

## Features

Expand All @@ -36,7 +36,7 @@ QView3D, developed at SUNY's Hydra Lab, is an open-source software project desig

- **Frontend**: Vue.js with Bootstrap for styling.
- **Backend**: Flask integrated with SQLite, handling data through Node.js.
- **Communication**: Serial communication via Python, CORS for middleware support.
- **Communication**: Serial communication via Python.
- **Database**: SQLite.

## Architecture Diagram
Expand All @@ -45,7 +45,7 @@ QView3D, developed at SUNY's Hydra Lab, is an open-source software project desig

## Setup and Installation

The software is currently designed to run on Ubuntu 20.04 LTS and later. MacOS and Windows are not fully supported but can be achieved with additional configuration.
The software is currently designed to run on Ubuntu 20.04 LTS and later. MacOS and Windows support can be achieved with additional configuration.

Clone the repository:

Expand Down
7 changes: 6 additions & 1 deletion client/src/components/GCode3DImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ onMounted(async () => {
extrusionColor: getComputedStyle(document.documentElement).getPropertyValue('--bs-primary-color').trim() || '#7561A9',
backgroundColor: 'black',
buildVolume: { x: 250, y: 210, z: 220 },
lineWidth: 0.2,
lineHeight: 0.2,
extrusionWidth: 0.2,
renderExtrusion: false,
renderTubes: true,
});

preview.camera.position.set(0, 410, 365);
preview.camera.position.set(-200, 232, 200);
preview.camera.lookAt(0, 0, 0);

if (canvas.value) {
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/GCode3DLiveViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ onMounted(async () => {
extrusionColor: getComputedStyle(document.documentElement).getPropertyValue('--bs-primary-color').trim() || '#7561A9',
backgroundColor: 'black',
buildVolume: { x: 250, y: 210, z: 220 },
lineWidth: 0.2,
lineHeight: 0.2,
extrusionWidth: 0.2,
renderExtrusion: true,
renderTubes: true,
});

preview.camera.position.set(0, 475, 0);
preview.camera.position.set(-200, 232, 200);
preview.camera.lookAt(0, 0, 0);

if (job.value?.current_layer_height && preview) {
Expand Down
18 changes: 18 additions & 0 deletions client/src/model/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,24 @@ export function useGetJobFile() {
}
}

export function useGetLogFile() {
return {
async getLogFile(jobid: number) {
try {
const response = await api(`getlogfile?jobid=${jobid}`)
const decodedData = atob(response.file);
const byteArray = new Uint8Array(decodedData.split('').map(char => char.charCodeAt(0)));
const file = new Blob([byteArray], { type: 'text/plain' });
const file_name = response.filename
saveAs(file, file_name)
} catch (error) {
console.error(error)
toast.error('An error occurred while retrieving the file')
}
}
}
}

export function useGetFile() {
return {
async getFile(job: Job): Promise<File | undefined> {
Expand Down
13 changes: 11 additions & 2 deletions client/src/views/ErrorView.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { printers, type Device } from '../model/ports'
import { type Issue, useGetIssues, useCreateIssues, useAssignIssue, useDeleteIssue, useEditIssue } from '../model/issues'
import { pageSize, useGetJobs, type Job, useAssignComment, useGetJobFile, useGetFile, useRemoveIssue, useDownloadCsv, isLoading } from '../model/jobs';
import { pageSize, useGetJobs, type Job, useAssignComment, useGetJobFile, useGetFile, useGetLogFile, useRemoveIssue, useDownloadCsv, isLoading } from '../model/jobs';
import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue';
import { useRouter } from 'vue-router';
import GCode3DImageViewer from '@/components/GCode3DImageViewer.vue'
Expand All @@ -15,6 +15,7 @@ const { createIssue } = useCreateIssues()
const { assign } = useAssignIssue()
const { assignComment } = useAssignComment()
const { getFileDownload } = useGetJobFile()
const { getLogFile } = useGetLogFile()
const { getFile } = useGetFile()
const { deleteIssue } = useDeleteIssue()
const { removeIssue } = useRemoveIssue()
Expand Down Expand Up @@ -729,7 +730,15 @@ const onlyNumber = ($event: KeyboardEvent) => {
@click="getFileDownload(job.id)"
:disabled="job.file_name_original.includes('.gcode:')">
<i class="fas fa-download"></i>
<span class="ms-2">Download</span>
<span class="ms-2">Download Gcode</span>
</a>
</li>
<li>
<a class="dropdown-item d-flex align-items-center"
@click="getLogFile(job.id)"
:disabled="job.file_name_original.includes('.gcode:')">
<i class="fas fa-download"></i>
<span class="ms-2">Download Log</span>
</a>
</li>
<li>
Expand Down
13 changes: 11 additions & 2 deletions client/src/views/JobHistory.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { printers, type Device } from '../model/ports'
import { pageSize, useGetJobs, type Job, useGetJobFile, useDeleteJob, useClearSpace, useFavoriteJob, useGetFile, useAssignComment, useDownloadCsv, useRemoveIssue, isLoading } from '../model/jobs';
import { pageSize, useGetJobs, type Job, useGetJobFile, useDeleteJob, useClearSpace, useFavoriteJob, useGetFile, useGetLogFile, useAssignComment, useDownloadCsv, useRemoveIssue, isLoading } from '../model/jobs';
import { computed, onMounted, onBeforeUnmount, ref, watchEffect, onUnmounted } from 'vue';
import { type Issue, useGetIssues, useAssignIssue } from '../model/issues'
import { useRouter } from 'vue-router';
Expand All @@ -12,6 +12,7 @@ import '@vuepic/vue-datepicker/dist/main.css';
const { jobhistory, getFavoriteJobs } = useGetJobs()
const { getFileDownload } = useGetJobFile()
const { getFile } = useGetFile()
const { getLogFile } = useGetLogFile()
const { deleteJob } = useDeleteJob()
const { clearSpace } = useClearSpace()
const { favorite } = useFavoriteJob()
Expand Down Expand Up @@ -845,7 +846,15 @@ const onlyNumber = ($event: KeyboardEvent) => {
@click="getFileDownload(job.id)"
:disabled="job.file_name_original.includes('.gcode:')">
<i class="fas fa-download"></i>
<span class="ms-2">Download</span>
<span class="ms-2">Download Gcode</span>
</a>
</li>
<li>
<a class="dropdown-item d-flex align-items-center"
@click="getLogFile(job.id)"
:disabled="job.file_name_original.includes('.gcode:')">
<i class="fas fa-download"></i>
<span class="ms-2">Download Log</span>
</a>
</li>
<li>
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ SQLAlchemy
tzlocal==2.1
Werkzeug==3.0.3
eventlet==0.37.0
gunicorn==23.0.0
gunicorn==23.0.0
colorlog==6.7.0
discord.py==2.4.0
80 changes: 80 additions & 0 deletions server/ANSI_Remover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import re
import os
import sys

def remove_ansi_codes_with_progress(log_file_path):
"""
Removes ANSI escape codes from a log file and writes the cleaned content to a new file,
with progress tracking.

Parameters:
log_file_path (str): Path to the input log file.

Returns:
str: Path to the output file containing cleaned content.
Raises:
FileNotFoundError: If the input file does not exist.
ValueError: If the input file is not a `.log` file.
IOError: For any I/O operation errors.
"""
# Regex to match ANSI escape codes
ansi_escape = re.compile(r'\033[@-_][0-?]*[ -/]*[@-~]')

# Ensure the provided file path is a `.log` file
if not log_file_path.endswith('.log'):
raise ValueError("Input file must have a .log extension")

output_file_path = log_file_path.replace('color', 'noColor')

try:
# Open the input and output files
with open(log_file_path, 'r') as infile, open(output_file_path, 'w') as outfile:
for line in infile:
# Remove ANSI escape codes from the current line
cleaned_line = ansi_escape.sub('', line)
outfile.write(cleaned_line)
return output_file_path

except FileNotFoundError:
raise FileNotFoundError(f"The file {log_file_path} does not exist.")
except IOError as e:
raise IOError(f"An error occurred while processing the file: {e}")


import gzip
import shutil
import os


def compress_with_gzip(log_file_path):
"""
Compresses a log file using gzip compression.

Parameters:
log_file_path (str): Path to the input log file.

Returns:
str: Path to the compressed file if successful.

Raises:
FileNotFoundError: If the input file does not exist.
ValueError: If the input path is a directory or invalid.
IOError: For any I/O operation errors.
"""
# Validate the input path
if not os.path.isfile(log_file_path):
raise ValueError(f"The specified path '{log_file_path}' is not a valid file.")

compressed_file_path = log_file_path + '.gz'

try:
# Compress the file
with open(log_file_path, 'rb') as f_in, gzip.open(compressed_file_path, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
return compressed_file_path

except FileNotFoundError:
raise FileNotFoundError(f"The file '{log_file_path}' does not exist.")
except IOError as e:
raise IOError(f"An error occurred while compressing the file: {e}")

Loading