From 7943120b25bfb61dba43d43ef1ad2085011dca6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Sat, 13 Jan 2018 22:07:25 +0100 Subject: [PATCH] Use setuptools' automatic script creation --- gajim/gajim.py | 10 +++++++++- gajim/gajim_remote.py | 11 ++++++++++- gajim/history_manager.py | 13 ++++++++++--- launch.py | 12 ++---------- scripts/gajim | 32 ------------------------------- scripts/gajim-history-manager | 36 ----------------------------------- scripts/gajim-remote | 31 ------------------------------ setup.py | 13 +++++++++---- 8 files changed, 40 insertions(+), 118 deletions(-) delete mode 100644 scripts/gajim delete mode 100644 scripts/gajim-history-manager delete mode 100644 scripts/gajim-remote diff --git a/gajim/gajim.py b/gajim/gajim.py index 27e827cf4..c0915ae0b 100644 --- a/gajim/gajim.py +++ b/gajim/gajim.py @@ -437,6 +437,14 @@ class GajimApplication(Gtk.Application): self.lookup_action(account + action_name).set_enabled(True) -if __name__ == '__main__': +def main(): + if sys.platform != 'win32': + if os.geteuid() == 0: + sys.exit("You must not launch gajim as root, it is insecure.") + appli = GajimApplication() appli.run(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/gajim/gajim_remote.py b/gajim/gajim_remote.py index dbe3bb6b9..53bf9f905 100644 --- a/gajim/gajim_remote.py +++ b/gajim/gajim_remote.py @@ -27,6 +27,7 @@ # gajim-remote help will show you the D-BUS API of Gajim +import os import sys import locale import urllib @@ -500,5 +501,13 @@ class GajimRemote: raise exceptions.ServiceNotAvailable return None -if __name__ == '__main__': + +def main(): + if os.geteuid() == 0: + sys.exit("You must not launch gajim as root, it is insecure.") + GajimRemote() + + +if __name__ == '__main__': + main() diff --git a/gajim/history_manager.py b/gajim/history_manager.py index 72f1bc08b..f53073788 100644 --- a/gajim/history_manager.py +++ b/gajim/history_manager.py @@ -30,7 +30,6 @@ import os import sys -import signal import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk @@ -668,7 +667,15 @@ class HistoryManager: path = self.logs_liststore.get_path(iter_) self.logs_listview.scroll_to_cell(path) -if __name__ == '__main__': - signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application + +def main(): + if sys.platform != 'win32': + if os.geteuid() == 0: + sys.exit("You must not launch gajim as root, it is insecure.") + HistoryManager() Gtk.main() + + +if __name__ == '__main__': + main() diff --git a/launch.py b/launch.py index 68e4680e0..20e03a7b7 100755 --- a/launch.py +++ b/launch.py @@ -1,12 +1,4 @@ #!/usr/bin/env python3 -import os -import sys - -if sys.platform != 'win32': - if os.geteuid() == 0: - sys.exit("You must not launch gajim as root, it is insecure.") - -import gajim.gajim as g - -g.GajimApplication().run(sys.argv) +from gajim import gajim +gajim.main() diff --git a/scripts/gajim b/scripts/gajim deleted file mode 100644 index 47f28512e..000000000 --- a/scripts/gajim +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -## -## Copyright (C) 2005 Yann Le Boulanger -## Copyright (C) 2006 Dimitur Kirov -## Stefan Bethge -## Copyright (C) 2008 Jonathan Schleifer -## -## This file is part of Gajim. -## -## Gajim is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation; version 3 only. -## -## Gajim is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Gajim. If not, see . -## - -import os -import sys - -if sys.platform != 'win32': - if os.geteuid() == 0: - sys.exit("You must not launch gajim as root, it is insecure.") - -import gajim.gajim as g - -g.GajimApplication().run(sys.argv) diff --git a/scripts/gajim-history-manager b/scripts/gajim-history-manager deleted file mode 100644 index cbf3cb4fc..000000000 --- a/scripts/gajim-history-manager +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -## -## Copyright (C) 2005 Yann Le Boulanger -## Copyright (C) 2006 Dimitur Kirov -## Stefan Bethge -## Copyright (C) 2008 Jonathan Schleifer -## -## This file is part of Gajim. -## -## Gajim is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation; version 3 only. -## -## Gajim is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Gajim. If not, see . -## - -import os -import sys - -if sys.platform != 'win32': - if os.geteuid() == 0: - sys.exit("You must not launch gajim as root, it is insecure.") - -import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk -import gajim.history_manager as g - -g.HistoryManager() -Gtk.main() diff --git a/scripts/gajim-remote b/scripts/gajim-remote deleted file mode 100644 index 624596878..000000000 --- a/scripts/gajim-remote +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 -## -## Copyright (C) 2005 Yann Le Boulanger -## Copyright (C) 2006 Dimitur Kirov -## Stefan Bethge -## Copyright (C) 2008 Jonathan Schleifer -## -## This file is part of Gajim. -## -## Gajim is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation; version 3 only. -## -## Gajim is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Gajim. If not, see . -## - -import os -import sys - -if os.geteuid() == 0: - sys.exit("You must not launch gajim as root, it is insecure.") - -import gajim.gajim_remote as g - -g.GajimRemote() diff --git a/setup.py b/setup.py index b0ef1dcc1..7a469624a 100644 --- a/setup.py +++ b/setup.py @@ -261,10 +261,15 @@ setup( 'test_nogui': test_nogui, 'update_po': update_po, }, - scripts=[ - 'scripts/gajim', - 'scripts/gajim-history-manager', - 'scripts/gajim-remote'], + entry_points={ + 'console_scripts': [ + 'gajim-remote = gajim.gajim_remote:main', + ], + 'gui_scripts': [ + 'gajim = gajim.gajim:main', + 'gajim-history-manager = gajim.history_manager:main', + ] + }, packages=find_packages(exclude=["gajim.dev", "test*"]), package_data={'gajim': package_data}, data_files=data_files,