def main(): fix_windows_stdout_stderr() if sys.version_info < (3, 4): print("You need at least Python 3.4 for this application!") sys.exit(1) t = time.time() if GENERATE_UI and not hasattr(sys, 'frozen'): try: urh_dir = os.path.abspath( os.path.join(os.path.dirname(sys.argv[0]), "..", "..")) sys.path.append(urh_dir) sys.path.append(os.path.join(urh_dir, "src")) import generate_ui generate_ui.gen() print("Time for generating UI: %.2f seconds" % (time.time() - t)) except (ImportError, FileNotFoundError): print( "Will not regenerate UI, because script can't be found. This is okay in release." ) urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0] urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..") prefix = os.path.abspath(os.path.normpath(urh_dir)) src_dir = os.path.join(prefix, "src") if os.path.exists(src_dir) and not prefix.startswith( "/usr") and not re.match(r"(?i)c:\\program", prefix): # Started locally, not installed print( "Adding {0} to pythonpath. This is only important when running URH from source." .format(src_dir)) sys.path.insert(0, src_dir) from urh.util import util util.set_windows_lib_path() try: import urh.cythonext.signalFunctions import urh.cythonext.path_creator import urh.cythonext.util except ImportError: if hasattr(sys, "frozen"): print("C++ Extensions not found. Exiting...") sys.exit(1) print("Could not find C++ extensions, trying to build them.") old_dir = os.curdir os.chdir(os.path.join(src_dir, "urh", "cythonext")) from urh.cythonext import build build.main() os.chdir(old_dir) from urh.controller.MainController import MainController from urh import constants if constants.SETTINGS.value("theme_index", 0, int) > 0: os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(["URH"] + sys.argv[1:]) app.setWindowIcon(QIcon(":/icons/data/icons/appicon.png")) util.set_icon_theme() constants.SETTINGS.setValue("default_theme", app.style().objectName()) if constants.SETTINGS.value("theme_index", 0, int) > 0: app.setStyle(QStyleFactory.create("Fusion")) if constants.SETTINGS.value("theme_index", 0, int) == 2: palette = QPalette() background_color = QColor(56, 60, 74) text_color = QColor(211, 218, 227).lighter() palette.setColor(QPalette.Window, background_color) palette.setColor(QPalette.WindowText, text_color) palette.setColor(QPalette.Base, background_color) palette.setColor(QPalette.AlternateBase, background_color) palette.setColor(QPalette.ToolTipBase, background_color) palette.setColor(QPalette.ToolTipText, text_color) palette.setColor(QPalette.Text, text_color) palette.setColor(QPalette.Button, background_color) palette.setColor(QPalette.ButtonText, text_color) palette.setColor(QPalette.BrightText, Qt.red) palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) palette.setColor(QPalette.Highlight, QColor(200, 50, 0)) palette.setColor(QPalette.HighlightedText, text_color) app.setPalette(palette) main_window = MainController() if sys.platform == "darwin": menu_bar = main_window.menuBar() menu_bar.setNativeMenuBar(False) import multiprocessing as mp mp.set_start_method( "spawn") # prevent errors with forking in native RTL-SDR backend elif sys.platform == "win32": # Ensure we get the app icon in windows taskbar import ctypes ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( "jopohl.urh") import multiprocessing as mp mp.freeze_support() main_window.showMaximized() # main_window.setFixedSize(1920, 1080 - 30) # Youtube # use system colors for painting widget = QWidget() bgcolor = widget.palette().color(QPalette.Background) fgcolor = widget.palette().color(QPalette.Foreground) selection_color = widget.palette().color(QPalette.Highlight) constants.BGCOLOR = bgcolor constants.LINECOLOR = fgcolor constants.SELECTION_COLOR = selection_color constants.SEND_INDICATOR_COLOR = selection_color if "autoclose" in sys.argv[1:]: # Autoclose after 1 second, this is useful for automated testing timer = QTimer() timer.timeout.connect(app.quit) timer.start(1000) return_code = app.exec_() app.closeAllWindows() os._exit( return_code ) # sys.exit() is not enough on Windows and will result in crash on exit
def main(): if sys.version_info < (3, 4): print("You need at least Python 3.4 for this application!") sys.exit(1) t = time.time() if GENERATE_UI and not hasattr(sys, 'frozen'): try: urh_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..", "..")) sys.path.append(urh_dir) sys.path.append(os.path.join(urh_dir, "src")) import generate_ui generate_ui.gen() print("Time for generating UI: %.2f seconds" % (time.time() - t)) except (ImportError, FileNotFoundError): print("Will not regenerate UI, because script can't be found. This is okay in release.") urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0] urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..") prefix = os.path.abspath(os.path.normpath(urh_dir)) src_dir = os.path.join(prefix, "src") if os.path.exists(src_dir) and not prefix.startswith("/usr") and not re.match(r"(?i)c:\\program", prefix): # Started locally, not installed print("Adding {0} to pythonpath. This is only important when running URH from source.".format(src_dir)) sys.path.insert(0, src_dir) from urh.util import util util.set_windows_lib_path() try: import urh.cythonext.signalFunctions import urh.cythonext.path_creator import urh.cythonext.util except ImportError: print("Could not find C++ extensions, trying to build them.") old_dir = os.curdir os.chdir(os.path.join(src_dir, "urh", "cythonext")) from urh.cythonext import build build.main() os.chdir(old_dir) from urh.controller.MainController import MainController from urh import constants if constants.SETTINGS.value("theme_index", 0, int) > 0: os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(["URH"] + sys.argv[1:]) app.setWindowIcon(QIcon(":/icons/data/icons/appicon.png")) if sys.platform != "linux": # noinspection PyUnresolvedReferences import urh.ui.xtra_icons_rc QIcon.setThemeName("oxy") constants.SETTINGS.setValue("default_theme", app.style().objectName()) if constants.SETTINGS.value("theme_index", 0, int) > 0: app.setStyle(QStyleFactory.create("Fusion")) if constants.SETTINGS.value("theme_index", 0, int) == 2: palette = QPalette() background_color = QColor(56, 60, 74) text_color = QColor(211, 218, 227).lighter() palette.setColor(QPalette.Window, background_color) palette.setColor(QPalette.WindowText, text_color) palette.setColor(QPalette.Base, background_color) palette.setColor(QPalette.AlternateBase, background_color) palette.setColor(QPalette.ToolTipBase, background_color) palette.setColor(QPalette.ToolTipText, text_color) palette.setColor(QPalette.Text, text_color) palette.setColor(QPalette.Button, background_color) palette.setColor(QPalette.ButtonText, text_color) palette.setColor(QPalette.BrightText, Qt.red) palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) palette.setColor(QPalette.Highlight, QColor(200, 50, 0)) palette.setColor(QPalette.HighlightedText, text_color) app.setPalette(palette) main_window = MainController() if sys.platform == "darwin": menu_bar = main_window.menuBar() menu_bar.setNativeMenuBar(False) import multiprocessing as mp mp.set_start_method("spawn") # prevent errors with forking in native RTL-SDR backend elif sys.platform == "win32": # Ensure we get the app icon in windows taskbar import ctypes ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("jopohl.urh") main_window.showMaximized() # main_window.setFixedSize(1920, 1080 - 30) # Youtube # use system colors for painting widget = QWidget() bgcolor = widget.palette().color(QPalette.Background) fgcolor = widget.palette().color(QPalette.Foreground) selection_color = widget.palette().color(QPalette.Highlight) constants.BGCOLOR = bgcolor constants.LINECOLOR = fgcolor constants.SELECTION_COLOR = selection_color constants.SEND_INDICATOR_COLOR = selection_color if "autoclose" in sys.argv[1:]: # Autoclose after 1 second, this is useful for automated testing timer = QTimer() timer.timeout.connect(app.quit) timer.start(1000) return_code = app.exec_() app.closeAllWindows() os._exit(return_code) # sys.exit() is not enough on Windows and will result in crash on exit
def main(): if sys.version_info < (3, 4): print("You need at least Python 3.4 for this application!") sys.exit(1) if sys.platform == "win32": urh_dir = os.path.dirname(os.path.realpath(__file__)) if not os.path.islink(__file__) \ else os.path.dirname(os.path.realpath(os.readlink(__file__))) assert os.path.isdir(urh_dir) dll_dir = os.path.realpath(os.path.join(urh_dir, "dev", "native", "lib", "win")) print("Using DLLs from:", dll_dir) os.environ['PATH'] = dll_dir + ';' + os.environ['PATH'] t = time.time() if GENERATE_UI and not hasattr(sys, 'frozen'): try: urh_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..", "..")) sys.path.append(urh_dir) sys.path.append(os.path.join(urh_dir, "src")) import generate_ui generate_ui.gen() print("Time for generating UI: %.2f seconds" % (time.time() - t)) except (ImportError, FileNotFoundError): print("Will not regenerate UI, because script cant be found. This is okay in release.") urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0] urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe urh_dir = os.path.join(os.path.dirname(urh_exe), "..", "..") prefix = os.path.abspath(os.path.normpath(urh_dir)) src_dir = os.path.join(prefix, "src") if os.path.exists(src_dir) and not prefix.startswith("/usr") \ and not re.match(r"(?i)c:\\program", prefix): # Started locally, not installed print("Using modules from {0}".format(src_dir)) sys.path.insert(0, src_dir) try: import urh.cythonext.signalFunctions import urh.cythonext.path_creator import urh.cythonext.util except ImportError: print("Could not find C++ extensions, trying to build them.") old_dir = os.curdir os.chdir(os.path.join(src_dir, "urh", "cythonext")) from urh.cythonext import build build.main() os.chdir(old_dir) from urh.controller.MainController import MainController from urh import constants if constants.SETTINGS.value("use_fallback_theme", False, bool): os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(sys.argv) # noinspection PyUnresolvedReferences import urh.ui.xtra_icons_rc # Use oxy theme always QIcon.setThemeName("oxy") constants.SETTINGS.setValue("default_theme", QApplication.style().objectName()) if constants.SETTINGS.value("use_fallback_theme", False, bool): QApplication.setStyle(QStyleFactory.create("Fusion")) main_window = MainController() if sys.platform == "darwin": menu_bar = main_window.menuBar() menu_bar.setNativeMenuBar(False) main_window.showMaximized() # main_window.setFixedSize(1920, 1080 - 30) # Youtube # use system colors for painting widget = QWidget() bgcolor = widget.palette().color(QPalette.Background) fgcolor = widget.palette().color(QPalette.Foreground) selection_color = widget.palette().color(QPalette.Highlight) constants.BGCOLOR = bgcolor constants.LINECOLOR = fgcolor constants.SELECTION_COLOR = selection_color constants.SEND_INDICATOR_COLOR = selection_color if "autoclose" in sys.argv[1:]: # Autoclose after 1 second, this is useful for automated testing timer = QTimer() timer.timeout.connect(app.quit) timer.start(1000) os._exit(app.exec_()) # sys.exit() is not enough on Windows and will result in crash on exit
def main(): fix_windows_stdout_stderr() if sys.version_info < (3, 4): print("You need at least Python 3.4 for this application!") sys.exit(1) urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0] urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..") prefix = os.path.abspath(os.path.normpath(urh_dir)) src_dir = os.path.join(prefix, "src") if os.path.exists(src_dir) and not prefix.startswith( "/usr") and not re.match(r"(?i)c:\\program", prefix): # Started locally, not installed -> add directory to path sys.path.insert(0, src_dir) if len(sys.argv) > 1 and sys.argv[1] == "--version": import urh.version print(urh.version.VERSION) sys.exit(0) if GENERATE_UI and not hasattr(sys, 'frozen'): try: sys.path.insert(0, os.path.join(prefix)) from data import generate_ui generate_ui.gen() except (ImportError, FileNotFoundError): # The generate UI script cannot be found so we are most likely in release mode, no problem here. pass from urh.util import util util.set_shared_library_path() try: import urh.cythonext.signal_functions import urh.cythonext.path_creator import urh.cythonext.util except ImportError: if hasattr(sys, "frozen"): print("C++ Extensions not found. Exiting...") sys.exit(1) print("Could not find C++ extensions, trying to build them.") old_dir = os.path.realpath(os.curdir) os.chdir(os.path.join(src_dir, "urh", "cythonext")) from urh.cythonext import build build.main() os.chdir(old_dir) from urh.controller.MainController import MainController from urh import settings if settings.read("theme_index", 0, int) > 0: os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(["URH"] + sys.argv[1:]) app.setWindowIcon(QIcon(":/icons/icons/appicon.png")) try: app.styleHints().setShowShortcutsInContextMenus(True) except AttributeError: pass util.set_icon_theme() font_size = settings.read("font_size", 0, int) if font_size > 0: font = app.font() font.setPointSize(font_size) app.setFont(font) settings.write("default_theme", app.style().objectName()) if settings.read("theme_index", 0, int) > 0: app.setStyle(QStyleFactory.create("Fusion")) if settings.read("theme_index", 0, int) == 2: palette = QPalette() background_color = QColor(56, 60, 74) text_color = QColor(211, 218, 227).lighter() palette.setColor(QPalette.Window, background_color) palette.setColor(QPalette.WindowText, text_color) palette.setColor(QPalette.Base, background_color) palette.setColor(QPalette.AlternateBase, background_color) palette.setColor(QPalette.ToolTipBase, background_color) palette.setColor(QPalette.ToolTipText, text_color) palette.setColor(QPalette.Text, text_color) palette.setColor(QPalette.Button, background_color) palette.setColor(QPalette.ButtonText, text_color) palette.setColor(QPalette.BrightText, Qt.red) palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) palette.setColor(QPalette.Highlight, QColor(200, 50, 0)) palette.setColor(QPalette.HighlightedText, text_color) app.setPalette(palette) # use system colors for painting widget = QWidget() bg_color = widget.palette().color(QPalette.Background) fg_color = widget.palette().color(QPalette.Foreground) selection_color = widget.palette().color(QPalette.Highlight) settings.BGCOLOR = bg_color settings.LINECOLOR = fg_color settings.SELECTION_COLOR = selection_color settings.SEND_INDICATOR_COLOR = selection_color main_window = MainController() # allow usage of prange (OpenMP) in Processes multiprocessing.set_start_method("spawn") if sys.platform == "win32": # Ensure we get the app icon in windows taskbar import ctypes ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( "jopohl.urh") main_window.showMaximized() # main_window.setFixedSize(1920, 1080 - 30) # Youtube if "autoclose" in sys.argv[1:]: # Autoclose after 1 second, this is useful for automated testing timer = QTimer() timer.timeout.connect(app.quit) timer.start(1000) return_code = app.exec_() app.closeAllWindows() os._exit( return_code ) # sys.exit() is not enough on Windows and will result in crash on exit
def main(): fix_windows_stdout_stderr() if sys.version_info < (3, 4): print("You need at least Python 3.4 for this application!") sys.exit(1) urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0] urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..") prefix = os.path.abspath(os.path.normpath(urh_dir)) src_dir = os.path.join(prefix, "src") if os.path.exists(src_dir) and not prefix.startswith("/usr") and not re.match(r"(?i)c:\\program", prefix): # Started locally, not installed -> add directory to path sys.path.insert(0, src_dir) if len(sys.argv) > 1 and sys.argv[1] == "--version": import urh.version print(urh.version.VERSION) sys.exit(0) if GENERATE_UI and not hasattr(sys, 'frozen'): try: sys.path.insert(0, os.path.join(prefix)) from data import generate_ui generate_ui.gen() except (ImportError, FileNotFoundError): # The generate UI script cannot be found so we are most likely in release mode, no problem here. pass from urh.util import util util.set_shared_library_path() try: import urh.cythonext.signal_functions import urh.cythonext.path_creator import urh.cythonext.util except ImportError: if hasattr(sys, "frozen"): print("C++ Extensions not found. Exiting...") sys.exit(1) print("Could not find C++ extensions, trying to build them.") old_dir = os.path.realpath(os.curdir) os.chdir(os.path.join(src_dir, "urh", "cythonext")) from urh.cythonext import build build.main() os.chdir(old_dir) from urh.controller.MainController import MainController from urh import constants if constants.SETTINGS.value("theme_index", 0, int) > 0: os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(["URH"] + sys.argv[1:]) app.setWindowIcon(QIcon(":/icons/icons/appicon.png")) util.set_icon_theme() font_size = constants.SETTINGS.value("font_size", 0, int) if font_size > 0: font = app.font() font.setPointSize(font_size) app.setFont(font) constants.SETTINGS.setValue("default_theme", app.style().objectName()) if constants.SETTINGS.value("theme_index", 0, int) > 0: app.setStyle(QStyleFactory.create("Fusion")) if constants.SETTINGS.value("theme_index", 0, int) == 2: palette = QPalette() background_color = QColor(56, 60, 74) text_color = QColor(211, 218, 227).lighter() palette.setColor(QPalette.Window, background_color) palette.setColor(QPalette.WindowText, text_color) palette.setColor(QPalette.Base, background_color) palette.setColor(QPalette.AlternateBase, background_color) palette.setColor(QPalette.ToolTipBase, background_color) palette.setColor(QPalette.ToolTipText, text_color) palette.setColor(QPalette.Text, text_color) palette.setColor(QPalette.Button, background_color) palette.setColor(QPalette.ButtonText, text_color) palette.setColor(QPalette.BrightText, Qt.red) palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) palette.setColor(QPalette.Highlight, QColor(200, 50, 0)) palette.setColor(QPalette.HighlightedText, text_color) app.setPalette(palette) # use system colors for painting widget = QWidget() bg_color = widget.palette().color(QPalette.Background) fg_color = widget.palette().color(QPalette.Foreground) selection_color = widget.palette().color(QPalette.Highlight) constants.BGCOLOR = bg_color constants.LINECOLOR = fg_color constants.SELECTION_COLOR = selection_color constants.SEND_INDICATOR_COLOR = selection_color main_window = MainController() # allow usage of prange (OpenMP) in Processes multiprocessing.set_start_method("spawn") if sys.platform == "darwin": menu_bar = main_window.menuBar() menu_bar.setNativeMenuBar(False) elif sys.platform == "win32": # Ensure we get the app icon in windows taskbar import ctypes ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("jopohl.urh") main_window.showMaximized() # main_window.setFixedSize(1920, 1080 - 30) # Youtube if "autoclose" in sys.argv[1:]: # Autoclose after 1 second, this is useful for automated testing timer = QTimer() timer.timeout.connect(app.quit) timer.start(1000) return_code = app.exec_() app.closeAllWindows() os._exit(return_code) # sys.exit() is not enough on Windows and will result in crash on exit