diff options
author | André Apitzsch <git@apitzsch.eu> | 2018-01-14 00:07:25 +0300 |
---|---|---|
committer | André Apitzsch <git@apitzsch.eu> | 2018-01-14 00:50:38 +0300 |
commit | 7943120b25bfb61dba43d43ef1ad2085011dca6a (patch) | |
tree | c8e4da3c17e7b3f0a11a1efd9c83f240b5e7b8d3 | |
parent | aa6e9e7084a81d4263e12c378ab1fae6ce94a851 (diff) |
Use setuptools' automatic script creation
-rw-r--r-- | gajim/gajim.py | 10 | ||||
-rw-r--r-- | gajim/gajim_remote.py | 11 | ||||
-rw-r--r-- | gajim/history_manager.py | 13 | ||||
-rwxr-xr-x | launch.py | 12 | ||||
-rw-r--r-- | scripts/gajim | 32 | ||||
-rw-r--r-- | scripts/gajim-history-manager | 36 | ||||
-rw-r--r-- | scripts/gajim-remote | 31 | ||||
-rw-r--r-- | setup.py | 13 |
8 files changed, 40 insertions, 118 deletions
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() @@ -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 <asterix AT lagaule.org> -## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com> -## Stefan Bethge <stefan AT lanpartei.de> -## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org> -## -## 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 <http://www.gnu.org/licenses/>. -## - -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 <asterix AT lagaule.org> -## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com> -## Stefan Bethge <stefan AT lanpartei.de> -## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org> -## -## 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 <http://www.gnu.org/licenses/>. -## - -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 <asterix AT lagaule.org> -## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com> -## Stefan Bethge <stefan AT lanpartei.de> -## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org> -## -## 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 <http://www.gnu.org/licenses/>. -## - -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() @@ -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, |