def inspectPackage(self, path, package): '''Searches the given path for plugins in package. Returns a dict with the found plugins and their versions, if any.''' try: __import__(package, globals(), locals(), []) except: print 'LO QUE!!!' path = path + paths.DIR_SEP + package modules = [ x.split( '.' )[ 0 ] for x in os.listdir( path ) \ if x.endswith( '.py' ) and not x.startswith( '_' ) \ and x != 'Plugin.py' ] plugins = {} plugins = plugins.fromkeys(modules) for i in modules: try: mod = __import__( package + '.' + i, globals(), \ None, [ 'VERSION' ] ) plugins[i] = getattr(mod, 'VERSION') except AttributeError: pass except Exception, e: del plugins[i] dialog.error('Exception importing %s\n%s' % (i, str(e)), title='PluginManager')
def __delete(self, progress): progress.start_module(lang(30133), self.DELETE_STEPS) try: progress.update(lang(30516)) # deleting files source = os.path.dirname(self.path) remove_empty = setting("fm_movie_remove_empty") == "true" if setting("fm_movies_structure") == "0": # multiple folders count = utilfile.count_manage_directory(self.alt_method, source) if not dialog.warning(lang(30133), count): raise Exception(lang(30609)) utilfile.delete_directory(self.alt_method, source) else: # single folder match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(self.alt_method, source, match) log("Movie: delete match: %s" % match) if not dialog.warning(lang(30133), count): raise Exception(lang(30609)) utilfile.delete_files(self.alt_method, source, match, remove_empty) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.movieid = None self.path = None except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception, e: dialog.error(e.message)
def active_toggled( self, cell, path, user_data ): '''enable or disable the plugin''' model, column = user_data iterator= model.get_iter_from_string( path ) plugin = self.pluginManager.getPlugin( model.get_value( iterator, 1 ) ) if plugin != None: if plugin.isEnabled(): plugin.stop() model.set_value( iterator, column, False ) plugins = self.config.user['activePlugins'].split( ',' ) if plugin.name in plugins: plugins.pop( plugins.index( plugin.name ) ) self.config.user['activePlugins'] = ','.join(plugins) else: status = plugin.check() if status[ 0 ]: plugin.start() model.set_value( iterator, column, True ) plugins = self.config.user['activePlugins'].split( ',' ) if plugins[ 0 ] == '' and len( plugins ) == 1: self.config.user['activePlugins'] = plugin.name elif not plugin.name in plugins: s = ','.join(plugins) + ',' + plugin.name self.config.user['activePlugins'] = s else: dialog.error(_('Plugin initialization failed: \n' ) \ + status[1])
def __delete(self, progress): progress.start_module(lang(30132), self.DELETE_STEPS) try: progress.update(lang(30516)) # deleting files source = os.path.dirname(self.path) remove_empty = setting('fm_movies_remove_empty') == 'true' if setting('fm_movies_structure') == '0': # multiple folders count = utilfile.count_manage_directory(self.alt_method, source) if not dialog.warning(lang(30132), count): raise Exception(lang(30609)) utilfile.delete_directory(self.alt_method, source) else: # single folder match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(self.alt_method, source, match) log("Movie.__delete: match=%s" % match) if not dialog.warning(lang(30132), count): raise Exception(lang(30609)) utilfile.delete_files(self.alt_method, source, match, remove_empty) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.movieid = None self.path = None except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception as e: if debug.get(): log(debug.traceback.print_exc(), xbmc.LOGERROR) debug.exception_dialog(e) finally: progress.finish_module()
def __move(self, progress): progress.start_module(lang(30132), self.MOVE_STEPS) try: progress.update(lang(30590)) # detecting library place lib_source = os.path.dirname(os.path.dirname(os.path.dirname(self.path))) if self.destination == lib_source: raise Exception(lang(30602)) progress.update(lang(30506)) # moving files source = os.path.dirname(self.path) match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(self.alt_method, source, match) if not dialog.warning(lang(30132), count): raise Exception(lang(30609)) log("Episode: move source path: %s" % source) if setting('fm_episodes_structure') == '0': # multiple folders destination = os.path.join(self.destination, self.path.split(os.sep)[-3], self.path.split(os.sep)[-2]) log("Episode: move destination (multiple) |alt_method=%s|: %s" % (self.alt_method, destination)) else: # single folder destination = os.path.join(self.destination, self.path.split(os.sep)[-2]) log("Episode: move destination (single) |alt_method=%s|: %s" % (self.alt_method, destination)) utilfile.move_files(self.alt_method, source, destination, match, True) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.path = os.path.join(destination, os.path.basename(self.path)) self.episodeid = utilxbmc.get_episodeid_by_path(self.path) if self.episodeid: # if still in lib source folders progress.update(lang(30514)) # setting watched utilxbmc.set_episode_playcount(self.episodeid, self.playcount+1) except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception, e: dialog.error(e.message)
def inspectPackage(self, path, package): '''Searches the given path for plugins in package. Returns a dict with the found plugins and their versions, if any.''' try: __import__(package, globals(), locals(), []) except: print 'LO QUE!!!' path = path + paths.DIR_SEP + package modules = [ x.split( '.' )[ 0 ] for x in os.listdir( path ) \ if x.endswith( '.py' ) and not x.startswith( '_' ) \ and x != 'Plugin.py' ] plugins = {} plugins = plugins.fromkeys( modules ) for i in modules: try: mod = __import__( package + '.' + i, globals(), \ None, [ 'VERSION' ] ) plugins[i] = getattr( mod, 'VERSION' ) except AttributeError: pass except Exception, e: del plugins[i] dialog.error('Exception importing %s\n%s' % (i, str(e)), title = 'PluginManager')
def response_cb(response, message=''): '''callback for the set autoreply dialog''' if response == stock.ACCEPT: if message == '': dialog.error(_("Empty autoreply")) else: self.controller.autoReplyMessage = message self.config.user['autoReplyMessage'] = message
def response_cb(response, message=''): '''callback for the set autoreply dialog''' if response == gtk.RESPONSE_ACCEPT: if self.checkbox.get_active() and message == '': dialog.error(_("Empty autoreply")) else: self.config.user['autoReply'] = self.checkbox.get_active() self.config.user['autoReplyMessage'] = message
def response_cb(response, message=""): """callback for the set autoreply dialog""" if response == stock.ACCEPT: if message == "": dialog.error(_("Empty autoreply")) else: self.controller.autoReplyMessage = message self.config.user["autoReplyMessage"] = message
def __set_tag(self, progress): progress.start_module(lang(30702), self.SET_TAG_STEPS) try: if not self.movieid: raise Exception(lang(30604)) progress.update(lang(30597)) # setting tag utilxbmc.set_movie_tag(self.movieid, self.tag) except Exception, e: dialog.error(e.message)
def __preserve_playcount(self, progress): progress.start_module(lang(30701), self.PRESERVE_PLAYCOUNT_STEPS) try: if not self.movieid: raise Exception(lang(30604)) progress.update(lang(30598)) # setting old playcount utilxbmc.set_movie_playcount(self.movieid, self.playcount) except Exception, e: dialog.error(e.message)
def _on_ce_edit_cb(response, text=""): """method called when the edition is done""" if response == stock.ACCEPT: if text: ret, msg = self.customEmoticons.chageShortcut(shortcut, text) if not ret: dialog.error(msg) else: dialog.error(_("Empty shortcut"))
def __rate_lib(self, progress): progress.start_module(lang(30204), self.RATE_LIB_STEPS) try: if not self.episodeid: raise Exception(lang(30601)) progress.update(lang(30522)) # updating rating utilxbmc.set_episode_rating(self.episodeid, self.rating) except Exception, e: dialog.error(e.message)
def __rate_lib(self, progress): progress.start_module(lang(30204), self.RATE_LIB_STEPS) try: if not self.movieid: raise Exception(lang(30604)) progress.update(lang(30522)) # updating rating log("Movie ID is %d" % self.movieid) utilxbmc.set_movie_rating(self.movieid, self.rating) except Exception, e: dialog.error(e.message)
def _on_ce_edit_cb(response, text=''): '''method called when the edition is done''' if response == stock.ACCEPT: if text: success, msg = self.controller.customEmoticons.create(\ text, path, 1) if not success: dialog.error(msg) else: dialog.error(_("Empty shortcut"))
def bLogin_clicked(self , *args): if self.getUser() == '' or self.getPass() == '' or self.getStatus() == '': dialog.error(_("User or password empty")) return if self.currentInterface == 'login' and self.cRemember.get_active(): if self.cRememberPass.get_active(): self.users.addUser(self.getUser(), base64.b16encode(self.getPass()), self.getStatus()) else: self.users.addUser(self.getUser(),'',self.getStatus()) self.users.save() self.login()
def onMaiButtonClicked(self, *args): if self.config.glob['overrideMail'] == '': try: desktop.open(self.controller.hotmail.getLoginPage()) except OSError: dialog.error(_('Couldn\'t launch the default browser')) else: try: subprocess.Popen(self.config.glob['overrideMail']) except: dialog.error(_('Couldn\'t launch the e-mail client'))
def _impl(self, filename): close = True self.session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Load Part") part_load_status = None try: # look for part in open parts for open_part in self.session.Parts: if open_part.FullPath.lower() == filename.lower(): # set part as work part self.session.Parts.SetActiveDisplay(open_part, NXOpen.DisplayPartOption.AllowAdditional, NXOpen.PartDisplayPartWorkPartOption.UseLast) close = False break else: _, part_load_status = self.session.Parts.OpenActiveDisplay(filename, NXOpen.DisplayPartOption.AllowAdditional) if part_load_status.NumberUnloadedParts > 0: _part = part_load_status.GetPartName(0) _desc = part_load_status.GetStatusDescription(0) if _desc not in IGNORE_OPEN_ERRORS: raise Exception("{}: {}".format(_desc, _part)) self.session.ApplicationSwitchImmediate("UG_APP_MODELING") initial_state = self.session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Initial State") self.logger.info("Processing part: {}".format(self.work_part.FullPath)) func(self, filename) self.session.UndoToMark(initial_state, None) except Exception as err: dialog.error([ "Error opening part. ({})".format(filename), "", str(err) ]) raise err finally: if part_load_status: part_load_status.Dispose() if close and self.work_part.FullPath == filename: part_close_responses = self.session.Parts.NewPartCloseResponses() self.work_part.Close(NXOpen.BasePart.CloseWholeTree.FalseValue, NXOpen.BasePart.CloseModified.UseResponses, part_close_responses) part_close_responses.Dispose() self.session.ApplicationSwitchImmediate("UG_APP_NOPART")
def openMail(self, params): if self.config.glob['overrideMail'] == '': try: desktop.open(self.controller.hotmail.getLoginPage\ (params[0], params[1], params[2])) except OSError: dialog.error(_('Couldn\'t launch the default browser')) else: try: subprocess.Popen(self.config.glob['overrideMail']) except: dialog.error(_('Couldn\'t launch the e-mail client'))
def _on_ce_choosed(response, path, shortcut, size): '''method called when the ce is selected''' if response != stock.ACCEPT: return self.config.user['emoticonDir']= os.path.dirname(path) if size == dialog.CEChooser.SMALL: size = 0 else: size = 1 ret,msg = self.customEmoticons.create(shortcut, path, size) if not ret: dialog.error(msg)
def __rate_tag(self, progress): progress.start_module(lang(30205), self.RATE_TAG_STEPS) try: if not self.movieid: raise Exception(lang(30604)) progress.update(lang(30524)) # setting tag tag = setting("rt_movies_tag_text") if "%s" in tag: tag = tag % self.rating utilxbmc.set_movie_tag(self.movieid, tag) except Exception, e: dialog.error(e.message)
def __init__(self, encryptedMessage): ''' Contructor ''' if not PEX: import dialog dialog.error(_('You must install python-pexpect in order to use GPG encode'), \ None, _('GPG') + ' ' + _('Error')) return MainEncodeDecode.__init__(self, encryptedMessage) self.gui = GPGEncodeDecodeGui() self.en = GPGEncodeDecode(self) self.Slash = encryptedMessage.Slash self.nameGpg = self.gui.askGPGuser(_('this window'))
def _on_close(element): '''calidate the fields and display a dialog if something is not valid and return False, if all validated, return True''' (validated, message, element) = element.validate() if not validated: tmp = { 'identifier': element.identifier, 'value': element.value, 'message': message, } dialog.error(_("Field '%(identifier)s ('%(value)s') not valid\n" \ "'%(message)s'" % tmp)) return False else: element.on_last_change() return True
def launch(config: str): """ Launches the GUI. :param config: config file """ try: logging.debug("Init interface") init = threading.Thread(target=Interface.init, args=(config, )) init.start() logging.debug("Init welcome window") welcome = WelcomeWindow() welcome.mainloop() init.join() app = OECSyncApp() app.mainloop() except Exception as e: dlg.error(e)
def __move(self, progress): progress.start_module(lang(30132), self.MOVE_STEPS) try: progress.update(lang(30590)) # detecting library place if setting("fm_movies_structure") == "0": lib_source = os.path.dirname(os.path.dirname(self.path)) else: lib_source = os.path.dirname(self.path) if self.destination == lib_source: raise Exception(lang(30607)) progress.update(lang(30506)) # moving files source = os.path.dirname(self.path) if setting("fm_movies_structure") == "0": # multiple folders count = utilfile.count_manage_directory(self.alt_method, source) if not dialog.warning(lang(30132), count): raise Exception(lang(30609)) log("Movie: move source (multiple): %s" % source) log("Movie: move destination (multiple): %s" % self.destination) utilfile.move_directory(self.alt_method, source, self.destination) self.path = os.path.join(self.destination, self.path.split(os.sep)[-2], os.path.basename(self.path)) log("Movie: Self path (lib/title/files.*): %s" % self.path) else: # single folder match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(self.alt_method, source, match) if not dialog.warning(lang(30132), count): raise Exception(lang(30609)) log("Movie: move source (single): %s" % source) log("Movie: move destination (single): %s" % self.destination) utilfile.move_files(self.alt_method, source, self.destination, match) self.path = os.path.join(self.destination, os.path.basename(self.path)) log("Movie: Self path: %s" % self.path) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.movieid = utilxbmc.get_movieid_by_path(self.path) if self.movieid: progress.update(lang(30514)) # setting watched utilxbmc.set_movie_playcount(self.movieid, self.playcount + 1) except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception, e: dialog.error(e.message)
def __move(self, progress): progress.start_module(lang(30131), self.MOVE_STEPS) try: progress.update(lang(30590)) # detecting library place if setting('fm_movies_structure') == '0': lib_source = os.path.dirname(os.path.dirname(self.path)) else: lib_source = os.path.dirname(self.path) if self.destination == lib_source: raise Exception(lang(30607)) progress.update(lang(30506)) # moving files source = os.path.dirname(self.path) if setting('fm_movies_structure') == '0': # multiple folders count = utilfile.count_manage_directory(self.alt_method, source) if not dialog.warning(lang(30131), count): raise Exception(lang(30609)) utilfile.move_directory(self.alt_method, source, self.destination) self.path = os.path.join(self.destination, self.path.split(os.sep)[-2], os.path.basename(self.path)) else: # single folder match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(self.alt_method, source, match) if not dialog.warning(lang(30131), count): raise Exception(lang(30609)) utilfile.move_files(self.alt_method, source, self.destination, match) self.path = os.path.join(self.destination, os.path.basename(self.path)) log("Movie.__move: source=%s, destination=%s, self.path=%s, alt_method=%s" % (source, self.destination, self.path, self.alt_method)) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.movieid = utilxbmc.get_movieid_by_path(self.path) if self.movieid: progress.update(lang(30514)) # setting watched utilxbmc.set_movie_playcount(self.movieid, self.playcount+1) except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception as e: if debug.get(): log(debug.traceback.print_exc(), xbmc.LOGERROR) debug.exception_dialog(e) finally: progress.finish_module()
def ValueErrorHandler(err): if err[0] == 'xbmcvfs.mkdirs': log("ValueError Exception: Error creating folder: %s" % err[1]) dialog.error(lang(30611) + ' %s' % err[1]) if err[0] == 'xbmcvfs.rmdir': log("ValueError Exception: Error removing folder: %s" % err[1]) dialog.error(lang(30612) + ' %s' % err[1]) if err[0] == 'xbmcvfs.delete': log("ValueError Exception: Error removing file: %s" % err[1]) dialog.error(lang(30613) + ' %s' % err[1]) if err[0] == 'xbmcvfs.copy': log("ValueError Exception: Error copying %s to %s" % (err[1], err[2])) dialog.error(lang(30614) + ' %s -> %s' % (err[1], err[2]))
def __delete(self, progress): progress.start_module(lang(30133), self.DELETE_STEPS) try: progress.update(lang(30516)) # deleting files source = os.path.dirname(self.path) remove_empty = setting('fm_episodes_remove_empty') == 'true' match = os.path.splitext(os.path.basename(self.path))[0] log("Episode: delete match: %s" % match) count = utilfile.count_manage_files(self.alt_method, source, match) if not dialog.warning(lang(30133), count): raise Exception(lang(30609)) utilfile.delete_files(self.alt_method, source, match, remove_empty) progress.update(lang(30513)) # updating library progress.update_library(self.path) self.episodeid = None self.path = None except OSError: dialog.error(lang(30610)) except ValueError as err: ValueErrorHandler(err) except Exception, e: dialog.error(e.message)
def onMaiButtonClicked(self, *args): try: desktop.open(self.controller.hotmail.getLoginPage()) except OSError: dialog.error(_('Couldn\'t launch the default browser'))
def exception_dialog(self, error): if debug.get() == False: log(error, xbmc.LOGERROR) dialog.error(error)
logger.info("Unparsed args: {}".format(unparsed)) # default -> select if not any(vars(args).values()): logger.error("No/Invalid process args. Defaulting to select.") args.select = True if args.select: processor.add_parts_to_process(dialog.get_files_to_process()) if args.work: try: processor.add_parts_to_process(session.Parts.Work.FullPath) except: dialog.error("Session does not have a work part") if args.all_open: parts_added = False for part in session.Parts: processor.add_parts_to_process(part.FullPath) parts_added = True if not parts_added: # no files open dialog.error("No files are open") if args.mfg: processor.add_parts_to_process(args.mfg) processor.process_parts()
def error(self, message, removeSpell=True): if self.enabled: dialog.error( message + " " + \ _("Plugin disabled.")) self.stop(removeSpell)
def error(self, message, removeSpell=True): if self.enabled: dialog.error(message + " " + _("Plugin disabled.")) self.stop(removeSpell)