-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmessy_organizer.py
More file actions
42 lines (37 loc) · 1.62 KB
/
messy_organizer.py
File metadata and controls
42 lines (37 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
import sys
import os
import argparse
def main():
print("Main: Starting Messy File Organizer...")
parser = argparse.ArgumentParser(description="Messy File Organizer - A tool to organize your messy downloads folder")
parser.add_argument('--cli', action='store_true', help='Run in command-line mode instead of GUI')
parser.add_argument('--config', default=os.path.join(os.path.expanduser("~"), '.config', 'mfo', 'config.json'),
help='Path to configuration file')
parser.add_argument('--log-level', default='INFO', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
help='Set the logging level')
parser.add_argument('--log-to-file', action='store_true', help='Log to file instead of console')
args = parser.parse_args()
if args.cli:
# Import and run the CLI version
from script import main as cli_main
cli_main(args)
else:
# Import and run the GUI version
try:
from PyQt5.QtWidgets import QApplication
from gui import MessyFileOrganizerGUI
app = QApplication(sys.argv)
window = MessyFileOrganizerGUI()
window.show()
sys.exit(app.exec_())
except ImportError:
print("Error: PyQt5 is required for the GUI. Install it with 'pip install PyQt5' or run with --cli flag.")
sys.exit(1)
except Exception as e:
print("Error starting GUI:", e)
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
main()