comparison Generic/openwith.py @ 6:2fc6b47dbe70

rename module globals to globalVars
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Sat, 06 Nov 2010 22:33:32 +0100
parents 2ac1551ad2ab
children a7b9f7e7dfa4
comparison
equal deleted inserted replaced
5:6502bfdaa84d 6:2fc6b47dbe70
35 # Modules 35 # Modules
36 import subprocess 36 import subprocess
37 import os 37 import os
38 38
39 # pyArq-Presupuestos modules 39 # pyArq-Presupuestos modules
40 import globals 40 import globalVars
41 41
42 # from gtkgui_helpers.py 42 # from gtkgui_helpers.py
43 def autodetect_desktop(): 43 def autodetect_desktop():
44 # recognize the environment and sets it in globals 44 # recognize the environment and sets it in globalVars
45 if os.name == 'nt': 45 if os.name == 'nt':
46 globals.desktop["desktop"] = "windows" 46 globalVars.desktop["desktop"] = "windows"
47 else: 47 else:
48 _processes = get_running_processes() 48 _processes = get_running_processes()
49 if 'gnome-session' in _processes: 49 if 'gnome-session' in _processes:
50 globals.desktop["desktop"] = "gnome" 50 globalVars.desktop["desktop"] = "gnome"
51 elif 'startkde' in _processes: 51 elif 'startkde' in _processes:
52 globals.desktop["desktop"] = "kde" 52 globalVars.desktop["desktop"] = "kde"
53 elif 'startxfce4' in _processes or 'xfce4-session' in _processes: 53 elif 'startxfce4' in _processes or 'xfce4-session' in _processes:
54 globals.desktop["desktop"] = "xfce" 54 globalVars.desktop["desktop"] = "xfce"
55 else: 55 else:
56 globals.desktop["desktop"] = "" 56 globalVars.desktop["desktop"] = ""
57 57
58 def get_running_processes(): 58 def get_running_processes():
59 '''returns running processes or None (if not /proc exists)''' 59 '''returns running processes or None (if not /proc exists)'''
60 if os.path.isdir('/proc'): 60 if os.path.isdir('/proc'):
61 # under Linux: checking if 'gnome-session' or 61 # under Linux: checking if 'gnome-session' or
102 command = '%s "%s"' % (executable, parameter) 102 command = '%s "%s"' % (executable, parameter)
103 return command 103 return command
104 104
105 def launch_file(kind, uri): 105 def launch_file(kind, uri):
106 # kind = "url" ,"mail", "image", "dxf" 106 # kind = "url" ,"mail", "image", "dxf"
107 _desktop = globals.desktop["desktop"] 107 _desktop = globalVars.desktop["desktop"]
108 if _desktop == "windows": 108 if _desktop == "windows":
109 try: 109 try:
110 os.startfile(uri) # if pywin32 is installed we open 110 os.startfile(uri) # if pywin32 is installed we open
111 except Exception: 111 except Exception:
112 pass 112 pass
119 command = 'kfmclient exec' 119 command = 'kfmclient exec'
120 elif _desktop == "xfce": 120 elif _desktop == "xfce":
121 command = 'exo-open' 121 command = 'exo-open'
122 else: 122 else:
123 if kind == 'url': 123 if kind == 'url':
124 command = globals.desktop["browser"] 124 command = globalVars.desktop["browser"]
125 elif kind == 'mail': 125 elif kind == 'mail':
126 command = globals.desktop["mailapp"] 126 command = globalVars.desktop["mailapp"]
127 elif kind == 'image': 127 elif kind == 'image':
128 command = globals.desktop["imageapp"] 128 command = globalVars.desktop["imageapp"]
129 elif kind == 'dxf': 129 elif kind == 'dxf':
130 command = globals.desktop["cadapp"] 130 command = globalVars.desktop["cadapp"]
131 else: # if no app is configured 131 else: # if no app is configured
132 return 132 return
133 command = build_command(command, uri) 133 command = build_command(command, uri)
134 try: 134 try:
135 exec_command(command) 135 exec_command(command)