PluginManager/PluginManager.py

branch
6_0_x
changeset 4379
2fadbed7d297
parent 4022
f5f42921717e
equal deleted inserted replaced
4377:4bae1fa50c68 4379:2fadbed7d297
187 return ( 187 return (
188 False, 188 False,
189 self.tr("Could not create a package for {0}.") 189 self.tr("Could not create a package for {0}.")
190 .format(self.__develPluginFile)) 190 .format(self.__develPluginFile))
191 191
192 if Preferences.getPluginManager("ActivateExternal"): 192 fname = os.path.join(self.pluginDirs["user"], "__init__.py")
193 fname = os.path.join(self.pluginDirs["user"], "__init__.py") 193 if not os.path.exists(fname):
194 if not os.path.exists(fname): 194 if not os.path.exists(self.pluginDirs["user"]):
195 if not os.path.exists(self.pluginDirs["user"]): 195 os.mkdir(self.pluginDirs["user"], 0o755)
196 os.mkdir(self.pluginDirs["user"], 0o755) 196 try:
197 try: 197 f = open(fname, "w")
198 f = open(fname, "w")
199 f.close()
200 except IOError:
201 del self.pluginDirs["user"]
202
203 if not os.path.exists(self.pluginDirs["global"]) and \
204 os.access(Utilities.getPythonModulesDirectory(), os.W_OK):
205 # create the global plugins directory
206 os.mkdir(self.pluginDirs["global"], 0o755)
207 fname = os.path.join(self.pluginDirs["global"], "__init__.py")
208 f = open(fname, "w", encoding="utf-8")
209 f.write('# -*- coding: utf-8 -*-' + "\n")
210 f.write("\n")
211 f.write('"""' + "\n")
212 f.write('Package containing the global plugins.' + "\n")
213 f.write('"""' + "\n")
214 f.close() 198 f.close()
215 if not os.path.exists(self.pluginDirs["global"]): 199 except IOError:
216 del self.pluginDirs["global"] 200 del self.pluginDirs["user"]
217 else: 201
218 del self.pluginDirs["user"] 202 if not os.path.exists(self.pluginDirs["global"]) and \
203 os.access(Utilities.getPythonModulesDirectory(), os.W_OK):
204 # create the global plugins directory
205 os.mkdir(self.pluginDirs["global"], 0o755)
206 fname = os.path.join(self.pluginDirs["global"], "__init__.py")
207 f = open(fname, "w", encoding="utf-8")
208 f.write('# -*- coding: utf-8 -*-' + "\n")
209 f.write("\n")
210 f.write('"""' + "\n")
211 f.write('Package containing the global plugins.' + "\n")
212 f.write('"""' + "\n")
213 f.close()
214 if not os.path.exists(self.pluginDirs["global"]):
219 del self.pluginDirs["global"] 215 del self.pluginDirs["global"]
220 216
221 if not os.path.exists(self.pluginDirs["eric6"]): 217 if not os.path.exists(self.pluginDirs["eric6"]):
222 return ( 218 return (
223 False, 219 False,
237 not os.path.exists(self.__develPluginFile): 233 not os.path.exists(self.__develPluginFile):
238 return False 234 return False
239 235
240 self.__foundCoreModules = self.getPluginModules( 236 self.__foundCoreModules = self.getPluginModules(
241 self.pluginDirs["eric6"]) 237 self.pluginDirs["eric6"])
242 if "global" in self.pluginDirs: 238 if Preferences.getPluginManager("ActivateExternal"):
243 self.__foundGlobalModules = \ 239 if "global" in self.pluginDirs:
244 self.getPluginModules(self.pluginDirs["global"]) 240 self.__foundGlobalModules = \
245 if "user" in self.pluginDirs: 241 self.getPluginModules(self.pluginDirs["global"])
246 self.__foundUserModules = \ 242 if "user" in self.pluginDirs:
247 self.getPluginModules(self.pluginDirs["user"]) 243 self.__foundUserModules = \
244 self.getPluginModules(self.pluginDirs["user"])
248 245
249 return len(self.__foundCoreModules + self.__foundGlobalModules + 246 return len(self.__foundCoreModules + self.__foundGlobalModules +
250 self.__foundUserModules) > 0 247 self.__foundUserModules) > 0
251 248
252 def getPluginModules(self, pluginPath): 249 def getPluginModules(self, pluginPath):

eric ide

mercurial