libpurple/plugins/startup.py

Thu, 01 Sep 2016 23:58:47 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Thu, 01 Sep 2016 23:58:47 -0400
changeset 37984
6a5ca046a90d
parent 37983
7d134a4a87b2
permissions
-rw-r--r--

Make all Python files PEP8 compatible.

16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 #!/usr/bin/env python
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2 #
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
3 # Makes sure only one purple instance is running
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
4 #
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 # Purple is the legal property of its developers, whose names are too numerous
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 # to list here. Please refer to the COPYRIGHT file distributed with this
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
7 # source distribution.
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
8 #
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 # the Free Software Foundation; either version 2 of the License, or
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
12 # (at your option) any later version.
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 #
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
17 # GNU General Public License for more details.
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
18 #
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
19 # You should have received a copy of the GNU General Public License along with
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
20 # this program; if not, write to the Free Software Foundation, Inc.,
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
22 #
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23
37983
7d134a4a87b2 Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33932
diff changeset
24 from __future__ import absolute_import, division, print_function
7d134a4a87b2 Ensure all Python scripts are Py3k compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33932
diff changeset
25
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
26 import os
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 import sys
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
28
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29 import dbus
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
30
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
31
18208
a27936adb5ca 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16840
diff changeset
32 if len(sys.argv) == 1:
33932
c49bfe98716d Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents: 19859
diff changeset
33 print("Usage:", sys.argv[0], "<purple-client> [arguments]")
c49bfe98716d Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents: 19859
diff changeset
34 print("\nExample:\n ", sys.argv[0], "pidgin -d -c /my/home")
c49bfe98716d Fix build and other scripts on Python3.
Ashish Gupta <ashmew2@gmail.com>
parents: 19859
diff changeset
35 sys.exit(1)
18208
a27936adb5ca 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16840
diff changeset
36
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37 home = os.path.expanduser('~/.purple/')
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 for arg in range(1, len(sys.argv[1:])):
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
39 if sys.argv[arg] == "-c":
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
40 home = os.path.expanduser(sys.argv[arg + 1])
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
41 break
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43 bus = dbus.SessionBus()
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
44
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
45 try:
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
46 obj = bus.get_object("im.pidgin.purple.PurpleService",
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
47 "/im/pidgin/purple/PurpleObject")
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
48 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
49 userdir = purple.PurpleUserDir()
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
50 if not os.path.isabs(userdir):
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
51 userdir = os.path.join(purple.PurpleHomeDir(), userdir)
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
52 if home == userdir:
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
53 print("Already running.")
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
54 purple.PurpleBlistShow()
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
55 else:
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
56 print("Starting client from a different home directory.")
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
57 raise
16840
1bb9975b28fa Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
58 except:
37984
6a5ca046a90d Make all Python files PEP8 compatible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37983
diff changeset
59 os.execlp(sys.argv[1], " ".join(sys.argv[2:]))

mercurial