annotate libpurple/plugins/startup.py @ 27143:454d46e9cbb7

Make a function static and add two comments
author Mark Doliner <mark@kingant.net>
date Mon, 22 Jun 2009 08:15:58 +0000
parents 44b4e8bd759b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16784
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 # Makes sure only one purple instance is running
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 # Purple is the legal property of its developers, whose names are too numerous
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 # to list here. Please refer to the COPYRIGHT file distributed with this
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 # source distribution.
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 # the Free Software Foundation; either version 2 of the License, or
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 # (at your option) any later version.
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 # GNU General Public License for more details.
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 # along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18136
diff changeset
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
16784
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 #
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 import sys
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 import dbus
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 import os
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27
18136
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
28 if len(sys.argv) == 1:
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
29 print "Usage:", sys.argv[0], """<purple-client> [arguments]
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
30
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
31 Example:
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
32 """, sys.argv[0], "pidgin -d -c /my/home"
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
33 sys.exit(1)
00cec200ec58 1. Show the usage of -m in the help message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16784
diff changeset
34
16784
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 home = os.path.expanduser('~/.purple/')
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 for arg in range(1, len(sys.argv[1:])):
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 if sys.argv[arg] == "-c":
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 home = os.path.expanduser(sys.argv[arg + 1])
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 break
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 bus = dbus.SessionBus()
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 try:
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 userdir = purple.PurpleUserDir()
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 if not os.path.isabs(userdir):
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 userdir = os.path.join(purple.PurpleHomeDir(), userdir)
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 if home == userdir:
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 print "Already running."
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 purple.PurpleBlistShow()
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 else:
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 print "Starting client from a different home directory."
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 raise
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 except:
db06d4a18246 Add a python script plugins/startup.py which will first check whether a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 os.execlp(sys.argv[1], " ".join(sys.argv[2:]))