def main(): """The main entry point for igraph when invoked from the command line shell""" config = Configuration.instance() if config.filename: print("Using configuration from %s" % config.filename, file=sys.stderr) else: print("No configuration file, using defaults", file=sys.stderr) if "shells" in config: parts = [part.strip() for part in config["shells"].split(",")] shell_classes = [] available_classes = dict( [ (k, v) for k, v in globals().items() if isinstance(v, type) and issubclass(v, Shell) ] ) for part in parts: cls = available_classes.get(part, None) if cls is None: print("Warning: unknown shell class `%s'" % part, file=sys.stderr) continue shell_classes.append(cls) else: shell_classes = [IPythonShell, ClassicPythonShell] import platform if platform.system() == "Windows": shell_classes.insert(0, IDLEShell) shell = None for shell_class in shell_classes: # pylint: disable-msg=W0703 # W0703: catch "Exception" try: shell = shell_class() break except Exception: # Try the next one if "Classic" in str(shell_class): raise pass if isinstance(shell, Shell): if config["verbose"]: if shell.supports_progress_bar(): set_progress_handler(shell.get_progress_handler()) if shell.supports_status_messages(): set_status_handler(shell.get_status_handler()) shell() else: print("No suitable Python shell was found.", file=sys.stderr) print("Check configuration variable `general.shells'.", file=sys.stderr)
def main(): """The main entry point for igraph when invoked from the command line shell""" config = Configuration.instance() if config.filename: print >> sys.stderr, "Using configuration from %s" % config.filename else: print >> sys.stderr, "No configuration file, using defaults" if config.has_key("shells"): parts = [part.strip() for part in config["shells"].split(",")] shell_classes = [] available_classes = dict([(k, v) for k, v in globals().iteritems() if isinstance(v, type) and issubclass(v, Shell)]) for part in parts: klass = available_classes.get(part, None) if klass is None: print >> sys.stderr, "Warning: unknown shell class `%s'" % part continue shell_classes.append(klass) else: shell_classes = [IPythonShell, ClassicPythonShell] import platform if platform.system() == "Windows": shell_classes.insert(0, IDLEShell) shell = None for shell_class in shell_classes: # pylint: disable-msg=W0703 # W0703: catch "Exception" try: shell = shell_class() break except StandardError: # Try the next one if "Classic" in str(shell_class): raise pass if isinstance(shell, Shell): if config["verbose"]: if shell.supports_progress_bar(): set_progress_handler(shell.get_progress_handler()) if shell.supports_status_messages(): set_status_handler(shell.get_status_handler()) shell() else: print >> sys.stderr, "No suitable Python shell was found." print >> sys.stderr, "Check configuration variable `general.shells'."
def main(): if config.filename: print >>sys.stderr, "Using configuration from %s" % config.filename else: print >>sys.stderr, "No configuration file, using defaults" if config.has_key("shells"): parts = [part.strip() for part in config["shells"].split(",")] shell_classes = [] available_classes = dict([(k, v) for k, v in globals().iteritems() \ if isinstance(v, type) and issubclass(v, Shell)]) for part in parts: klass = available_classes.get(part, None) if klass is None: print >>sys.stderr, "Warning: unknown shell class `%s'" % part else: shell_classes.append(klass) else: shell_classes = [IPythonShell, ClassicPythonShell] import platform if platform.system() == "Windows": shell_classes.insert(0, IDLEShell) shell = None for shell_class in shell_classes: try: shell = shell_class() break except: # Try the next one pass if isinstance(shell, Shell): if config["verbose"] and shell.supports_progress_bar(): set_progress_handler(shell.get_progress_handler()) shell() else: print >>sys.stderr, "No suitable Python shell was found." print >>sys.stderr, "Check configuration variable `general.shells'."