def main(): server = config.Config().get_musicbrainz_server() musicbrainzngs.set_hostname(server) # Find whipper's plugins paths (local paths have higher priority) plugins_p = [directory.data_path('plugins')] # local path (in $HOME) if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv plugins_p.append( get_python_lib( plat_specific=False, standard_lib=False, prefix='/usr/local') + '/whipper/plugins') plugins_p.append( get_python_lib(plat_specific=False, standard_lib=False) + '/whipper/plugins') else: plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()] # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment(plugins_p)) list(map(pkg_resources.working_set.add, distributions)) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError as e: logger.critical("SystemError: %s", e) if (isinstance(e, common.EjectError) and cmd.options.eject in ('failure', 'always')): eject_device(e.device) return 255 except RuntimeError as e: print(e) return 1 except KeyboardInterrupt: return 2 except ImportError as e: raise except task.TaskException as e: if isinstance(e.exception, ImportError): raise ImportError(e.exception) elif isinstance(e.exception, common.MissingDependencyException): logger.critical('missing dependency "%s"', e.exception.dependency) return 255 if isinstance(e.exception, common.EmptyError): logger.debug("EmptyError: %s", e.exception) logger.critical('could not create encoded file') return 255 # in python3 we can instead do `raise e.exception` as that would show # the exception's original context logger.critical(e.exceptionMessage) return 255 return ret if ret else 0
def main(): server = config.Config().get_musicbrainz_server() musicbrainzngs.set_hostname(server) # Find whipper's plugins paths (local paths have higher priority) plugins_p = [directory.data_path('plugins')] # local path (in $HOME) if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv plugins_p.append( get_python_lib(plat_specific=False, standard_lib=False, prefix='/usr/local') + '/whipper/plugins') plugins_p.append(get_python_lib(plat_specific=False, standard_lib=False) + '/whipper/plugins') else: plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()] # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment(plugins_p) ) list(map(pkg_resources.working_set.add, distributions)) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError as e: logger.critical("SystemError: %s", e) if (isinstance(e, common.EjectError) and cmd.options.eject in ('failure', 'always')): eject_device(e.device) return 255 except RuntimeError as e: print(e) return 1 except KeyboardInterrupt: return 2 except ImportError as e: raise except task.TaskException as e: if isinstance(e.exception, ImportError): raise ImportError(e.exception) elif isinstance(e.exception, common.MissingDependencyException): logger.critical('missing dependency "%s"', e.exception.dependency) return 255 if isinstance(e.exception, common.EmptyError): logger.debug("EmptyError: %s", e.exception) logger.critical('could not create encoded file') return 255 # in python3 we can instead do `raise e.exception` as that would show # the exception's original context logger.critical(e.exceptionMessage) return 255 return ret if ret else 0
def main(): try: server = config.Config().get_musicbrainz_server() except KeyError as e: sys.stderr.write('whipper: %s\n' % str(e)) sys.exit() musicbrainzngs.set_hostname(server) # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment([directory.data_path('plugins')])) list(map(pkg_resources.working_set.add, distributions)) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError as e: sys.stderr.write('whipper: error: %s\n' % e) if (isinstance(e, common.EjectError) and cmd.options.eject in ('failure', 'always')): eject_device(e.device) return 255 except RuntimeError as e: print(e) return 1 except KeyboardInterrupt: return 2 except ImportError as e: raise except task.TaskException as e: if isinstance(e.exception, ImportError): raise ImportError(e.exception) elif isinstance(e.exception, common.MissingDependencyException): sys.stderr.write('whipper: error: missing dependency "%s"\n' % e.exception.dependency) return 255 if isinstance(e.exception, common.EmptyError): logger.debug("EmptyError: %r", str(e.exception)) sys.stderr.write('whipper: error: Could not create encoded file.\n' ) # noqa: E501 return 255 # in python3 we can instead do `raise e.exception` as that would show # the exception's original context sys.stderr.write(e.exceptionMessage) return 255 return ret if ret else 0
def main(): # set user agent musicbrainzngs.set_useragent("whipper", whipper.__version__, "https://github.com/JoeLametta/whipper") # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment([directory.data_path('plugins')])) map(pkg_resources.working_set.add, distributions) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError, e: sys.stderr.write('whipper: error: %s\n' % e) if (type(e) is common.EjectError and cmd.options.eject in ('failure', 'always')): eject_device(e.device) return 255
def main(): server = config.Config().get_musicbrainz_server() https_enabled = server['scheme'] == 'https' try: musicbrainzngs.set_hostname(server['netloc'], https_enabled) # Parameter 'use_https' is missing in versions of musicbrainzngs < 0.7 except TypeError: logger.warning("Parameter 'use_https' is missing in versions of " "musicbrainzngs < 0.7. This means whipper will only " "be able to communicate with the configured " "MusicBrainz server ('%s') over plain HTTP. If a " "custom server which speaks HTTPS only has been " "declared, a suitable version of the " "musicbrainzngs module will be needed " "to make it work in whipper.", server['netloc']) musicbrainzngs.set_hostname(server['netloc']) # Find whipper's plugins paths (local paths have higher priority) plugins_p = [directory.data_path('plugins')] # local path (in $HOME) if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv plugins_p.append( get_python_lib(plat_specific=False, standard_lib=False, prefix='/usr/local') + '/whipper/plugins') plugins_p.append(get_python_lib(plat_specific=False, standard_lib=False) + '/whipper/plugins') else: plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()] # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment(plugins_p) ) list(map(pkg_resources.working_set.add, distributions)) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError as e: logger.critical("SystemError: %s", e) if (isinstance(e, common.EjectError) and cmd.options.eject in ('failure', 'always')): # XXX: Pylint, instance of 'SystemError' has no 'device' member eject_device(e.device) return 255 except RuntimeError as e: print(e) return 1 except KeyboardInterrupt: return 2 except ImportError: raise except task.TaskException as e: if isinstance(e.exception, ImportError): raise ImportError(e.exception) elif isinstance(e.exception, common.MissingDependencyException): logger.critical('missing dependency "%s"', e.exception.dependency) return 255 if isinstance(e.exception, common.EmptyError): logger.debug("EmptyError: %s", e.exception) logger.critical('could not create encoded file') return 255 # in python3 we can instead do `raise e.exception` as that would show # the exception's original context logger.critical(e.exceptionMessage) return 255 return ret if ret else 0
def main(): # set user agent musicbrainzngs.set_useragent("whipper", whipper.__version__, "https://github.com/JoeLametta/whipper") try: server = config.Config().get_musicbrainz_server() except KeyError, e: sys.stderr.write('whipper: %s\n' % e.message) sys.exit() musicbrainzngs.set_hostname(server) # register plugins with pkg_resources distributions, _ = pkg_resources.working_set.find_plugins( pkg_resources.Environment([directory.data_path('plugins')]) ) map(pkg_resources.working_set.add, distributions) try: cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None) ret = cmd.do() except SystemError, e: sys.stderr.write('whipper: error: %s\n' % e) if (type(e) is common.EjectError and cmd.options.eject in ('failure', 'always')): eject_device(e.device) return 255 except RuntimeError, e: print(e) return 1 except KeyboardInterrupt: