-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
031e16a
commit d236f08
Showing
36 changed files
with
1,229 additions
and
284 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
Owly/Owly.xcodeproj/xcshareddata/xcschemes/Owly.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1600" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES" | ||
buildArchitectures = "Automatic"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "30B497C62C71C28B00780AAC" | ||
BuildableName = "Owly.app" | ||
BlueprintName = "Owly" | ||
ReferencedContainer = "container:Owly.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO" | ||
parallelizable = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "30B497DC2C71C28C00780AAC" | ||
BuildableName = "OwlyTests.xctest" | ||
BlueprintName = "OwlyTests" | ||
ReferencedContainer = "container:Owly.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
<TestableReference | ||
skipped = "NO" | ||
parallelizable = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "30B497E62C71C28C00780AAC" | ||
BuildableName = "OwlyUITests.xctest" | ||
BlueprintName = "OwlyUITests" | ||
ReferencedContainer = "container:Owly.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "30B497C62C71C28B00780AAC" | ||
BuildableName = "Owly.app" | ||
BlueprintName = "Owly" | ||
ReferencedContainer = "container:Owly.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "30B497C62C71C28B00780AAC" | ||
BuildableName = "Owly.app" | ||
BlueprintName = "Owly" | ||
ReferencedContainer = "container:Owly.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# api_key_page.py | ||
import json | ||
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLineEdit, QPushButton, QLabel | ||
from PyQt6.QtCore import QSettings | ||
|
||
class APIKeyPage(QWidget): | ||
def __init__(self): | ||
super().__init__() | ||
self.settings = QSettings("YourCompany", "FileOrganizerApp") | ||
self.init_ui() | ||
|
||
def init_ui(self): | ||
layout = QVBoxLayout() | ||
|
||
self.api_key_input = QLineEdit() | ||
self.api_key_input.setEchoMode(QLineEdit.EchoMode.Password) | ||
self.api_key_input.setText(self.settings.value("openai_api_key", "")) | ||
|
||
save_button = QPushButton("Save API Key") | ||
save_button.clicked.connect(self.save_api_key) | ||
|
||
layout.addWidget(QLabel("Enter your OpenAI API Key:")) | ||
layout.addWidget(self.api_key_input) | ||
layout.addWidget(save_button) | ||
|
||
self.setLayout(layout) | ||
|
||
def save_api_key(self): | ||
api_key = self.api_key_input.text() | ||
self.settings.setValue("openai_api_key", api_key) | ||
|
||
# Update config.json | ||
try: | ||
with open('config.json', 'r+') as f: | ||
config = json.load(f) | ||
config['openai_api_key'] = api_key | ||
f.seek(0) | ||
json.dump(config, f, indent=4) | ||
f.truncate() | ||
except FileNotFoundError: | ||
with open('config.json', 'w') as f: | ||
json.dump({'openai_api_key': api_key}, f, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# directories_page.py | ||
|
||
import os | ||
import subprocess | ||
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, | ||
QPushButton, QListWidget, QFileDialog, QMessageBox, QListWidgetItem) | ||
from PyQt6.QtCore import QThread, pyqtSignal, QSettings | ||
from watchdog.observers import Observer | ||
from watchdog.events import FileSystemEventHandler | ||
|
||
class WorkerThread(QThread): | ||
progress = pyqtSignal(int, int) | ||
finished = pyqtSignal() | ||
|
||
def __init__(self, directory): | ||
super().__init__() | ||
self.directory = directory | ||
|
||
def run(self): | ||
try: | ||
total_files = sum([len(files) for r, d, files in os.walk(self.directory)]) | ||
processed_files = 0 | ||
|
||
for root, dirs, files in os.walk(self.directory): | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
if os.path.basename(file_path) == '.DS_Store': | ||
print(f"Skipping .DS_Store file: {file_path}") | ||
continue | ||
subprocess.run(["python", "scripts/advanced_base64.py", file_path], check=True) | ||
subprocess.run(["python", "scripts/rename_files_base64.py", file_path], check=True) | ||
processed_files += 1 | ||
self.progress.emit(processed_files, total_files) | ||
|
||
except subprocess.CalledProcessError as e: | ||
print(f"An error occurred while running the scripts: {e}") | ||
self.finished.emit() | ||
|
||
class FileHandler(FileSystemEventHandler): | ||
def __init__(self, callback): | ||
self.callback = callback | ||
|
||
def on_created(self, event): | ||
if not event.is_directory: | ||
self.callback(event.src_path) | ||
|
||
class DirectoriesPage(QWidget): | ||
process_directory_signal = pyqtSignal(str) | ||
|
||
def __init__(self, index_manager): | ||
super().__init__() | ||
self.index_manager = index_manager | ||
self.settings = QSettings("YourCompany", "FileOrganizerApp") | ||
self.directories = self.settings.value("watched_directories", [], type=list) | ||
self.observers = [] | ||
self.init_ui() | ||
self.setup_watchers() | ||
|
||
def init_ui(self): | ||
layout = QVBoxLayout() | ||
|
||
self.directory_list = QListWidget() | ||
layout.addWidget(self.directory_list) | ||
|
||
button_layout = QHBoxLayout() | ||
add_button = QPushButton("Add Directory") | ||
remove_button = QPushButton("Remove Directory") | ||
process_button = QPushButton("Process Directories") | ||
|
||
add_button.clicked.connect(self.add_directory) | ||
remove_button.clicked.connect(self.remove_directory) | ||
process_button.clicked.connect(self.process_directories) | ||
|
||
button_layout.addWidget(add_button) | ||
button_layout.addWidget(remove_button) | ||
button_layout.addWidget(process_button) | ||
|
||
layout.addLayout(button_layout) | ||
|
||
self.setLayout(layout) | ||
self.load_directories() | ||
|
||
def load_directories(self): | ||
for directory in self.directories: | ||
self.directory_list.addItem(directory) | ||
|
||
def add_directory(self): | ||
directory = QFileDialog.getExistingDirectory(self, "Select Directory") | ||
if directory and directory not in self.directories: | ||
self.directories.append(directory) | ||
self.directory_list.addItem(directory) | ||
self.setup_watcher(directory) | ||
self.save_directories() | ||
|
||
def remove_directory(self): | ||
current_item = self.directory_list.currentItem() | ||
if current_item: | ||
directory = current_item.text() | ||
self.directories.remove(directory) | ||
self.directory_list.takeItem(self.directory_list.row(current_item)) | ||
self.remove_watcher(directory) | ||
self.save_directories() | ||
|
||
def process_directories(self): | ||
if not self.directories: | ||
QMessageBox.warning(self, "No Directories", "Please add directories to process.") | ||
return | ||
|
||
for directory in self.directories: | ||
self.process_directory_signal.emit(directory) | ||
|
||
def process_directory(self, directory): | ||
self.worker = WorkerThread(directory) | ||
self.worker.progress.connect(self.update_progress) | ||
self.worker.finished.connect(self.on_processing_finished) | ||
self.worker.start() | ||
|
||
def update_progress(self, processed, total): | ||
# Update progress in Queue page | ||
pass | ||
|
||
def on_processing_finished(self): | ||
QMessageBox.information(self, "Processing Complete", "Directory processing has finished.") | ||
|
||
def setup_watchers(self): | ||
for directory in self.directories: | ||
self.setup_watcher(directory) | ||
|
||
def setup_watcher(self, directory): | ||
event_handler = FileHandler(self.process_new_file) | ||
observer = Observer() | ||
observer.schedule(event_handler, directory, recursive=True) | ||
observer.start() | ||
self.observers.append(observer) | ||
|
||
def remove_watcher(self, directory): | ||
for observer in self.observers: | ||
if observer.watches.get(directory): | ||
observer.unschedule_all() | ||
observer.stop() | ||
self.observers.remove(observer) | ||
break | ||
|
||
def process_new_file(self, file_path): | ||
try: | ||
if os.path.basename(file_path) == '.DS_Store': | ||
print(f"Skipping .DS_Store file: {file_path}") | ||
return | ||
subprocess.run(["python", "scripts/advanced_base64.py", file_path], check=True) | ||
subprocess.run(["python", "scripts/rename_files_base64.py", file_path], check=True) | ||
self.index_manager.add_to_index(file_path) | ||
except subprocess.CalledProcessError as e: | ||
print(f"An error occurred while processing {file_path}: {e}") | ||
except Exception as e: | ||
print(f"An unexpected error occurred while processing {file_path}: {e}") | ||
|
||
def save_directories(self): | ||
self.settings.setValue("watched_directories", self.directories) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# index_manager.py | ||
|
||
import json | ||
import os | ||
|
||
class IndexManager: | ||
def __init__(self, index_file='processed_files_index.json'): | ||
self.index_file = index_file | ||
self.index = self.load_index() | ||
|
||
def load_index(self): | ||
if os.path.exists(self.index_file): | ||
with open(self.index_file, 'r') as f: | ||
return json.load(f) | ||
return {} | ||
|
||
def save_index(self): | ||
with open(self.index_file, 'w') as f: | ||
json.dump(self.index, f, indent=4) | ||
|
||
def is_file_processed(self, file_path): | ||
return file_path in self.index | ||
|
||
def add_processed_file(self, original_path, new_path, new_filename): | ||
self.index[original_path] = { | ||
'new_path': new_path, | ||
'new_filename': new_filename, | ||
'original_filename': os.path.basename(original_path) | ||
} | ||
self.save_index() | ||
|
||
def get_processed_file_info(self, original_path): | ||
return self.index.get(original_path) | ||
|
||
def get_all_processed_files(self): | ||
return self.index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# main.py | ||
|
||
import sys | ||
from PyQt6.QtWidgets import QApplication | ||
from PyQt6.QtGui import QIcon | ||
from main_window import MainWindow | ||
from index_manager import IndexManager | ||
|
||
def main(): | ||
app = QApplication(sys.argv) | ||
|
||
# Set the app icon | ||
icon = QIcon('icon.icns') # Make sure this file exists in your project directory | ||
app.setWindowIcon(icon) | ||
|
||
# On macOS, set the dock icon | ||
if sys.platform == 'darwin': | ||
app.setWindowIcon(icon) | ||
|
||
# Create the index manager | ||
app.setApplicationName("Owly") | ||
index_manager = IndexManager() | ||
|
||
# Create and show the main window | ||
main_window = MainWindow(index_manager) | ||
main_window.show() | ||
|
||
# Start the event loop | ||
sys.exit(app.exec()) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.