Mirage2/src/old-src/__main__.py

53 lines
1.4 KiB
Python
Raw Normal View History

2022-02-23 06:54:16 +00:00
#!/usr/bin/python3
# Python imports
2023-04-23 17:06:16 +00:00
import argparse
import faulthandler
import traceback
2022-02-23 06:54:16 +00:00
from setproctitle import setproctitle
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Application imports
2023-04-23 17:06:16 +00:00
from __builtins__ import *
from app import Application
2022-02-23 06:54:16 +00:00
2023-04-23 17:06:16 +00:00
def run():
try:
setproctitle(f"{app_name}")
2022-02-23 06:54:16 +00:00
faulthandler.enable() # For better debug info
parser = argparse.ArgumentParser()
# Add long and short arguments
2023-04-23 17:06:16 +00:00
parser.add_argument("--debug", "-d", default="false", help="Do extra console messaging.")
parser.add_argument("--trace-debug", "-td", default="false", help="Disable saves, ignore IPC lock, do extra console messaging.")
parser.add_argument("--no-plugins", "-np", default="false", help="Do not load plugins.")
parser.add_argument("--file", "-f", default=None, help="Open an image.")
parser.add_argument("--dir", "-d", default=None, help="Load a dir with images.")
2022-02-23 06:54:16 +00:00
# Read arguments (If any...)
args, unknownargs = parser.parse_known_args()
2023-04-23 17:06:16 +00:00
if args.debug == "true":
settings.set_debug(True)
if args.trace_debug == "true":
settings.set_trace_debug(True)
Application(args, unknownargs)
2022-02-23 06:54:16 +00:00
Gtk.main()
except Exception as e:
traceback.print_exc()
quit()
2023-04-23 17:06:16 +00:00
if __name__ == "__main__":
""" Set process title, get arguments, and create GTK main thread. """
run()