| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | import sys | 
					
						
							| 
									
										
										
										
											2009-01-11 13:49:03 +00:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											2008-08-27 07:55:06 +00:00
										 |  |  | import getopt | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use_x = True | 
					
						
							| 
									
										
										
										
											2008-08-27 18:55:18 +00:00
										 |  |  | shortargs = 'hnv:' | 
					
						
							|  |  |  | longargs = 'help no-x verbose=' | 
					
						
							|  |  |  | opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split()) | 
					
						
							| 
									
										
										
										
											2008-08-27 07:55:06 +00:00
										 |  |  | for o, a in opts: | 
					
						
							| 
									
										
										
										
											2010-02-08 15:08:40 +01:00
										 |  |  |     if o in ('-n', '--no-x'): | 
					
						
							|  |  |  |         use_x = False | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-09 00:24:08 +00:00
										 |  |  | gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../..') | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-20 23:07:28 +02:00
										 |  |  | # look for modules in the CWD, then gajim/test/lib, then gajim/gajim, | 
					
						
							| 
									
										
										
										
											2009-01-11 13:49:03 +00:00
										 |  |  | # then everywhere else | 
					
						
							| 
									
										
										
										
											2017-08-12 02:39:55 +02:00
										 |  |  | sys.path.insert(1, gajim_root) | 
					
						
							| 
									
										
										
										
											2008-08-09 00:24:08 +00:00
										 |  |  | sys.path.insert(1, gajim_root + '/test/lib') | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # a temporary version of ~/.gajim for testing | 
					
						
							|  |  |  | configdir = gajim_root + '/test/tmp' | 
					
						
							| 
									
										
										
										
											2010-08-27 11:47:38 +02:00
										 |  |  | # plugins config dir | 
					
						
							|  |  |  | pluginsconfigdir = configdir + '/pluginsconfig' | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # define _ for i18n | 
					
						
							| 
									
										
										
										
											2016-10-10 15:22:51 +02:00
										 |  |  | import builtins | 
					
						
							|  |  |  | builtins._ = lambda x: x | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 15:11:55 +02:00
										 |  |  | from gajim.common.contacts import LegacyContactsAPI | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | def setup_env(): | 
					
						
							| 
									
										
										
										
											2010-02-08 15:08:40 +01:00
										 |  |  |     # wipe config directory | 
					
						
							|  |  |  |     if os.path.isdir(configdir): | 
					
						
							|  |  |  |         import shutil | 
					
						
							|  |  |  |         shutil.rmtree(configdir) | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:08:40 +01:00
										 |  |  |     os.mkdir(configdir) | 
					
						
							| 
									
										
										
										
											2010-08-27 11:47:38 +02:00
										 |  |  |     os.mkdir(pluginsconfigdir) | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-21 12:44:10 +02:00
										 |  |  |     from gajim.common import configpaths | 
					
						
							|  |  |  |     configpaths.set_config_root(configdir) | 
					
						
							|  |  |  |     configpaths.init() | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-13 13:18:56 +02:00
										 |  |  |     # for some reason gajim.common.app needs to be imported before xmpppy? | 
					
						
							|  |  |  |     from gajim.common import app | 
					
						
							| 
									
										
										
										
											2008-06-12 03:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:08:40 +01:00
										 |  |  |     import logging | 
					
						
							|  |  |  |     logging.basicConfig() | 
					
						
							| 
									
										
										
										
											2009-01-11 13:49:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-25 20:49:37 +02:00
										 |  |  |     configpaths.override_path('DATA', gajim_root + '/gajim/data') | 
					
						
							| 
									
										
										
										
											2017-08-13 13:18:56 +02:00
										 |  |  |     app.use_x = use_x | 
					
						
							| 
									
										
										
										
											2017-09-15 15:11:55 +02:00
										 |  |  |     app.contacts = LegacyContactsAPI() | 
					
						
							|  |  |  |     app.connections = {} | 
					
						
							| 
									
										
										
										
											2008-06-29 05:25:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-08 15:08:40 +01:00
										 |  |  |     if use_x: | 
					
						
							| 
									
										
										
										
											2017-08-12 02:39:55 +02:00
										 |  |  |         from gajim import gtkgui_helpers | 
					
						
							| 
									
										
										
										
											2017-09-16 12:18:22 +02:00
										 |  |  |         gtkgui_helpers.GUI_DIR = gajim_root + '/gajim/data/gui' | 
					
						
							| 
									
										
										
										
											2017-06-13 23:58:06 +02:00
										 |  |  |         from gajim.gajim import GajimApplication | 
					
						
							| 
									
										
										
										
											2017-08-13 13:18:56 +02:00
										 |  |  |         app.app = GajimApplication() |